-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Player testing: Add Player Testing framework #332
Merged
rolandkakonyi
merged 22 commits into
development
from
player-testing/add-player-testing-framework
Dec 13, 2023
Merged
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6210d66
feat(playertesting): add player testing framework
rolandkakonyi fea3d22
Merge branch 'player-testing/cavy-setup' into player-testing/add-play…
rolandkakonyi 17c0e66
Merge branch 'player-testing/cavy-setup' into player-testing/add-play…
rolandkakonyi bff5d8d
feat(playertesting): add instructions when running without cavy
rolandkakonyi 9fc60c5
feat(playertesting): refactor
rolandkakonyi 8c469a7
Merge branch 'player-testing/cavy-setup' into player-testing/add-play…
rolandkakonyi 6a86342
Merge branch 'player-testing/cavy-setup' into player-testing/add-play…
rolandkakonyi 0d00e43
chore: add changelog entry
rolandkakonyi 97999dd
feat(playertesting): rename CLI commands
rolandkakonyi 188d3ec
chore: update contribution guide
rolandkakonyi f8a1ec0
Merge branch 'player-testing/cavy-setup' into player-testing/add-play…
rolandkakonyi 0d64213
Merge branch 'player-testing/cavy-setup' into player-testing/add-play…
rolandkakonyi 1634338
Merge branch 'player-testing/cavy-setup' into player-testing/add-play…
rolandkakonyi 7955765
Merge branch 'player-testing/cavy-setup' into player-testing/add-play…
rolandkakonyi 150bc5e
chore: use UUID generator library
rolandkakonyi fe5f4ea
feat(playertesting): make event expectation helpers more verbose
rolandkakonyi a4c62d7
feat(playertesting): use variadic parameters for multiple event expec…
rolandkakonyi 23323d3
feat(playertesting): add more meaningful tests
rolandkakonyi 9cf03b2
feat(playertesting): fix variadic parameters usage
rolandkakonyi 3742d68
feat(playertesting): update contribution guide with real test
rolandkakonyi a57ae4a
fix return type of RepeatedEvent function
rolandkakonyi 0d97cc6
feat(playertesting): rename PlayerWorld to PlayerTestWorld
rolandkakonyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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,4 +1,5 @@ | ||
{ | ||
"name": "IntegrationTest", | ||
"displayName": "IntegrationTest" | ||
"displayName": "IntegrationTest", | ||
"licenseKey": "ENTER_LICENSE_KEY" | ||
} |
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,5 +1,8 @@ | ||
import { AppRegistry } from 'react-native'; | ||
import TestableApp from './src/TestableApp'; | ||
import { name as appName } from './app.json'; | ||
import PlayerWorld from './playertesting/PlayerWorld'; | ||
import { name as appName, licenseKey } from './app.json'; | ||
|
||
PlayerWorld.defaultLicenseKey = licenseKey; | ||
|
||
AppRegistry.registerComponent(appName, () => TestableApp); |
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
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
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,65 @@ | ||
export enum EventType { | ||
AdBreakFinished = 'onAdBreakFinished', | ||
AdBreakStarted = 'onAdBreakStarted', | ||
AdClicked = 'onAdClicked', | ||
AdError = 'onAdError', | ||
AdFinished = 'onAdFinished', | ||
AdManifestLoad = 'onAdManifestLoad', | ||
AdManifestLoaded = 'onAdManifestLoaded', | ||
AdQuartile = 'onAdQuartile', | ||
AdScheduled = 'onAdScheduled', | ||
AdSkipped = 'onAdSkipped', | ||
AdStarted = 'onAdStarted', | ||
CastAvailable = 'onCastAvailable', | ||
CastPaused = 'onCastPaused', | ||
CastPlaybackFinished = 'onCastPlaybackFinished', | ||
CastPlaying = 'onCastPlaying', | ||
CastStarted = 'onCastStarted', | ||
CastStart = 'onCastStart', | ||
CastStopped = 'onCastStopped', | ||
CastTimeUpdated = 'onCastTimeUpdated', | ||
CastWaitingForDevice = 'onCastWaitingForDevice', | ||
Destroy = 'onDestroy', | ||
Event = 'onEvent', | ||
FullscreenEnabled = 'onFullscreenEnabled', | ||
FullscreenDisabled = 'onFullscreenDisabled', | ||
FullscreenEnter = 'onFullscreenEnter', | ||
FullscreenExit = 'onFullscreenExit', | ||
Muted = 'onMuted', | ||
Paused = 'onPaused', | ||
PictureInPictureAvailabilityChanged = 'onPictureInPictureAvailabilityChanged', | ||
PictureInPictureEnter = 'onPictureInPictureEnter', | ||
PictureInPictureEntered = 'onPictureInPictureEntered', | ||
PictureInPictureExit = 'onPictureInPictureExit', | ||
PictureInPictureExited = 'onPictureInPictureExited', | ||
PlaybackFinished = 'onPlaybackFinished', | ||
PlayerActive = 'onPlayerActive', | ||
PlayerError = 'onPlayerError', | ||
PlayerWarning = 'onPlayerWarning', | ||
Play = 'onPlay', | ||
Playing = 'onPlaying', | ||
Ready = 'onReady', | ||
Seeked = 'onSeeked', | ||
Seek = 'onSeek', | ||
TimeShift = 'onTimeShift', | ||
TimeShifted = 'onTimeShifted', | ||
StallStarted = 'onStallStarted', | ||
StallEnded = 'onStallEnded', | ||
SourceError = 'onSourceError', | ||
SourceLoaded = 'onSourceLoaded', | ||
SourceLoad = 'onSourceLoad', | ||
SourceUnloaded = 'onSourceUnloaded', | ||
SourceWarning = 'onSourceWarning', | ||
AudioAdded = 'onAudioAdded', | ||
AudioChanged = 'onAudioChanged', | ||
AudioRemoved = 'onAudioRemoved', | ||
SubtitleAdded = 'onSubtitleAdded', | ||
SubtitleChanged = 'onSubtitleChanged', | ||
SubtitleRemoved = 'onSubtitleRemoved', | ||
TimeChanged = 'onTimeChanged', | ||
Unmuted = 'onUnmuted', | ||
VideoPlaybackQualityChanged = 'onVideoPlaybackQualityChanged', | ||
DownloadFinished = 'onDownloadFinished', | ||
VideoDownloadQualityChanged = 'onVideoDownloadQualityChanged', | ||
PlaybackSpeedChanged = 'onPlaybackSpeedChanged', | ||
} |
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,95 @@ | ||
import { | ||
Player, | ||
PlayerConfig, | ||
Event, | ||
SourceConfig, | ||
ReadyEvent, | ||
TimeChangedEvent, | ||
} from 'bitmovin-player-react-native'; | ||
import { EventType } from './EventType'; | ||
import PlayerWorld from './PlayerWorld'; | ||
import { | ||
SingleEventExpectation, | ||
MultipleEventsExpectation, | ||
} from './expectations'; | ||
|
||
export const startPlayerTest = async ( | ||
config: PlayerConfig, | ||
fn: () => Promise<void> | ||
): Promise<void> => { | ||
return await PlayerWorld.shared.startPlayerTest(config, fn); | ||
}; | ||
|
||
export const callPlayer = async <T>( | ||
fn: (player: Player) => Promise<T> | ||
): Promise<T> => { | ||
return await PlayerWorld.shared.callPlayer(fn); | ||
}; | ||
|
||
export const expectEvent = async <T extends Event>( | ||
expectationConvertible: SingleEventExpectation | EventType, | ||
timeoutSeconds: number = 10 | ||
): Promise<T> => { | ||
return await PlayerWorld.shared.expectEvent( | ||
expectationConvertible, | ||
timeoutSeconds | ||
); | ||
}; | ||
|
||
export const expectEvents = async ( | ||
expectationsConvertible: MultipleEventsExpectation | EventType[], | ||
timeoutSeconds: number = 10 | ||
): Promise<Event[]> => { | ||
return await PlayerWorld.shared.expectEvents( | ||
expectationsConvertible, | ||
timeoutSeconds | ||
); | ||
}; | ||
|
||
export const callPlayerAndExpectEvent = async <E extends Event, P>( | ||
fn: (player: Player) => Promise<P>, | ||
expectationConvertible: SingleEventExpectation | EventType, | ||
timeoutSeconds: number = 10 | ||
): Promise<E> => { | ||
return await PlayerWorld.shared.callPlayerAndExpectEvent( | ||
fn, | ||
expectationConvertible, | ||
timeoutSeconds | ||
); | ||
}; | ||
|
||
export const callPlayerAndExpectEvents = async ( | ||
fn: (player: Player) => void, | ||
expectationsConvertible: MultipleEventsExpectation | EventType[], | ||
timeoutSeconds: number = 10 | ||
): Promise<Event[]> => { | ||
return await PlayerWorld.shared.callPlayerAndExpectEvents( | ||
fn, | ||
expectationsConvertible, | ||
timeoutSeconds | ||
); | ||
}; | ||
|
||
export const loadSourceConfig = async ( | ||
sourceConfig: SourceConfig, | ||
timeoutSeconds: number = 10 | ||
): Promise<ReadyEvent> => { | ||
return await PlayerWorld.shared.loadSourceConfig( | ||
sourceConfig, | ||
timeoutSeconds | ||
); | ||
}; | ||
|
||
export const playFor = async ( | ||
time: number, | ||
timeoutSeconds: number = 10 | ||
): Promise<TimeChangedEvent> => { | ||
return await PlayerWorld.shared.playFor(time, timeoutSeconds); | ||
}; | ||
|
||
export const playUntil = async ( | ||
time: number, | ||
timeoutSeconds: number = 10 | ||
): Promise<TimeChangedEvent> => { | ||
return await PlayerWorld.shared.playUntil(time, timeoutSeconds); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this new key here, to enable setting the license key easily for tests.
This can be later used for CI as well.