From 39c2e07923568e4694e724864de8ff6f91c32461 Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Thu, 30 Nov 2023 14:14:27 +0100 Subject: [PATCH 1/5] feat(playertests): fix source loadingState in events --- ios/Event+JSON.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Event+JSON.swift b/ios/Event+JSON.swift index 0b6c817c..12b06ef5 100644 --- a/ios/Event+JSON.swift +++ b/ios/Event+JSON.swift @@ -5,7 +5,7 @@ extension Source { var json: [AnyHashable: Any] = [ "duration": duration, "isActive": isActive, - "loadingState": loadingState, + "loadingState": loadingState.rawValue, "isAttachedToPlayer": isAttachedToPlayer ] if let metadata { From 3993e56f36f33079b48d3b08141f6e4faedcc5bf Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Thu, 30 Nov 2023 14:14:55 +0100 Subject: [PATCH 2/5] feat(playertests): fix wrong type annotation for player testing function --- integration_test/playertesting/PlayerTesting.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_test/playertesting/PlayerTesting.ts b/integration_test/playertesting/PlayerTesting.ts index 74c13a70..c20cce83 100644 --- a/integration_test/playertesting/PlayerTesting.ts +++ b/integration_test/playertesting/PlayerTesting.ts @@ -126,8 +126,8 @@ export const expectEvents = async ( * @see {@link Player} * @see {@link EventType} */ -export const callPlayerAndExpectEvent = async ( - fn: (player: Player) => Promise

, +export const callPlayerAndExpectEvent = async ( + fn: (player: Player) => void, expectationConvertible: SingleEventExpectation | EventType, timeoutSeconds: number = 10 ): Promise => { From f4c040746a04efc5d5abd1cd70b0fb655fa073f0 Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Thu, 30 Nov 2023 14:17:22 +0100 Subject: [PATCH 3/5] feat(playertests): add Sources helper to support player tests --- integration_test/tests/helper/Sources.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 integration_test/tests/helper/Sources.ts diff --git a/integration_test/tests/helper/Sources.ts b/integration_test/tests/helper/Sources.ts new file mode 100644 index 00000000..e969b9d9 --- /dev/null +++ b/integration_test/tests/helper/Sources.ts @@ -0,0 +1,13 @@ +import { SourceConfig, SourceType } from 'bitmovin-player-react-native'; + +export const Sources = { + artOfMotionHls: { + url: 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8', + type: SourceType.HLS, + } as SourceConfig, + + artOfMotionDash: { + url: 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/mpds/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd', + type: SourceType.DASH, + } as SourceConfig, +}; From be36949719f3bb8299a04410e3d495a78da5bc10 Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Thu, 30 Nov 2023 14:18:58 +0100 Subject: [PATCH 4/5] feat(playertests): fix race-condition in player testing network --- integration_test/playertesting/PlayerTestWorld.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/integration_test/playertesting/PlayerTestWorld.ts b/integration_test/playertesting/PlayerTestWorld.ts index a5b77660..6005bbdd 100644 --- a/integration_test/playertesting/PlayerTestWorld.ts +++ b/integration_test/playertesting/PlayerTestWorld.ts @@ -72,10 +72,15 @@ export default class PlayerTestWorld { player.initialize(); this.player = player; + // Trick to wait for the player to be initialized + // otherwise initial events might be missed + await player.isPlaying(); + await fn().finally(() => { player.destroy(); this.isFinished_ = true; this.player = undefined; + this.eventListeners = {}; }); }; From 8cefd02b37546b016a9c6d3eede28fb4e01dc39f Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Thu, 30 Nov 2023 14:24:50 +0100 Subject: [PATCH 5/5] feat(playertests): add note about setting license key for tests --- CONTRIBUTING.md | 2 ++ integration_test/README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ad40bb66..c7ab5f7d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -129,6 +129,8 @@ yarn integration-test test:android yarn integration-test test:ios ``` +To set the license key to be used for the tests, you can set the key `"licenseKey"` in `integration_test/app.json`. + See available API for testing [here](/integration_test/playertesting/PlayerTesting.ts). ### Adding new tests diff --git a/integration_test/README.md b/integration_test/README.md index ea2bffdc..fd12cf6a 100644 --- a/integration_test/README.md +++ b/integration_test/README.md @@ -28,4 +28,6 @@ Hint: You can provide a specific iOS simulator by name when using `--simulator` yarn example ios --simulator="iPhone 14 Pro" ``` +To set the license key to be used for the tests, you can set the key `"licenseKey"` in `integration_test/app.json`. + Note: The tests are currently only supported on iOS simulators and Android emulators. Running them on real devices is not supported at the moment.