Skip to content

Commit

Permalink
feat(playertests): extend loading tests and add unloading tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandkakonyi committed Nov 30, 2023
1 parent f1dc4cf commit 6c8b9aa
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 25 deletions.
5 changes: 5 additions & 0 deletions integration_test/tests/helper/Sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ export const Sources = {
url: 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/mpds/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd',
type: SourceType.DASH,
} as SourceConfig,

akamaiLiveTest: {
url: 'https://cph-msl.akamaized.net/hls/live/2000341/test/master.m3u8',
type: SourceType.HLS,
} as SourceConfig,
};
3 changes: 2 additions & 1 deletion integration_test/tests/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PlaybackTest from './playbackTest';
import LoadingTest from './loadingTest';
import UnloadingTest from './unloadingTest';

export default [PlaybackTest, LoadingTest];
export default [PlaybackTest, LoadingTest, UnloadingTest];
69 changes: 45 additions & 24 deletions integration_test/tests/loadingTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,60 @@ import { TestScope } from 'cavy';
import {
callPlayerAndExpectEvent,
callPlayerAndExpectEvents,
EventBag,
EventSequence,
EventType,
FilteredEvent,
startPlayerTest,
} from '../playertesting';
import { Sources } from './helper/Sources';
import {
DownloadFinishedEvent,
HttpRequestType,
SourceConfig,
} from 'bitmovin-player-react-native';

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);
function loadingSourceTests(sourceConfig: SourceConfig, label: string) {
spec.describe(`loading a ${label} source`, () => {
spec.it('emits ReadyEvent event', async () => {
await startPlayerTest({}, async () => {
await callPlayerAndExpectEvent((player) => {
player.load(sourceConfig);
}, 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.it('emits SourceLoad and SourceLoaded events', async () => {
await startPlayerTest({}, async () => {
await callPlayerAndExpectEvents((player) => {
player.load(sourceConfig);
}, 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);
spec.it('emits DownloadFinished events', async () => {
await startPlayerTest({}, async () => {
await callPlayerAndExpectEvents(
(player) => {
player.load(sourceConfig);
},
EventBag(
FilteredEvent<DownloadFinishedEvent>(
EventType.DownloadFinished,
(event) =>
event.requestType === HttpRequestType.ManifestHlsMaster
),
FilteredEvent<DownloadFinishedEvent>(
EventType.DownloadFinished,
(event) =>
event.requestType === HttpRequestType.ManifestHlsVariant
)
)
);
});
});
});
});
}

loadingSourceTests(Sources.artOfMotionHls, 'VOD');
loadingSourceTests(Sources.akamaiLiveTest, 'live');
};
22 changes: 22 additions & 0 deletions integration_test/tests/unloadingTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { TestScope } from 'cavy';
import {
callPlayerAndExpectEvent,
EventType,
startPlayerTest,
} from '../playertesting';
import { Sources } from './helper/Sources';

export default (spec: TestScope) => {
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);
});
});
});
};

0 comments on commit 6c8b9aa

Please sign in to comment.