forked from webrtc/samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request webrtc#1543 from fippo/moar-e2e-tests
test: add e2e tests for change-codecs and negotiate-timing
- Loading branch information
Showing
3 changed files
with
140 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) 2022 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 */ | ||
|
||
'use strict'; | ||
const webdriver = require('selenium-webdriver'); | ||
const seleniumHelpers = require('../../../../../test/webdriver'); | ||
const {expect} = require('chai'); | ||
|
||
let driver; | ||
const path = '/src/content/peerconnection/change-codecs/index.html'; | ||
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; | ||
|
||
describe('peerconnection with setCodecPreferences', () => { | ||
before(() => { | ||
driver = seleniumHelpers.buildDriver(); | ||
}); | ||
after(() => { | ||
return driver.quit(); | ||
}); | ||
|
||
beforeEach(() => { | ||
return driver.get(url); | ||
}); | ||
|
||
['video/VP8'].forEach(codec => { | ||
it('establishes a connection', async () => { | ||
await driver.findElement(webdriver.By.id('startButton')).click(); | ||
|
||
await driver.wait(() => driver.executeScript(() => { | ||
return localStream !== null; // eslint-disable-line no-undef | ||
})); | ||
await driver.wait(() => driver.executeScript(() => { | ||
return codecPreferences.disabled === false; // eslint-disable-line no-undef | ||
})); | ||
await driver.findElement(webdriver.By.id('codecPreferences')).click(); | ||
await driver.findElement(webdriver.By.css('option[value=\'video/VP8\']')).click(); | ||
|
||
await driver.wait(() => driver.findElement(webdriver.By.id('callButton')).isEnabled()); | ||
await driver.findElement(webdriver.By.id('callButton')).click(); | ||
|
||
await Promise.all([ | ||
await driver.wait(() => driver.executeScript(() => { | ||
return pc1 && pc1.connectionState === 'connected'; // eslint-disable-line no-undef | ||
})), | ||
await driver.wait(() => driver.executeScript(() => { | ||
return pc2 && pc2.connectionState === 'connected'; // eslint-disable-line no-undef | ||
})), | ||
]); | ||
|
||
await driver.wait(() => driver.executeScript(() => { | ||
return document.getElementById('remoteVideo').readyState === HTMLMediaElement.HAVE_ENOUGH_DATA; | ||
})); | ||
|
||
await driver.wait(() => driver.executeScript(() => { | ||
return document.getElementById('actualCodec').innerText !== ''; | ||
})); | ||
const actualCodec = await driver.findElement(webdriver.By.id('actualCodec')).getAttribute('innerText'); | ||
expect(actualCodec.startsWith('Using ' + codec)).to.be.true; | ||
}); | ||
}); | ||
}); | ||
|
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2022 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 */ | ||
|
||
'use strict'; | ||
const webdriver = require('selenium-webdriver'); | ||
const seleniumHelpers = require('../../../../../test/webdriver'); | ||
const {expect} = require('chai'); | ||
|
||
let driver; | ||
const path = '/src/content/peerconnection/negotiate-timing/index.html'; | ||
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; | ||
|
||
describe('peerconnection with negotiation timing', () => { | ||
before(() => { | ||
driver = seleniumHelpers.buildDriver(); | ||
}); | ||
after(() => { | ||
return driver.quit(); | ||
}); | ||
|
||
beforeEach(() => { | ||
return driver.get(url); | ||
}); | ||
|
||
it('establishes a connection, renegotiates and hangs up', async () => { | ||
await driver.findElement(webdriver.By.id('startButton')).click(); | ||
|
||
await driver.wait(() => driver.executeScript(() => { | ||
return localStream !== null; // eslint-disable-line no-undef | ||
})); | ||
|
||
await driver.wait(() => driver.findElement(webdriver.By.id('callButton')).isEnabled()); | ||
await driver.findElement(webdriver.By.id('callButton')).click(); | ||
|
||
await Promise.all([ | ||
await driver.wait(() => driver.executeScript(() => { | ||
return pc1 && pc1.connectionState === 'connected'; // eslint-disable-line no-undef | ||
})), | ||
await driver.wait(() => driver.executeScript(() => { | ||
return pc2 && pc2.connectionState === 'connected'; // eslint-disable-line no-undef | ||
})), | ||
]); | ||
|
||
await driver.wait(() => driver.executeScript(() => { | ||
return document.getElementById('remoteVideo').readyState === HTMLMediaElement.HAVE_ENOUGH_DATA; | ||
})); | ||
|
||
await driver.wait(() => driver.findElement(webdriver.By.id('renegotiateButton')).isEnabled()); | ||
await driver.findElement(webdriver.By.id('renegotiateButton')).click(); | ||
|
||
await driver.wait(() => driver.executeScript(() => { | ||
return document.getElementById('log').innerText !== 'Log goes here'; | ||
})); | ||
const logText = await driver.findElement(webdriver.By.id('log')).getAttribute('innerText'); | ||
expect(logText.split('\n')).to.have.lengthOf(2); | ||
|
||
await driver.findElement(webdriver.By.id('hangupButton')).click(); | ||
|
||
await driver.wait(() => driver.executeScript(() => { | ||
return pc1 === null; // eslint-disable-line no-undef | ||
})); | ||
}); | ||
}); | ||
|