forked from webrtc/samples
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
can be run with node_modules/.bin/mocha 'src/content/**/js/test.js'
- Loading branch information
Showing
18 changed files
with
1,002 additions
and
822 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,55 @@ | ||
/* | ||
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. | ||
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. | ||
*/ | ||
export default { | ||
'It should transfer text over data channel': (browser) => { | ||
const path = '/src/content/datachannel/basic/index.html'; | ||
const url = 'file://' + process.cwd() + path; | ||
|
||
browser | ||
.url(url) | ||
.click('#startButton') | ||
.expect.element('#sendButton').to.be.enabled.before(50); | ||
browser.expect.element('#dataChannelSend').to.be.enabled.before(50); | ||
|
||
browser.setValue('#dataChannelSend', 'HELLO, WORLD!'); | ||
browser | ||
.click('#sendButton') | ||
.pause(50) | ||
.assert.value('#dataChannelReceive', 'HELLO, WORLD!'); | ||
|
||
browser | ||
.click('#closeButton') | ||
.expect.element('#sendButton').to.not.be.enabled.before(50); | ||
|
||
browser.end(); | ||
} | ||
}; | ||
/* eslint-env node, mocha */ | ||
|
||
'use strict'; | ||
const webdriver = require('selenium-webdriver'); | ||
const seleniumHelpers = require('../../../../../test/webdriver'); | ||
const {expect} = require('chai'); | ||
|
||
let driver; | ||
const path = '/src/content/datachannel/basic/index.html'; | ||
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; | ||
|
||
describe('datachannel basic', () => { | ||
before(() => { | ||
driver = seleniumHelpers.buildDriver(); | ||
}); | ||
after(() => { | ||
return driver.quit(); | ||
}); | ||
|
||
beforeEach(() => { | ||
return driver.get(url); | ||
}); | ||
|
||
it('transfers text', async () => { | ||
const text = 'Hello world'; | ||
await driver.findElement(webdriver.By.id('startButton')).click(); | ||
|
||
await Promise.all([ | ||
driver.wait(() => driver.executeScript(() => { | ||
return localConnection && localConnection.connectionState === 'connected'; // eslint-disable-line no-undef | ||
})), | ||
await driver.wait(() => driver.executeScript(() => { | ||
return remoteConnection && remoteConnection.connectionState === 'connected'; // eslint-disable-line no-undef | ||
})), | ||
]); | ||
await driver.wait(() => driver.findElement(webdriver.By.id('sendButton')).isEnabled()); | ||
|
||
await driver.findElement(webdriver.By.id('dataChannelSend')) | ||
.sendKeys(text); | ||
await driver.findElement(webdriver.By.id('sendButton')).click(); | ||
await driver.wait(() => driver.executeScript(() => { | ||
return document.getElementById('dataChannelReceive').value.length > 0; | ||
})); | ||
|
||
const value = await driver.findElement(webdriver.By.id('dataChannelReceive')).getAttribute('value'); | ||
expect(value).to.equal(text); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,57 @@ | ||
/* | ||
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. | ||
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. | ||
*/ | ||
export default { | ||
'It should transfer data over data channel': (browser) => { | ||
const path = '/src/content/datachannel/datatransfer/index.html'; | ||
const url = 'file://' + process.cwd() + path; | ||
|
||
browser | ||
.url(url) | ||
.click('#sendTheData') | ||
.pause(1000) | ||
.assert.value('#receiveProgress', '16777200') | ||
.end(); | ||
} | ||
}; | ||
/* eslint-env node, mocha */ | ||
|
||
'use strict'; | ||
const webdriver = require('selenium-webdriver'); | ||
const seleniumHelpers = require('../../../../../test/webdriver'); | ||
const {expect} = require('chai'); | ||
|
||
let driver; | ||
const path = '/src/content/datachannel/datatransfer/index.html'; | ||
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; | ||
|
||
describe('datachannel datatransfer', () => { | ||
before(() => { | ||
driver = seleniumHelpers.buildDriver(); | ||
}); | ||
after(() => { | ||
return driver.quit(); | ||
}); | ||
|
||
beforeEach(() => { | ||
return driver.get(url); | ||
}); | ||
|
||
it('transfers data', async () => { | ||
const megsToSend = 4; | ||
await driver.findElement(webdriver.By.id('megsToSend')) | ||
.clear(); | ||
await driver.findElement(webdriver.By.id('megsToSend')) | ||
.sendKeys(megsToSend + '\n'); | ||
|
||
await driver.findElement(webdriver.By.id('sendTheData')).click(); | ||
|
||
await Promise.all([ | ||
driver.wait(() => driver.executeScript(() => { | ||
return localConnection && localConnection.connectionState === 'connected'; // eslint-disable-line no-undef | ||
})), | ||
await driver.wait(() => driver.executeScript(() => { | ||
return remoteConnection && remoteConnection.connectionState === 'connected'; // eslint-disable-line no-undef | ||
})), | ||
]); | ||
|
||
// the remote connection gets closed when it is done. | ||
await driver.wait(() => driver.executeScript(() => { | ||
return remoteConnection === null; // eslint-disable-line no-undef | ||
})); | ||
|
||
const transferred = await driver.findElement(webdriver.By.id('receiveProgress')).getAttribute('value'); | ||
expect(transferred >>> 0).to.equal(megsToSend * 1024 * 1024); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
/* | ||
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. | ||
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. | ||
*/ | ||
/* eslint-env node, mocha */ | ||
|
||
export default { | ||
'It should transfer a file over a datachannel': (browser) => { | ||
const path = '/src/content/datachannel/filetransfer/index.html'; | ||
const url = 'file://' + process.cwd() + path; | ||
'use strict'; | ||
const webdriver = require('selenium-webdriver'); | ||
const seleniumHelpers = require('../../../../../test/webdriver'); | ||
|
||
let driver; | ||
const path = '/src/content/datachannel/filetransfer/index.html'; | ||
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; | ||
|
||
describe('datachannel basic', () => { | ||
before(() => { | ||
driver = seleniumHelpers.buildDriver(); | ||
}); | ||
after(() => { | ||
return driver.quit(); | ||
}); | ||
|
||
beforeEach(() => { | ||
return driver.get(url); | ||
}); | ||
|
||
it('transfers a file', async () => { | ||
await driver.findElement(webdriver.By.id('fileInput')) | ||
.sendKeys(process.cwd() + '/src/content/devices/multi/images/poster.jpg'); | ||
await driver.wait(() => driver.findElement(webdriver.By.id('sendFile')).isEnabled()); | ||
await driver.findElement(webdriver.By.id('sendFile')).click(); | ||
|
||
// the remote connection gets closed when it is done. | ||
await driver.wait(() => driver.executeScript(() => { | ||
return remoteConnection === null; // eslint-disable-line no-undef | ||
})); | ||
await driver.wait(() => driver.findElement(webdriver.By.id('download')).isEnabled()); | ||
}); | ||
}); | ||
|
||
browser | ||
.url(url) | ||
.waitForElementNotVisible('#download', 100, 'File download link is not visible') | ||
.waitForElementVisible('#fileInput', 1000) | ||
.setValue('#fileInput', process.cwd() + '/src/content/devices/multi/images/poster.jpg') | ||
.waitForElementVisible('#download', 10000, 'File download link is visible') | ||
.end(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.