Skip to content

Files

This branch is 764 commits behind webrtcHacks/adapter:main.

test

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jul 20, 2017
Jul 20, 2017
May 15, 2017
May 17, 2017
Jun 27, 2017
Jul 19, 2017
Apr 26, 2016
Jun 28, 2017
Jul 18, 2017
Jan 22, 2016

Build Status

Intro

Selenium WebDriver, Node, Testling and travis-multirunner are used as the testing framework. Selenium WebDriver drives the browser; Node and Testling manage the tests, while travis-multirunner downloads and installs the browsers to be tested on, i.e. creates the testing matrix.

Functional unit tests located in test/unit are run in node using Mocha, Chai and Sinon.

Development

Detailed information on developing in the webrtc GitHub repo can be mark in the WebRTC GitHub repo developer's guide.

This guide assumes you are running a Debian based Linux distribution (travis-multirunner currently fetches .deb browser packages).

Clone the repo in desired folder

git clone https://github.com/webrtc/adapter.git

Install npm dependencies

npm install

Build

In order to get a usable file, you need to build it.

grunt build

This will result in 4 files in the out/ folder:

  • adapter.js - includes all the shims and is visible in the browser under the global adapter object (window.adapter).
  • adapter_no_edge.js - same as above but does not include the Microsoft Edge (ORTC) shim.
  • adapter_no_edge_no_global.js same as above but is not exposed/visible in the browser (you cannot call/interact with the shims in the browser).
  • adapter.js_no_global.js - same as adapter.js but is not exposed/visible in the browser (you cannot call/interact with the shims in the browser).

Run tests

Runs grunt and tests in test/tests.js. Change the browser to your choice, more details here

BROWSER=chrome BVER=stable npm test

Add tests

test/tests.js is used as an index for the tests, tests should be added here using require(). The tests themselves should be placed in the same js folder as main.js: e.g.src/content/getusermedia/gum/js/test.js.

The tests should be written using Testling for test validation (using Tape script language) and Selenium WebDriver is used to control and drive the test in the browser.

Use the existing tests as guide on how to write tests and also look at the Testling guide and Selenium WebDriver (make sure to select javascript as language preference.) for more information.

Global Selenium WebDriver settings can be found in test/selenium-lib.js, if your test require some specific settings not covered in selenium-lib.js, add your own to the test and do not import the selenium-lib.js file into the test, only do this if it's REALLY necessary.

Once your test is ready, create a pull request and see how it runs on travis-multirunner.

Change browser and channel/version for testing

Chrome stable is currently installed as the default browser for the tests.

Currently Chrome and Firefox are supported*, check travis-multirunner repo for updates around this. Firefox channels supported are stable, beta and nightly. Chrome channels supported on Linux are stable, beta and unstable.

To select a different browser and/or channel version, change environment variables BROWSER and BVER, then you can rerun the tests with the new browser.

export BROWSER=firefox BVER=nightly

Alternatively you can also do it without changing environment variables.

BROWSER=firefox BVER=nightly npm test

###* Experimental browser support You can run the tests in any currently installed browser locally that is supported by Selenium WebDriver but you have to bypass travis-multirunner. Also it only makes sense to use a WebRTC supported browser.

  • Remove the .setBinary() and .setChromeBinaryPath() methods in test/selenium-lib.js (these currently point to travis-multirunner scripts that only run on Debian based Linux distributions) or change them to point to a location of your choice.
  • Then add the Selenium driver of the browser you want to use to test/selenium-lib.js, check Selenium WebDriver supported browsers page for more details.
  • Then just do the following (replace "opera" with your browser of choice) in order to run all tests
BROWSER=opera npm test