-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
and fix misc bugs and terminology
- Loading branch information
Showing
3 changed files
with
101 additions
and
21 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
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,79 @@ | ||
/* | ||
* 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 */ | ||
|
||
'use strict'; | ||
const webdriver = require('selenium-webdriver'); | ||
const seleniumHelpers = require('../../../../../test/webdriver'); | ||
const {expect} = require('chai'); | ||
|
||
let driver; | ||
const path = '/src/content/peerconnection/states/index.html'; | ||
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; | ||
|
||
describe('peerconnection states', () => { | ||
before(() => { | ||
driver = seleniumHelpers.buildDriver(); | ||
}); | ||
after(() => { | ||
return driver.quit(); | ||
}); | ||
|
||
beforeEach(() => { | ||
return driver.get(url); | ||
}); | ||
|
||
it('establishes a connection 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('video2').readyState === HTMLMediaElement.HAVE_ENOUGH_DATA; | ||
})); | ||
|
||
const pc1States = { | ||
signaling: await driver.findElement(webdriver.By.id('pc1SignalState')).getAttribute('innerText'), | ||
ice: await driver.findElement(webdriver.By.id('pc1IceState')).getAttribute('innerText'), | ||
connection: await driver.findElement(webdriver.By.id('pc1ConnState')).getAttribute('innerText'), | ||
}; | ||
expect(pc1States.signaling).to.equal('stable => have-local-offer => stable'); | ||
expect(pc1States.ice).to.equal('new => checking => connected'); | ||
expect(pc1States.connection).to.equal('=> connecting => connected'); | ||
|
||
const pc2States = { | ||
signaling: await driver.findElement(webdriver.By.id('pc2SignalState')).getAttribute('innerText'), | ||
ice: await driver.findElement(webdriver.By.id('pc2IceState')).getAttribute('innerText'), | ||
connection: await driver.findElement(webdriver.By.id('pc2ConnState')).getAttribute('innerText'), | ||
}; | ||
expect(pc2States.signaling).to.equal('stable => have-remote-offer => stable'); | ||
expect(pc2States.ice).to.equal('new => checking => connected'); | ||
expect(pc2States.connection).to.equal('=> connecting => connected'); | ||
|
||
await driver.findElement(webdriver.By.id('hangupButton')).click(); | ||
|
||
await driver.wait(() => driver.executeScript(() => { | ||
return pc1 === null; // eslint-disable-line no-undef | ||
})); | ||
}); | ||
}); | ||
|