forked from EXT/VR180-Web-Player
This commit is contained in:
@@ -20,6 +20,7 @@ function createVideo(overrides = {}) {
|
||||
currentTime: 20,
|
||||
duration: 120,
|
||||
ended: false,
|
||||
loop: false,
|
||||
loadCount: 0,
|
||||
muted: false,
|
||||
pauseCount: 0,
|
||||
@@ -107,6 +108,17 @@ test('MediaController toggles mute and native controls', () => {
|
||||
assert.equal(video.controls, true);
|
||||
});
|
||||
|
||||
test('MediaController toggles loop playback state', () => {
|
||||
const { controller, video } = createController();
|
||||
|
||||
assert.equal(controller.isLooping(), false);
|
||||
assert.equal(controller.toggleLoop(), true);
|
||||
assert.equal(video.loop, true);
|
||||
assert.equal(controller.isLooping(), true);
|
||||
assert.equal(controller.toggleLoop(), false);
|
||||
assert.equal(video.loop, false);
|
||||
});
|
||||
|
||||
test('MediaController resets video and play button to poster state', () => {
|
||||
const playButton = { classList: createClassList(), disabled: true };
|
||||
playButton.classList.add('hidden');
|
||||
@@ -122,7 +134,7 @@ test('MediaController resets video and play button to poster state', () => {
|
||||
assert.equal(playButton.disabled, false);
|
||||
});
|
||||
|
||||
test('MediaController restarts ended video before playing in 2D mode', async () => {
|
||||
test('MediaController restarts ended video before playing again', async () => {
|
||||
let resumed = false;
|
||||
const { controller, video } = createController({
|
||||
is2DModeActive: () => true,
|
||||
@@ -138,6 +150,15 @@ test('MediaController restarts ended video before playing in 2D mode', async ()
|
||||
assert.equal(video.currentTime, 0);
|
||||
assert.equal(video.playCount, 1);
|
||||
assert.equal(resumed, true);
|
||||
|
||||
const vrVideo = createVideo({ currentTime: 120, ended: true, paused: true });
|
||||
const { controller: vrController } = createController({ video: vrVideo });
|
||||
|
||||
vrController.togglePlayPause();
|
||||
await Promise.resolve();
|
||||
|
||||
assert.equal(vrVideo.currentTime, 0);
|
||||
assert.equal(vrVideo.playCount, 1);
|
||||
});
|
||||
|
||||
test('MediaController pauses when toggling playback while already playing', () => {
|
||||
@@ -151,44 +172,37 @@ test('MediaController pauses when toggling playback while already playing', () =
|
||||
assert.equal(video.paused, true);
|
||||
});
|
||||
|
||||
test('MediaController dispatches ended behavior for VR, 2D, and idle modes', async () => {
|
||||
test('MediaController dispatches ended behavior for VR, 2D, and idle modes', () => {
|
||||
const vrCalls = [];
|
||||
const { controller } = createController({
|
||||
video: createVideo({ paused: false })
|
||||
});
|
||||
|
||||
controller.handleEnded({
|
||||
cleanupFailedVrExit: () => vrCalls.push('cleanup'),
|
||||
exitVr: () => {
|
||||
vrCalls.push('exit');
|
||||
return Promise.resolve();
|
||||
},
|
||||
isIn2DMode: () => false,
|
||||
isInVr: () => true,
|
||||
on2DEnded: () => vrCalls.push('2d'),
|
||||
onVrEnded: () => vrCalls.push('vr'),
|
||||
resetToOriginalState: () => vrCalls.push('reset')
|
||||
});
|
||||
await Promise.resolve();
|
||||
assert.deepEqual(vrCalls, ['exit']);
|
||||
assert.deepEqual(vrCalls, ['vr']);
|
||||
|
||||
const twoDCalls = [];
|
||||
controller.handleEnded({
|
||||
cleanupFailedVrExit: () => twoDCalls.push('cleanup'),
|
||||
exitVr: () => Promise.resolve(),
|
||||
isIn2DMode: () => true,
|
||||
isInVr: () => false,
|
||||
on2DEnded: () => twoDCalls.push('2d'),
|
||||
onVrEnded: () => twoDCalls.push('vr'),
|
||||
resetToOriginalState: () => twoDCalls.push('reset')
|
||||
});
|
||||
assert.deepEqual(twoDCalls, ['2d']);
|
||||
|
||||
const idleCalls = [];
|
||||
controller.handleEnded({
|
||||
cleanupFailedVrExit: () => idleCalls.push('cleanup'),
|
||||
exitVr: () => Promise.resolve(),
|
||||
isIn2DMode: () => false,
|
||||
isInVr: () => false,
|
||||
on2DEnded: () => idleCalls.push('2d'),
|
||||
onVrEnded: () => idleCalls.push('vr'),
|
||||
resetToOriginalState: () => idleCalls.push('reset')
|
||||
});
|
||||
assert.deepEqual(idleCalls, ['reset']);
|
||||
|
||||
Reference in New Issue
Block a user