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

Fix errors external/wpt/RTCPeerConnection-removeTrack.https.html.

This is in preparation for RTCRtpTransceiver/Unified Plan support.

"Calling removeTrack with valid sender should set sender.track to null"
  Asserting that direction changes from 'sendrecv' to 'recvonly', this
  is explicit in the spec[1].

"Calling removeTrack with currentDirection blah should set direction to
 blah"
  The tests that meant to set up currentDirection to be 'sendrecv' or
  'recvonly' before removeTrack() were incorrect. Tests updated to set
  up currentDirection correctly. Also updated them to use async/await
  because that's much nicer.

These all fail because we don't have transceivers yet, but when running
these changes in the RTCRtpTransceiver WIP CL[2], they all pass.

[1] See step 10 of
    https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-removetrack
[2] https://chromium-review.googlesource.com/c/chromium/src/+/1025771/

Bug: 777617
Change-Id: Ie3c077d14ea30038a06a98ecbeea475ac824dd9c
Reviewed-on: https://chromium-review.googlesource.com/1095275Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566366}
parent 857445ce
...@@ -147,8 +147,7 @@ ...@@ -147,8 +147,7 @@
pc.removeTrack(sender); pc.removeTrack(sender);
assert_equals(sender.track, null); assert_equals(sender.track, null);
assert_equals(transceiver.direction, 'sendrecv', assert_equals(transceiver.direction, 'recvonly');
'direction should not be altered');
}, 'addTransceiver - Calling removeTrack with valid sender should set sender.track to null'); }, 'addTransceiver - Calling removeTrack with valid sender should set sender.track to null');
...@@ -179,31 +178,33 @@ ...@@ -179,31 +178,33 @@
10. If transceiver.currentDirection is sendrecv set transceiver.direction 10. If transceiver.currentDirection is sendrecv set transceiver.direction
to recvonly. to recvonly.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const caller = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => caller.close());
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
const track = generateMediaStreamTrack('audio'); const track = generateMediaStreamTrack('audio');
const transceiver = pc.addTransceiver(track); const transceiver = caller.addTransceiver(track);
const { sender } = transceiver; const { sender } = transceiver;
assert_equals(sender.track, track); assert_equals(sender.track, track);
assert_equals(transceiver.direction, 'sendrecv'); assert_equals(transceiver.direction, 'sendrecv');
assert_equals(transceiver.currentDirection, null); assert_equals(transceiver.currentDirection, null);
return pc.createOffer() const offer = await caller.createOffer();
.then(offer => await caller.setLocalDescription(offer);
pc.setLocalDescription(offer) await callee.setRemoteDescription(offer);
.then(() => generateAnswer(offer))) callee.addTrack(track);
.then(answer => pc.setRemoteDescription(answer)) const answer = await callee.createAnswer();
.then(() => { await callee.setLocalDescription(answer);
assert_equals(transceiver.currentDirection, 'sendrecv'); await caller.setRemoteDescription(answer);
assert_equals(transceiver.currentDirection, 'sendrecv');
pc.removeTrack(sender); caller.removeTrack(sender);
assert_equals(sender.track, null); assert_equals(sender.track, null);
assert_equals(transceiver.direction, 'recvonly'); assert_equals(transceiver.direction, 'recvonly');
assert_equals(transceiver.currentDirection, 'sendrecv', assert_equals(transceiver.currentDirection, 'sendrecv',
'Expect currentDirection to not change'); 'Expect currentDirection to not change');
});
}, 'Calling removeTrack with currentDirection sendrecv should set direction to recvonly'); }, 'Calling removeTrack with currentDirection sendrecv should set direction to recvonly');
/* /*
...@@ -212,7 +213,7 @@ ...@@ -212,7 +213,7 @@
11. If transceiver.currentDirection is sendonly set transceiver.direction 11. If transceiver.currentDirection is sendonly set transceiver.direction
to inactive. to inactive.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('audio'); const track = generateMediaStreamTrack('audio');
...@@ -223,20 +224,17 @@ ...@@ -223,20 +224,17 @@
assert_equals(transceiver.direction, 'sendonly'); assert_equals(transceiver.direction, 'sendonly');
assert_equals(transceiver.currentDirection, null); assert_equals(transceiver.currentDirection, null);
return pc.createOffer() const offer = await pc.createOffer();
.then(offer => await pc.setLocalDescription(offer);
pc.setLocalDescription(offer) const answer = await generateAnswer(offer);
.then(() => generateAnswer(offer))) await pc.setRemoteDescription(answer);
.then(answer => pc.setRemoteDescription(answer)) assert_equals(transceiver.currentDirection, 'sendonly');
.then(() => {
assert_equals(transceiver.currentDirection, 'sendonly');
pc.removeTrack(sender); pc.removeTrack(sender);
assert_equals(sender.track, null); assert_equals(sender.track, null);
assert_equals(transceiver.direction, 'inactive'); assert_equals(transceiver.direction, 'inactive');
assert_equals(transceiver.currentDirection, 'sendonly', assert_equals(transceiver.currentDirection, 'sendonly',
'Expect currentDirection to not change'); 'Expect currentDirection to not change');
});
}, 'Calling removeTrack with currentDirection sendonly should set direction to inactive'); }, 'Calling removeTrack with currentDirection sendonly should set direction to inactive');
/* /*
...@@ -245,30 +243,32 @@ ...@@ -245,30 +243,32 @@
9. If transceiver.currentDirection is recvonly or inactive, 9. If transceiver.currentDirection is recvonly or inactive,
then abort these steps. then abort these steps.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const caller = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => caller.close());
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
const track = generateMediaStreamTrack('audio'); const track = generateMediaStreamTrack('audio');
const transceiver = pc.addTransceiver(track, { direction: 'recvonly' }); const transceiver = caller.addTransceiver(track, { direction: 'recvonly' });
const { sender } = transceiver; const { sender } = transceiver;
assert_equals(sender.track, track); assert_equals(sender.track, track);
assert_equals(transceiver.direction, 'recvonly'); assert_equals(transceiver.direction, 'recvonly');
assert_equals(transceiver.currentDirection, null); assert_equals(transceiver.currentDirection, null);
return pc.createOffer() const offer = await caller.createOffer();
.then(offer => await caller.setLocalDescription(offer);
pc.setLocalDescription(offer) await callee.setRemoteDescription(offer);
.then(() => generateAnswer(offer))) callee.addTrack(track);
.then(answer => pc.setRemoteDescription(answer)) const answer = await callee.createAnswer();
.then(() => { await callee.setLocalDescription(answer);
assert_equals(transceiver.currentDirection, 'recvonly'); await caller.setRemoteDescription(answer);
assert_equals(transceiver.currentDirection, 'recvonly');
pc.removeTrack(sender); caller.removeTrack(sender);
assert_equals(sender.track, null); assert_equals(sender.track, null);
assert_equals(transceiver.direction, 'recvonly'); assert_equals(transceiver.direction, 'recvonly');
assert_equals(transceiver.currentDirection, 'recvonly'); assert_equals(transceiver.currentDirection, 'recvonly');
});
}, 'Calling removeTrack with currentDirection recvonly should not change direction'); }, 'Calling removeTrack with currentDirection recvonly should not change direction');
/* /*
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
9. If transceiver.currentDirection is recvonly or inactive, 9. If transceiver.currentDirection is recvonly or inactive,
then abort these steps. then abort these steps.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('audio'); const track = generateMediaStreamTrack('audio');
...@@ -288,19 +288,16 @@ ...@@ -288,19 +288,16 @@
assert_equals(transceiver.direction, 'inactive'); assert_equals(transceiver.direction, 'inactive');
assert_equals(transceiver.currentDirection, null); assert_equals(transceiver.currentDirection, null);
return pc.createOffer() const offer = await pc.createOffer();
.then(offer => await pc.setLocalDescription(offer);
pc.setLocalDescription(offer) const answer = await generateAnswer(offer);
.then(() => generateAnswer(offer))) await pc.setRemoteDescription(answer);
.then(answer => pc.setRemoteDescription(answer)) assert_equals(transceiver.currentDirection, 'inactive');
.then(() => {
assert_equals(transceiver.currentDirection, 'inactive');
pc.removeTrack(sender); pc.removeTrack(sender);
assert_equals(sender.track, null); assert_equals(sender.track, null);
assert_equals(transceiver.direction, 'inactive'); assert_equals(transceiver.direction, 'inactive');
assert_equals(transceiver.currentDirection, 'inactive'); assert_equals(transceiver.currentDirection, 'inactive');
});
}, 'Calling removeTrack with currentDirection inactive should not change direction'); }, 'Calling removeTrack with currentDirection inactive should not change direction');
/* /*
......
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