Commit bb69a6a2 authored by Philipp Hancke's avatar Philipp Hancke Committed by Commit Bot

webrtc wpt: remove generateMediaStreamTrack usage

removes most usage of generateMediaStreamTrack in favor of
await-ing tracks from getUserMedia and stopping them)

BUG=836871

Change-Id: Id84f6cb6b3537faf2bb83332c5d7993550246581
Reviewed-on: https://chromium-review.googlesource.com/1117069Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Commit-Queue: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574855}
parent 90bd2dd7
......@@ -119,7 +119,9 @@
const offer = await caller.createOffer();
await caller.setLocalDescription(offer);
await callee.setRemoteDescription(offer);
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
callee.addTrack(track);
const answer = await callee.createAnswer();
await callee.setLocalDescription(answer);
......
......@@ -6,7 +6,7 @@ FAIL addTrack with single track argument and multiple streams should succeed pro
PASS Adding the same track multiple times should throw InvalidAccessError
FAIL addTrack with existing sender with null track, same kind, and recvonly direction should reuse sender promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
FAIL addTrack with existing sender that has not been used to send should reuse the sender promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
FAIL addTrack with existing sender that has been used to send should create new sender assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL addTrack with existing sender that has been used to send should create new sender promise_test: Unhandled rejection with value: object "TypeError: caller.addTransceiver is not a function"
FAIL addTrack with existing sender with null track, different kind, and recvonly direction should create new sender promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
Harness: the test ran to completion.
......@@ -11,7 +11,7 @@
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
// The following helper functions are called from RTCPeerConnection-helper.js:
// generateMediaStreamTrack
// getNoiseStream()
/*
5.1. RTCPeerConnection Interface Extensions
......@@ -171,7 +171,9 @@
assert_equals(transceiver.sender.track, null);
assert_equals(transceiver.direction, 'recvonly');
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const sender = pc.addTrack(track);
assert_equals(sender, transceiver.sender);
......@@ -188,7 +190,9 @@
assert_equals(transceiver.sender.track, null);
assert_equals(transceiver.direction, 'sendrecv');
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const sender = pc.addTrack(track);
assert_equals(sender.track, track);
......@@ -201,8 +205,10 @@
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
const transceiver =
caller.addTransceiver(generateMediaStreamTrack('audio'));
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = caller.addTransceiver(track);
{
const offer = await caller.createOffer();
await caller.setLocalDescription(offer);
......@@ -227,7 +233,7 @@
// |transceiver.sender| is currently not used for sending, but it should not
// be reused because it has been used for sending before.
const sender = caller.addTrack(generateMediaStreamTrack('audio'));
const sender = caller.addTrack(track);
assert_true(sender != null);
assert_not_equals(sender, transceiver.sender);
}, 'addTrack with existing sender that has been used to send should create new sender');
......@@ -240,7 +246,9 @@
assert_equals(transceiver.sender.track, null);
assert_equals(transceiver.direction, 'recvonly');
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const sender = pc.addTrack(track);
assert_equals(sender.track, track);
......
......@@ -3,7 +3,7 @@ PASS getStats() with no argument should succeed
PASS getStats(null) should succeed
PASS getStats() with track not added to connection should reject with InvalidAccessError
PASS getStats() with track added via addTrack should succeed
FAIL getStats() with track added via addTransceiver should succeed assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL getStats() with track added via addTransceiver should succeed promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
FAIL getStats() with track associated with more than one sender should reject with InvalidAccessError promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
FAIL getStats() with track associated with both sender and receiver should reject with InvalidAccessError pc.addTransceiver is not a function
PASS getStats() with no argument should return stats report containing peer-connection stats on an empty PC
......
......@@ -78,10 +78,13 @@
});
}, 'getStats() with track added via addTrack should succeed');
promise_test(t => {
promise_test(async t => {
const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
pc.addTransceiver(track);
return pc.getStats(track);
......
This is a testharness.js-based test.
FAIL addTransceiver - Calling removeTrack when connection is closed should throw InvalidStateError assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL addTransceiver - Calling removeTrack when connection is closed should throw InvalidStateError promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
PASS addTrack - Calling removeTrack when connection is closed should throw InvalidStateError
FAIL addTransceiver - Calling removeTrack on different connection that is closed should throw InvalidStateError assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL addTransceiver - Calling removeTrack on different connection that is closed should throw InvalidStateError promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
PASS addTrack - Calling removeTrack on different connection that is closed should throw InvalidStateError
FAIL addTransceiver - Calling removeTrack on different connection should throw InvalidAccessError assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL addTransceiver - Calling removeTrack on different connection should throw InvalidAccessError promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
PASS addTrack - Calling removeTrack on different connection should throw InvalidAccessError
FAIL addTransceiver - Calling removeTrack with valid sender should set sender.track to null assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL addTransceiver - Calling removeTrack with valid sender should set sender.track to null promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
PASS addTrack - Calling removeTrack with valid sender should set sender.track to null
FAIL Calling removeTrack with currentDirection sendrecv should set direction to recvonly assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL Calling removeTrack with currentDirection sendonly should set direction to inactive assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL Calling removeTrack with currentDirection recvonly should not change direction assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL Calling removeTrack with currentDirection inactive should not change direction assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL Calling removeTrack with currentDirection sendrecv should set direction to recvonly promise_test: Unhandled rejection with value: object "TypeError: caller.addTransceiver is not a function"
FAIL Calling removeTrack with currentDirection sendonly should set direction to inactive promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
FAIL Calling removeTrack with currentDirection recvonly should not change direction promise_test: Unhandled rejection with value: object "TypeError: caller.addTransceiver is not a function"
FAIL Calling removeTrack with currentDirection inactive should not change direction promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
Harness: the test ran to completion.
......@@ -12,7 +12,6 @@
// The following helper functions are called from RTCPeerConnection-helper.js:
// generateAnswer
// generateMediaStreamTrack
/*
5.1. RTCPeerConnection Interface Extensions
......@@ -35,15 +34,16 @@
5.1. removeTrack
3. If connection's [[isClosed]] slot is true, throw an InvalidStateError.
*/
test(t => {
promise_test(async t => {
const pc = new RTCPeerConnection();
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver(track);
const { sender } = transceiver;
pc.close();
assert_throws('InvalidStateError', () => pc.removeTrack(sender));
}, 'addTransceiver - Calling removeTrack when connection is closed should throw InvalidStateError');
promise_test(async t => {
......@@ -59,16 +59,17 @@
assert_throws('InvalidStateError', () => pc.removeTrack(sender));
}, 'addTrack - Calling removeTrack when connection is closed should throw InvalidStateError');
test(t => {
promise_test(async t => {
const pc = new RTCPeerConnection();
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver(track);
const { sender } = transceiver;
const pc2 = new RTCPeerConnection();
pc2.close();
assert_throws('InvalidStateError', () => pc2.removeTrack(sender));
}, 'addTransceiver - Calling removeTrack on different connection that is closed should throw InvalidStateError');
promise_test(async t => {
......@@ -89,15 +90,16 @@
5.1. removeTrack
4. If sender was not created by connection, throw an InvalidAccessError.
*/
test(t => {
promise_test(async t => {
const pc = new RTCPeerConnection();
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver(track);
const { sender } = transceiver;
const pc2 = new RTCPeerConnection();
assert_throws('InvalidAccessError', () => pc2.removeTrack(sender));
}, 'addTransceiver - Calling removeTrack on different connection should throw InvalidAccessError');
promise_test(async t => {
......@@ -117,9 +119,11 @@
5.1. removeTrack
7. Set sender.track to null.
*/
test(t => {
promise_test(async t => {
const pc = new RTCPeerConnection();
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver(track);
const { sender } = transceiver;
......@@ -130,7 +134,6 @@
pc.removeTrack(sender);
assert_equals(sender.track, null);
assert_equals(transceiver.direction, 'recvonly');
}, 'addTransceiver - Calling removeTrack with valid sender should set sender.track to null');
promise_test(async t => {
......@@ -159,7 +162,9 @@
t.add_cleanup(() => caller.close());
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = caller.addTransceiver(track);
const { sender } = transceiver;
......@@ -192,7 +197,9 @@
promise_test(async t => {
const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver(track, { direction: 'sendonly' });
const { sender } = transceiver;
......@@ -224,7 +231,9 @@
t.add_cleanup(() => caller.close());
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = caller.addTransceiver(track, { direction: 'recvonly' });
const { sender } = transceiver;
......@@ -256,7 +265,9 @@
promise_test(async t => {
const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('audio');
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver(track, { direction: 'inactive' });
const { sender } = transceiver;
......
......@@ -6,7 +6,7 @@ PASS addTrack with single track argument and multiple streams should succeed
PASS Adding the same track multiple times should throw InvalidAccessError
FAIL addTrack with existing sender with null track, same kind, and recvonly direction should reuse sender promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
FAIL addTrack with existing sender that has not been used to send should reuse the sender promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
FAIL addTrack with existing sender that has been used to send should create new sender assert_idl_attribute: Expect pc to have addTransceiver() method property "addTransceiver" not found in prototype chain
FAIL addTrack with existing sender that has been used to send should create new sender promise_test: Unhandled rejection with value: object "TypeError: caller.addTransceiver is not a function"
FAIL addTrack with existing sender with null track, different kind, and recvonly direction should create new sender promise_test: Unhandled rejection with value: object "TypeError: pc.addTransceiver is not a function"
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment