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: {
|
2013-08-26 04:50:59 +03:00
|
|
|
'volumeControl': false
|
2013-03-02 01:11:20 +03:00
|
|
|
}
|
2013-04-13 02:51:04 +03:00
|
|
|
},
|
2013-05-03 03:07:05 +03:00
|
|
|
volume: function(){},
|
|
|
|
muted: 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: {
|
2013-08-26 04:50:59 +03:00
|
|
|
'volumeControl': true
|
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
|
|
|
|
2013-08-26 04:50:59 +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
|
|
|
|
2013-08-26 04:50:59 +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
|
|
|
});
|
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,
|
|
|
|
ready: noop
|
|
|
|
};
|
|
|
|
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');
|
|
|
|
});
|