-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(playertests): add playback and loading tests
- Loading branch information
1 parent
8cefd02
commit c95599c
Showing
4 changed files
with
105 additions
and
42 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import ExampleSpec from './exampleSpec'; | ||
import PlaybackTest from './playbackTest'; | ||
import LoadingTest from './loadingTest'; | ||
|
||
export default [ExampleSpec]; | ||
export default [PlaybackTest, LoadingTest]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { TestScope } from 'cavy'; | ||
import { | ||
callPlayerAndExpectEvent, | ||
callPlayerAndExpectEvents, | ||
EventSequence, | ||
EventType, | ||
expectEvents, | ||
loadSourceConfig, | ||
playFor, | ||
RepeatedEvent, | ||
startPlayerTest, | ||
} from '../playertesting'; | ||
import { PausedEvent } from 'bitmovin-player-react-native'; | ||
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<PausedEvent>((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); | ||
}); | ||
}); | ||
}); | ||
}; |