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,
|
|
|
|
tech: {
|
|
|
|
features: {
|
|
|
|
volumeControl: false
|
2013-03-02 01:11:20 +03:00
|
|
|
}
|
2013-04-13 02:51:04 +03:00
|
|
|
},
|
|
|
|
volume: 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,
|
|
|
|
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: {
|
|
|
|
features: {
|
|
|
|
volumeControl: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
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
|
|
|
|
|
|
|
player.tech.features.volumeControl = 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
|
|
|
|
|
|
|
player.tech.features.volumeControl = 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
|
|
|
});
|