Skip to content

Commit

Permalink
Merge pull request #665 from samdutton/gh-pages
Browse files Browse the repository at this point in the history
Removed redundant src/.jshintrc; added no-unused-vars rule to allow unused args
  • Loading branch information
KaptenJansson committed Oct 21, 2015
2 parents 96dcd09 + d1cb0a2 commit 5aa59cd
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 142 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"no-shadow": 2,
"no-trailing-spaces": 2,
"no-unused-expressions": 2,
"no-unused-vars": [2, {"args": "none"}],
"object-curly-spacing": [2, "never"],
"padded-blocks": [2, "never"],
"quotes": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"grunt-githooks": "^0.3.1",
"grunt-htmlhint": ">=0.4.1",
"pem": "^1.8.1",
"selenium-webdriver": "^2.46.0",
"selenium-webdriver": "^2.48.0",
"tape": "^4.0.0",
"travis-multirunner": "^2.6.0",
"webrtc-adapter-test": "^0.2.1"
Expand Down
44 changes: 0 additions & 44 deletions src/.jshintrc

This file was deleted.

196 changes: 99 additions & 97 deletions src/content/devices/input-output/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

'use strict';

// This is a basic test file for use with testling.
// The test script language comes from tape.
var test = require('tape');
Expand All @@ -15,118 +16,119 @@ var webdriver = require('selenium-webdriver');
var seleniumHelpers = require('../../../../../test/selenium-lib');

test('Fake device selection and check video element dimensions ' +
'in input-output demo', function(t) {
'in input-output demo',
function(t) {
// FIXME: use env[SELENIUM_BROWSER] instead?
var driver = seleniumHelpers.buildDriver();

var browser = process.env.BROWSER;

driver.get('file://' + process.cwd() +
'/src/content/devices/input-output/index.html')
.then(function() {
t.pass('Page loaded');
// Making sure we can select the 1st audio device.
// TODO: Select more devices if Firefox adds a 2nd fake A&V device and
// Chrome adds another fake video device.
t.pass('Selecting 1st audio device');
return driver.wait(webdriver.until.elementLocated(
.then(function() {
t.pass('Page loaded');
// Making sure we can select the 1st audio device.
// TODO: Select more devices if Firefox adds a 2nd fake A&V device and
// Chrome adds another fake video device.
t.pass('Selecting 1st audio device');
return driver.wait(webdriver.until.elementLocated(
webdriver.By.css('#audioSource>option')));
})
.then(function(element) {
return new webdriver.ActionSequence(driver).
doubleClick(element).perform();
})
// Check enumerateDevices has returned an id.
.then(function() {
return driver.findElement(webdriver.By.css(
})
.then(function(element) {
return new webdriver.ActionSequence(driver).
doubleClick(element).perform();
})
// Check enumerateDevices has returned an id.
.then(function() {
return driver.findElement(webdriver.By.css(
'#audioSource>option')).getAttribute('value');
})
.then(function(deviceId) {
t.ok(deviceId, 'Device/source id: ' + deviceId);
})
.then(function() {
// Making sure we can select the 1st video device.
// TODO: Select more devices if Firefox adds a 2nd fake A/V device and
// Chrome adds another fake video device.
t.pass('Selecting 1st video device');
return driver.wait(webdriver.until.elementLocated(
})
.then(function(deviceId) {
t.ok(deviceId, 'Device/source id: ' + deviceId);
})
.then(function() {
// Making sure we can select the 1st video device.
// TODO: Select more devices if Firefox adds a 2nd fake A/V device and
// Chrome adds another fake video device.
t.pass('Selecting 1st video device');
return driver.wait(webdriver.until.elementLocated(
webdriver.By.css('#videoSource>option')));
})
.then(function(element) {
return new webdriver.ActionSequence(driver).
doubleClick(element).perform();
})
// Check enumerateDevices has returned an id.
.then(function() {
return driver.findElement(webdriver.By.css(
})
.then(function(element) {
return new webdriver.ActionSequence(driver).
doubleClick(element).perform();
})
// Check enumerateDevices has returned an id.
.then(function() {
return driver.findElement(webdriver.By.css(
'#videoSource>option')).getAttribute('value');
})
.then(function(deviceId) {
t.ok(deviceId !== '', 'Device/source id: ' + deviceId);
})
.then(function() {
// Make sure the stream is ready.
return driver.wait(function() {
return driver.executeScript('return window.stream !== undefined;');
}, 30 * 1000);
})
// Check for a fake audio device label (Chrome only).
.then(function() {
return driver.executeScript('return stream.getAudioTracks()[0].label');
})
.then(function(deviceLabel) {
// TODO: Improve this once Firefox has added labels for fake devices.
var fakeAudioDeviceName = (browser === 'chrome') ?
})
.then(function(deviceId) {
t.ok(deviceId !== '', 'Device/source id: ' + deviceId);
})
.then(function() {
// Make sure the stream is ready.
return driver.wait(function() {
return driver.executeScript('return window.stream !== undefined;');
}, 30 * 1000);
})
// Check for a fake audio device label (Chrome only).
.then(function() {
return driver.executeScript('return stream.getAudioTracks()[0].label');
})
.then(function(deviceLabel) {
// TODO: Improve this once Firefox has added labels for fake devices.
var fakeAudioDeviceName = (browser === 'chrome') ?
'Fake Audio 1' : '';
t.ok(fakeAudioDeviceName === deviceLabel,
'Fake audio device found with label: ' + deviceLabel);
})
// Check for a fake video device label (Chrome only).
.then(function() {
return driver.executeScript('return stream.getVideoTracks()[0].label');
})
.then(function(deviceLabel) {
// TODO: Improve this once Firefox has added labels for fake devices.
var fakeVideoDeviceName = (browser === 'chrome') ?
t.ok(fakeAudioDeviceName === deviceLabel,
'Fake audio device found with label: ' + deviceLabel);
})
// Check for a fake video device label (Chrome only).
.then(function() {
return driver.executeScript('return stream.getVideoTracks()[0].label');
})
.then(function(deviceLabel) {
// TODO: Improve this once Firefox has added labels for fake devices.
var fakeVideoDeviceName = (browser === 'chrome') ?
'fake_device_0' : '';
// TODO: Remove match() method once http://crbug.com/526633 is fixed.
t.ok(fakeVideoDeviceName === deviceLabel.match(fakeVideoDeviceName)[0],
// TODO: Remove match() method once http://crbug.com/526633 is fixed.
t.ok(fakeVideoDeviceName === deviceLabel.match(fakeVideoDeviceName)[0],
'Fake video device found with label: ' +
deviceLabel.match(fakeVideoDeviceName)[0]);
})
// Check that there is a video element and it is displaying something.
.then(function() {
return driver.findElement(webdriver.By.id('video'));
})
.then(function(videoElement) {
t.pass('Found video element');
var width = 0;
var height = 0;
return new webdriver.promise.Promise(function(resolve) {
videoElement.getAttribute('videoWidth').then(function(w) {
width = w;
t.pass('Got videoWidth ' + w);
if (width && height) {
resolve([width, height]);
}
});
videoElement.getAttribute('videoHeight').then(function(h) {
height = h;
t.pass('Got videoHeight ' + h);
if (width && height) {
resolve([width, height]);
}
})
// Check that there is a video element and it is displaying something.
.then(function() {
return driver.findElement(webdriver.By.id('video'));
})
.then(function(videoElement) {
t.pass('Found video element');
var width = 0;
var height = 0;
return new webdriver.promise.Promise(function(resolve) {
videoElement.getAttribute('videoWidth').then(function(w) {
width = w;
t.pass('Got videoWidth ' + w);
if (width && height) {
resolve([width, height]);
}
});
videoElement.getAttribute('videoHeight').then(function(h) {
height = h;
t.pass('Got videoHeight ' + h);
if (width && height) {
resolve([width, height]);
}
});
});
})
.then(function(dimensions) {
t.pass('Got video dimensions ' + dimensions.join('x'));
})
.then(function() {
t.end();
})
.then(null, function(err) {
t.fail(err);
t.end();
});
})
.then(function(dimensions) {
t.pass('Got video dimensions ' + dimensions.join('x'));
})
.then(function() {
t.end();
})
.then(null, function(err) {
t.fail(err);
t.end();
});
});

0 comments on commit 5aa59cd

Please sign in to comment.