Add tests for Android.

This commit is contained in:
polesye
2013-12-23 10:55:04 +02:00
parent b6808d3d13
commit afec2dd4ad
4 changed files with 69 additions and 56 deletions

View File

@@ -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 () {

View File

@@ -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');
});
});
});
});
});

View File

@@ -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();
});
});
});
});

View File

@@ -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();
});
});
});