2013-03-02 01:11:20 +03:00
|
|
|
module('Controls');
|
|
|
|
|
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,
|
2014-08-06 03:07:46 +03:00
|
|
|
language: noop,
|
|
|
|
languages: noop,
|
2013-03-05 21:38:47 +03:00
|
|
|
tech: {
|
2014-08-13 00:51:50 +03:00
|
|
|
'volumeControlFeature': 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
|
|
|
|
2013-03-05 21:38:47 +03:00
|
|
|
volumeControl = new vjs.VolumeControl(player);
|
|
|
|
muteToggle = new vjs.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,
|
2014-08-06 03:07:46 +03:00
|
|
|
language: noop,
|
|
|
|
languages: noop,
|
2013-03-05 21:38:47 +03:00
|
|
|
on: function(event, callback){
|
|
|
|
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;
|
|
|
|
},
|
|
|
|
tech: {
|
2014-08-13 00:51:50 +03:00
|
|
|
'volumeControlFeature': 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
|
|
|
|
2013-03-05 21:38:47 +03:00
|
|
|
volumeControl = new vjs.VolumeControl(player);
|
|
|
|
muteToggle = new vjs.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,
|
2013-03-25 01:51:09 +03:00
|
|
|
'volumeControl is hidden initially');
|
2013-04-02 23:17:30 +03:00
|
|
|
ok(muteToggle.el().className.indexOf('vjs-hidden') < 0,
|
2013-03-25 01:51:09 +03:00
|
|
|
'muteToggle is hidden initially');
|
2013-03-02 01:11:20 +03:00
|
|
|
|
2014-08-13 00:51:50 +03:00
|
|
|
player.tech['volumeControlFeature'] = 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
|
|
|
|
2013-04-02 23:17:30 +03:00
|
|
|
ok(volumeControl.el().className.indexOf('vjs-hidden') >= 0,
|
2013-03-25 01:51:09 +03:00
|
|
|
'volumeControl does not hide itself');
|
2013-04-02 23:17:30 +03:00
|
|
|
ok(muteToggle.el().className.indexOf('vjs-hidden') >= 0,
|
2013-03-25 01:51:09 +03:00
|
|
|
'muteToggle does not hide itself');
|
2013-03-02 01:11:20 +03:00
|
|
|
|
2014-08-13 00:51:50 +03:00
|
|
|
player.tech['volumeControlFeature'] = 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
|
|
|
|
2013-04-02 23:17:30 +03:00
|
|
|
ok(volumeControl.el().className.indexOf('vjs-hidden') < 0,
|
2013-03-25 01:51:09 +03:00
|
|
|
'volumeControl does not show itself');
|
2013-04-02 23:17:30 +03:00
|
|
|
ok(muteToggle.el().className.indexOf('vjs-hidden') < 0,
|
2013-03-25 01:51:09 +03:00
|
|
|
'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
|
|
|
};
|
|
|
|
slider = new vjs.Slider(player);
|
|
|
|
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);
|
|
|
|
|
|
|
|
var player = PlayerTest.makePlayer();
|
|
|
|
var playbackRate = new vjs.PlaybackRateMenuButton(player);
|
|
|
|
|
|
|
|
ok(playbackRate.el().className.indexOf('vjs-hidden') >= 0, 'playbackRate is not hidden');
|
|
|
|
});
|