2015-04-14 22:08:32 +02:00
|
|
|
import VolumeControl from '../../src/js/control-bar/volume-control/volume-control.js';
|
2015-03-26 06:43:41 +02:00
|
|
|
import MuteToggle from '../../src/js/control-bar/mute-toggle.js';
|
2015-04-14 22:08:32 +02:00
|
|
|
import PlaybackRateMenuButton from '../../src/js/control-bar/playback-rate-menu/playback-rate-menu-button.js';
|
|
|
|
import Slider from '../../src/js/slider/slider.js';
|
2015-03-26 06:43:41 +02:00
|
|
|
import TestHelpers from './test-helpers.js';
|
|
|
|
import document from 'global/document';
|
|
|
|
|
|
|
|
q.module('Controls');
|
2013-03-02 01:11:20 +03:00
|
|
|
|
2013-03-25 01:51:09 +03:00
|
|
|
test('should hide volume control if it\'s not supported', function(){
|
2013-04-13 02:51:04 +03:00
|
|
|
expect(2);
|
|
|
|
|
2013-03-05 21:38:47 +03:00
|
|
|
var noop, player, volumeControl, muteToggle;
|
|
|
|
noop = function(){};
|
|
|
|
player = {
|
|
|
|
id: noop,
|
|
|
|
on: noop,
|
|
|
|
ready: noop,
|
2015-09-15 02:45:14 +02:00
|
|
|
tech_: {
|
2014-09-03 02:22:43 +03:00
|
|
|
'featuresVolumeControl': false
|
2013-04-13 02:51:04 +03:00
|
|
|
},
|
2013-05-03 03:07:05 +03:00
|
|
|
volume: function(){},
|
2014-02-07 03:54:35 +03:00
|
|
|
muted: function(){},
|
|
|
|
reportUserActivity: function(){}
|
2013-03-05 21:38:47 +03:00
|
|
|
};
|
2013-04-09 23:18:55 +03:00
|
|
|
|
2015-03-26 06:43:41 +02:00
|
|
|
volumeControl = new VolumeControl(player);
|
|
|
|
muteToggle = new MuteToggle(player);
|
2013-03-02 01:11:20 +03:00
|
|
|
|
2013-04-02 23:17:30 +03:00
|
|
|
ok(volumeControl.el().className.indexOf('vjs-hidden') >= 0, 'volumeControl is not hidden');
|
|
|
|
ok(muteToggle.el().className.indexOf('vjs-hidden') >= 0, 'muteToggle is not hidden');
|
2013-03-02 01:11:20 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
test('should test and toggle volume control on `loadstart`', function(){
|
2013-04-13 02:51:04 +03:00
|
|
|
var noop, listeners, player, volumeControl, muteToggle, i;
|
2013-03-05 21:38:47 +03:00
|
|
|
noop = function(){};
|
|
|
|
listeners = [];
|
|
|
|
player = {
|
|
|
|
id: noop,
|
|
|
|
on: function(event, callback){
|
2014-10-28 20:16:56 +02:00
|
|
|
// don't fire dispose listeners
|
|
|
|
if (event !== 'dispose') {
|
|
|
|
listeners.push(callback);
|
|
|
|
}
|
2013-03-02 01:11:20 +03:00
|
|
|
},
|
2013-03-05 21:38:47 +03:00
|
|
|
ready: noop,
|
|
|
|
volume: function(){
|
|
|
|
return 1;
|
|
|
|
},
|
|
|
|
muted: function(){
|
|
|
|
return false;
|
|
|
|
},
|
2015-09-15 02:45:14 +02:00
|
|
|
tech_: {
|
2014-09-03 02:22:43 +03:00
|
|
|
'featuresVolumeControl': true
|
2014-02-07 03:54:35 +03:00
|
|
|
},
|
|
|
|
reportUserActivity: function(){}
|
2013-03-05 21:38:47 +03:00
|
|
|
};
|
2013-04-09 23:18:55 +03:00
|
|
|
|
2015-03-26 06:43:41 +02:00
|
|
|
volumeControl = new VolumeControl(player);
|
|
|
|
muteToggle = new MuteToggle(player);
|
2013-03-02 01:11:20 +03:00
|
|
|
|
2014-10-28 20:16:56 +02:00
|
|
|
equal(volumeControl.hasClass('vjs-hidden'), false, 'volumeControl is hidden initially');
|
|
|
|
equal(muteToggle.hasClass('vjs-hidden'), false, 'muteToggle is hidden initially');
|
2013-03-02 01:11:20 +03:00
|
|
|
|
2015-09-15 02:45:14 +02:00
|
|
|
player.tech_['featuresVolumeControl'] = false;
|
2013-04-13 02:51:04 +03:00
|
|
|
for (i = 0; i < listeners.length; i++) {
|
|
|
|
listeners[i]();
|
|
|
|
}
|
2013-03-02 01:11:20 +03:00
|
|
|
|
2014-10-28 20:16:56 +02:00
|
|
|
equal(volumeControl.hasClass('vjs-hidden'), true, 'volumeControl does not hide itself');
|
|
|
|
equal(muteToggle.hasClass('vjs-hidden'), true, 'muteToggle does not hide itself');
|
2013-03-02 01:11:20 +03:00
|
|
|
|
2015-09-15 02:45:14 +02:00
|
|
|
player.tech_['featuresVolumeControl'] = true;
|
2013-04-13 02:51:04 +03:00
|
|
|
for (i = 0; i < listeners.length; i++) {
|
|
|
|
listeners[i]();
|
|
|
|
}
|
2013-03-02 01:11:20 +03:00
|
|
|
|
2014-10-28 20:16:56 +02:00
|
|
|
equal(volumeControl.hasClass('vjs-hidden'), false, 'volumeControl does not show itself');
|
|
|
|
equal(muteToggle.hasClass('vjs-hidden'), false, 'muteToggle does not show itself');
|
2013-03-02 01:11:20 +03:00
|
|
|
});
|
2013-04-22 20:57:42 +03:00
|
|
|
|
|
|
|
test('calculateDistance should use changedTouches, if available', function() {
|
|
|
|
var noop, player, slider, event;
|
|
|
|
noop = function(){};
|
|
|
|
player = {
|
|
|
|
id: noop,
|
|
|
|
on: noop,
|
2014-02-07 03:54:35 +03:00
|
|
|
ready: noop,
|
|
|
|
reportUserActivity: noop
|
2013-04-22 20:57:42 +03:00
|
|
|
};
|
2015-03-26 06:43:41 +02:00
|
|
|
slider = new Slider(player);
|
2013-04-22 20:57:42 +03:00
|
|
|
document.body.appendChild(slider.el_);
|
|
|
|
slider.el_.style.position = 'absolute';
|
|
|
|
slider.el_.style.width = '200px';
|
|
|
|
slider.el_.style.left = '0px';
|
|
|
|
|
|
|
|
event = {
|
|
|
|
pageX: 10,
|
|
|
|
changedTouches: [{
|
|
|
|
pageX: 100
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
|
|
|
equal(slider.calculateDistance(event), 0.5, 'we should have touched exactly in the center, so, the ratio should be half');
|
|
|
|
});
|
2014-05-14 00:02:02 +03:00
|
|
|
|
|
|
|
test('should hide playback rate control if it\'s not supported', function(){
|
|
|
|
expect(1);
|
|
|
|
|
2015-03-26 06:43:41 +02:00
|
|
|
var player = TestHelpers.makePlayer();
|
|
|
|
var playbackRate = new PlaybackRateMenuButton(player);
|
2014-05-14 00:02:02 +03:00
|
|
|
|
|
|
|
ok(playbackRate.el().className.indexOf('vjs-hidden') >= 0, 'playbackRate is not hidden');
|
|
|
|
});
|