Commit fbdd17fb authored by Henrik Boström's avatar Henrik Boström Committed by Commit Bot

Improve RTCPeerConnection-setRemoteDescription-tracks.https.html tests.

Using async functions and promise_tests instead of then()-chains and
async_tests. This makes them more readable, easier to maintain and
shorter.

Replaced RTCPeerConnection-helper.js function performOffer() with
exchangeOffer()/exchangeAnswer()/exchangeOfferAnswer().

Updated tests that were performing multiple offers to perform a full
offer/answer exchange whenever there were future offers to be made.
Previously it would perform half of an offer/answer cycle before
starting the next offer/answer, which under Unified Plan could lead to
some unexpected failures.

TBR=guidou@chromium.org

Bug: 777617
Change-Id: Ib0305d55af5aef7f49b5418d4ba44ded9c84d5c6
Reviewed-on: https://chromium-review.googlesource.com/1082434Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Commit-Queue: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565234}
parent 2eec314f
...@@ -388,16 +388,19 @@ function getUserMediaTracksAndStreams(count, type = 'audio') { ...@@ -388,16 +388,19 @@ function getUserMediaTracksAndStreams(count, type = 'audio') {
}); });
} }
// Creates an offer for the caller, set it as the caller's local description and async function exchangeOffer(caller, callee) {
// then sets the callee's remote description to the offer. Returns the Promise const offer = await caller.createOffer();
// of the setRemoteDescription call. await caller.setLocalDescription(offer);
function performOffer(caller, callee) { return callee.setRemoteDescription(offer);
let sessionDescription; }
return caller.createOffer() async function exchangeAnswer(caller, callee) {
.then(offer => { const answer = await callee.createAnswer();
sessionDescription = offer; await callee.setLocalDescription(answer);
return caller.setLocalDescription(offer); return caller.setRemoteDescription(answer);
}).then(() => callee.setRemoteDescription(sessionDescription)); }
async function exchangeOfferAnswer(caller, callee) {
await exchangeOffer(caller, callee);
return exchangeAnswer(caller, callee);
} }
...@@ -415,3 +418,13 @@ class Resolver { ...@@ -415,3 +418,13 @@ class Resolver {
this.reject = promiseReject; this.reject = promiseReject;
} }
} }
function addEventListenerPromise(t, target, type, listener) {
return new Promise((resolve, reject) => {
target.addEventListener(type, t.step_func(e => {
if (listener != undefined)
e = listener(e);
resolve(e);
}));
});
}
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL addTrack() with a track and no stream makes ontrack fire with a track and no stream. assert_equals: Expected remote track not to belong to a stream. expected 0 but got 1 FAIL addTrack() with a track and no stream makes ontrack fire with a track and no stream. assert_equals: No remote stream created. expected 0 but got 1
PASS addTrack() with a track and a stream makes ontrack fire with a track and a stream. PASS addTrack() with a track and a stream makes ontrack fire with a track and a stream.
PASS ontrack fires before setRemoteDescription resolves. PASS ontrack fires before setRemoteDescription resolves.
PASS addTrack() with two tracks and one stream makes ontrack fire twice with the tracks and shared stream. PASS addTrack() with two tracks and one stream makes ontrack fire twice with the tracks and shared stream.
PASS addTrack() for an existing stream makes stream.onaddtrack fire. PASS addTrack() for an existing stream makes stream.onaddtrack fire.
PASS stream.onaddtrack fires before setRemoteDescription resolves. PASS stream.onaddtrack fires before setRemoteDescription resolves.
FAIL addTrack() with a track and two streams makes ontrack fire with a track and two streams. Failed to execute 'addTrack' on 'RTCPeerConnection': Adding a track to multiple streams is not supported. FAIL addTrack() with a track and two streams makes ontrack fire with a track and two streams. promise_test: Unhandled rejection with value: object "NotSupportedError: Failed to execute 'addTrack' on 'RTCPeerConnection': Adding a track to multiple streams is not supported."
PASS ontrack's receiver matches getReceivers(). PASS ontrack's receiver matches getReceivers().
FAIL removeTrack() does not remove the receiver. assert_array_equals: Expected the set of receivers to remain the same. lengths differ, expected 1 got 0 FAIL removeTrack() does not remove the receiver. assert_equals: Receiver not removed. expected 1 but got 0
PASS removeTrack() makes stream.onremovetrack fire and the track to be removed from the stream. PASS removeTrack() makes stream.onremovetrack fire and the track to be removed from the stream.
PASS stream.onremovetrack fires before setRemoteDescription resolves. PASS stream.onremovetrack fires before setRemoteDescription resolves.
PASS removeTrack() makes track.onmute fire and the track to be muted. PASS removeTrack() makes track.onmute fire and the track to be muted.
PASS track.onmute fires before setRemoteDescription resolves. PASS track.onmute fires before setRemoteDescription resolves.
FAIL removeTrack() twice is safe. Failed to execute 'removeTrack' on 'RTCPeerConnection': The sender was not created by this peer connection. FAIL removeTrack() twice is safe. promise_test: Unhandled rejection with value: object "InvalidAccessError: Failed to execute 'removeTrack' on 'RTCPeerConnection': The sender was not created by this peer connection."
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -285,7 +285,7 @@ ...@@ -285,7 +285,7 @@
sendingTrack1 = tracks[0]; sendingTrack1 = tracks[0];
sendingTrack2 = tracks[1]; sendingTrack2 = tracks[1];
sender = caller.addTrack(sendingTrack1); sender = caller.addTrack(sendingTrack1);
return performOffer(caller, callee); return exchangeOffer(caller, callee);
})) }))
.then(t.step_func(() => { .then(t.step_func(() => {
return sender.replaceTrack(sendingTrack2); return sender.replaceTrack(sendingTrack2);
......
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