From afec2dd4ad0d4ab40f7455b76c56d0ce2f468448 Mon Sep 17 00:00:00 2001 From: polesye Date: Mon, 23 Dec 2013 10:55:04 +0200 Subject: [PATCH] Add tests for Android. --- .../js/spec/video/video_control_spec.js | 64 ++++++++++--------- .../js/spec/video/video_player_spec.js | 39 ++++++----- .../spec/video/video_progress_slider_spec.js | 11 ++-- .../js/spec/video/video_speed_control_spec.js | 11 ++-- 4 files changed, 69 insertions(+), 56 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_control_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_control_spec.js index a213669bed..49f52d208d 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/video_control_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/video_control_spec.js @@ -210,6 +210,11 @@ isShown: true, isTouch: ['iPad'] }, + { + name: 'Android', + isShown: true, + isTouch: ['Android'] + }, { name: 'iPhone', isShown: false, @@ -237,38 +242,39 @@ }); }); - it('is shown on paused video on iPad in HTML5 player', function () { - window.onTouchBasedDevice.andReturn(['iPad']); - initialize(); - var btnPlay = state.el.find('.btn-play'); + $.each(['iPad', 'Android'], function(index, device) { + it('is shown on paused video on '+ device +' in HTML5 player', function () { + window.onTouchBasedDevice.andReturn([device]); + initialize(); + var btnPlay = state.el.find('.btn-play'); - videoControl.play(); - videoControl.pause(); + videoControl.play(); + videoControl.pause(); - expect(btnPlay).not.toHaveClass('is-hidden'); + expect(btnPlay).not.toHaveClass('is-hidden'); + }); + + it('is hidden on playing video on '+ device +' in HTML5 player', function () { + window.onTouchBasedDevice.andReturn([device]); + initialize(); + var btnPlay = state.el.find('.btn-play'); + + videoControl.play(); + + expect(btnPlay).toHaveClass('is-hidden'); + }); + + it('is hidden on paused video on '+ device +' in YouTube player', function () { + window.onTouchBasedDevice.andReturn([device]); + initializeYouTube(); + var btnPlay = state.el.find('.btn-play'); + + videoControl.play(); + videoControl.pause(); + + expect(btnPlay).toHaveClass('is-hidden'); + }); }); - - it('is hidden on playing video on iPad in HTML5 player', function () { - window.onTouchBasedDevice.andReturn(['iPad']); - initialize(); - var btnPlay = state.el.find('.btn-play'); - - videoControl.play(); - - expect(btnPlay).toHaveClass('is-hidden'); - }); - - it('is hidden on paused video on iPad in YouTube player', function () { - window.onTouchBasedDevice.andReturn(['iPad']); - initializeYouTube(); - var btnPlay = state.el.find('.btn-play'); - - videoControl.play(); - videoControl.pause(); - - expect(btnPlay).toHaveClass('is-hidden'); - }); - }); it('show', function () { diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js index bd4c1e0fbc..cadba4c995 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js @@ -157,14 +157,13 @@ // JS. describe('when on a touch based device', function () { - beforeEach(function () { - window.onTouchBasedDevice.andReturn(['iPad']); - initialize(); - }); - - it('create video volume control', function () { - expect(videoVolumeControl).toBeUndefined(); - expect(state.el.find('div.volume')).not.toExist(); + $.each(['iPad', 'Android'], function(index, device) { + it('create video volume control on' + device, function() { + window.onTouchBasedDevice.andReturn([device]); + initialize(); + expect(videoVolumeControl).toBeUndefined(); + expect(state.el.find('div.volume')).not.toExist(); + }); }); }); @@ -879,10 +878,12 @@ describe('on Touch devices', function () { it('`is-touch` class name is added to container', function () { - window.onTouchBasedDevice.andReturn(['iPad']); - initialize(); + $.each(['iPad', 'Android', 'iPhone'], function(index, device) { + window.onTouchBasedDevice.andReturn([device]); + initialize(); - expect(state.el).toHaveClass('is-touch'); + expect(state.el).toHaveClass('is-touch'); + }); }); it('modules are not initialized on iPhone', function () { @@ -899,11 +900,17 @@ }); }); - it('controls become visible after playing starts on iPad', function () { - window.onTouchBasedDevice.andReturn(['iPad']); - initialize(); + $.each(['iPad', 'Android'], function(index, device) { + var message = 'controls become visible after playing starts on ' + + device; + it(message, function() { + var controls; + window.onTouchBasedDevice.andReturn([device]); - var controls = state.el.find('.video-controls'); + runs(function () { + initialize(); + controls = state.el.find('.video-controls'); + }); waitsFor(function () { return state.el.hasClass('is-initialized'); @@ -921,7 +928,7 @@ runs(function () { expect(controls).not.toHaveClass('is-hidden'); }); - + }); }); }); }); diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_progress_slider_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_progress_slider_spec.js index e885cb42a6..10e46c79aa 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/video_progress_slider_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/video_progress_slider_spec.js @@ -54,11 +54,12 @@ // We can't expect $.fn.slider not to have been called, // because sliders are used in other parts of Video. }); - it('build the slider on iPad', function() { - window.onTouchBasedDevice.andReturn(['iPad']); - initialize(); - - expect(videoProgressSlider.slider).toBeDefined(); + $.each(['iPad', 'Android'], function(index, device) { + it('build the slider on ' + device, function() { + window.onTouchBasedDevice.andReturn([device]); + initialize(); + expect(videoProgressSlider.slider).toBeDefined(); + }); }); }); }); diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_speed_control_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_speed_control_spec.js index 0ca4cde994..f012dc21e3 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/video_speed_control_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/video_speed_control_spec.js @@ -57,13 +57,12 @@ }); describe('when running on touch based device', function() { - beforeEach(function() { - window.onTouchBasedDevice.andReturn(['iPad']); - initialize(); - }); - - it('is not rendered', function() { + $.each(['iPad', 'Android'], function(index, device) { + it('is not rendered on' + device, function() { + window.onTouchBasedDevice.andReturn([device]); + initialize(); expect(state.el.find('div.speeds')).not.toExist(); + }); }); });