2013-03-02 01:11:20 +03:00
|
|
|
module('Controls');
|
|
|
|
|
|
|
|
test('should hide volume control if it\'s not supported', function() {
|
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-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
|
|
|
|
|
|
|
equal(volumeControl.el().style.display, 'none', 'volumeControl is not hidden');
|
|
|
|
equal(muteToggle.el().style.display, 'none', 'muteToggle is not hidden');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should test and toggle volume control on `loadstart`', function(){
|
2013-03-05 21:38:47 +03:00
|
|
|
var noop, listeners, player, volumeControl, muteToggle;
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
volumeControl = new vjs.VolumeControl(player);
|
|
|
|
muteToggle = new vjs.MuteToggle(player);
|
2013-03-02 01:11:20 +03:00
|
|
|
|
|
|
|
equal(volumeControl.el().style.display,
|
|
|
|
'',
|
|
|
|
'volumeControl is hidden initially');
|
|
|
|
equal(muteToggle.el().style.display,
|
|
|
|
'',
|
|
|
|
'muteToggle is hidden initially');
|
|
|
|
|
|
|
|
player.tech.features.volumeControl = false;
|
|
|
|
listeners.forEach(function(listener) {
|
|
|
|
listener();
|
|
|
|
});
|
|
|
|
|
|
|
|
equal(volumeControl.el().style.display,
|
|
|
|
'none',
|
|
|
|
'volumeControl does not hide itself');
|
|
|
|
equal(muteToggle.el().style.display,
|
|
|
|
'none',
|
|
|
|
'muteToggle does not hide itself');
|
|
|
|
|
|
|
|
player.tech.features.volumeControl = true;
|
|
|
|
listeners.forEach(function(listener) {
|
|
|
|
listener();
|
|
|
|
});
|
|
|
|
|
|
|
|
equal(volumeControl.el().style.display,
|
|
|
|
'block',
|
|
|
|
'volumeControl does not show itself');
|
|
|
|
equal(muteToggle.el().style.display,
|
|
|
|
'block',
|
|
|
|
'muteToggle does not show itself');
|
|
|
|
});
|