diff --git a/integration_test/tests/exampleSpec.ts b/integration_test/tests/exampleSpec.ts deleted file mode 100644 index 0f293af4..00000000 --- a/integration_test/tests/exampleSpec.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { TestScope } from 'cavy'; -import { - callPlayerAndExpectEvents, - EventSequence, - EventType, - expectEvents, - loadSourceConfig, - RepeatedEvent, - startPlayerTest, -} from '../playertesting'; -import { SourceType } from 'bitmovin-player-react-native'; -export default (spec: TestScope) => { - spec.describe('calling play when a source is loaded', () => { - spec.it('emits a Play and Playing event', async () => { - await startPlayerTest({}, async () => { - await loadSourceConfig({ - url: 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8', - type: SourceType.HLS, - }); - await callPlayerAndExpectEvents((player) => { - player.play(); - }, EventSequence(EventType.Play, EventType.Playing)); - }); - }); - }); - spec.describe('playing a source', () => { - spec.it('emits TimeChanged events', async () => { - await startPlayerTest({}, async () => { - await loadSourceConfig({ - url: 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8', - type: SourceType.HLS, - }); - await callPlayerAndExpectEvents((player) => { - player.play(); - }, EventSequence(EventType.Play, EventType.Playing)); - await expectEvents(RepeatedEvent(EventType.TimeChanged, 5)); - }); - }); - }); -}; diff --git a/integration_test/tests/index.ts b/integration_test/tests/index.ts index 3a963c02..730702c4 100644 --- a/integration_test/tests/index.ts +++ b/integration_test/tests/index.ts @@ -1,3 +1,4 @@ -import ExampleSpec from './exampleSpec'; +import PlaybackTest from './playbackTest'; +import LoadingTest from './loadingTest'; -export default [ExampleSpec]; +export default [PlaybackTest, LoadingTest]; diff --git a/integration_test/tests/loadingTest.ts b/integration_test/tests/loadingTest.ts new file mode 100644 index 00000000..efe21661 --- /dev/null +++ b/integration_test/tests/loadingTest.ts @@ -0,0 +1,40 @@ +import { TestScope } from 'cavy'; +import { + callPlayerAndExpectEvent, + callPlayerAndExpectEvents, + EventSequence, + EventType, + startPlayerTest, +} from '../playertesting'; +import { Sources } from './helper/Sources'; + +export default (spec: TestScope) => { + spec.describe('loading a source', () => { + spec.it('emits ReadyEvent event', async () => { + await startPlayerTest({}, async () => { + await callPlayerAndExpectEvent((player) => { + player.load(Sources.artOfMotionHls); + }, EventType.Ready); + }); + }); + spec.it('emits SourceLoad and SourceLoaded events', async () => { + await startPlayerTest({}, async () => { + await callPlayerAndExpectEvents((player) => { + player.load(Sources.artOfMotionHls); + }, EventSequence(EventType.SourceLoad, EventType.SourceLoaded)); + }); + }); + }); + spec.describe('unloading the player', () => { + spec.it('emits SourceUnloaded event', async () => { + await startPlayerTest({}, async () => { + await callPlayerAndExpectEvent((player) => { + player.load(Sources.artOfMotionHls); + }, EventType.Ready); + await callPlayerAndExpectEvent((player) => { + player.unload(); + }, EventType.SourceUnloaded); + }); + }); + }); +}; diff --git a/integration_test/tests/playbackTest.ts b/integration_test/tests/playbackTest.ts new file mode 100644 index 00000000..a2e8307d --- /dev/null +++ b/integration_test/tests/playbackTest.ts @@ -0,0 +1,61 @@ +import { TestScope } from 'cavy'; +import { + callPlayerAndExpectEvent, + callPlayerAndExpectEvents, + EventSequence, + EventType, + expectEvents, + loadSourceConfig, + playFor, + RepeatedEvent, + startPlayerTest, +} from '../playertesting'; +import { Sources } from './helper/Sources'; + +export default (spec: TestScope) => { + spec.describe('calling player API when a source is loaded', () => { + spec.it( + 'emits a Play and Playing events after calling play API', + async () => { + await startPlayerTest({}, async () => { + await loadSourceConfig(Sources.artOfMotionHls); + await callPlayerAndExpectEvents((player) => { + player.play(); + }, EventSequence(EventType.Play, EventType.Playing)); + }); + } + ); + spec.it('emits a Paused event after calling pause API', async () => { + await startPlayerTest({}, async () => { + await loadSourceConfig(Sources.artOfMotionHls); + await playFor(1); + await callPlayerAndExpectEvent((player) => { + player.pause(); + }, EventType.Paused); + }); + }); + }); + spec.describe('playing a source', () => { + spec.it('emits TimeChanged events', async () => { + await startPlayerTest({}, async () => { + await loadSourceConfig(Sources.artOfMotionHls); + await callPlayerAndExpectEvents((player) => { + player.play(); + }, EventSequence(EventType.Play, EventType.Playing)); + await expectEvents(RepeatedEvent(EventType.TimeChanged, 5)); + }); + }); + }); + spec.describe('playing a source to its end', () => { + spec.it('emits PlaybackFinished event', async () => { + await startPlayerTest({}, async () => { + await loadSourceConfig(Sources.artOfMotionHls); + await callPlayerAndExpectEvent(async (player) => { + player.play(); + const duration = await player.getDuration(); + player.seek(duration - 3); + }, EventType.PlaybackFinished); + }); + }); + }); +};