Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RTCRtpTransceiver direction tests #13914

Merged
merged 3 commits into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webrtc/RTCDTMFSender-ontonechange.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
// tonechange event, to make sure that tonechange is triggered
// then stopped
if(tone === 'A') {
transceiver.setDirection('recvonly');
transceiver.direction = 'recvonly';

pc.createOffer()
.then(offer =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,57 @@
<!doctype html>
<meta charset=utf-8>
<title>RTCRtpTransceiver.prototype.setDirection</title>
<title>RTCRtpTransceiver.prototype.direction</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script>
'use strict';

// Test is based on the following editor draft:
// https://rawgit.com/w3c/webrtc-pc/cc8d80f455b86c8041d63bceb8b457f45c72aa89/webrtc.html
// https://rawgit.com/w3c/webrtc-pc/8495678808d126d8bc764bf944996f32981fa6fd/webrtc.html

// The following helper functions are called from RTCPeerConnection-helper.js:
// generateAnswer

/*
5.4. RTCRtpTransceiver Interface
interface RTCRtpTransceiver {
readonly attribute RTCRtpTransceiverDirection direction;
attribute RTCRtpTransceiverDirection direction;
readonly attribute RTCRtpTransceiverDirection? currentDirection;
void setDirection(RTCRtpTransceiverDirection direction);
...
};
*/

/*
5.4. setDirection
4. Set transceiver's [[Direction]] slot to newDirection.
5.4. direction
7. Set transceiver's [[Direction]] slot to newDirection.
*/
test(t => {
const pc = new RTCPeerConnection();
const transceiver = pc.addTransceiver('audio');
assert_equals(transceiver.direction, 'sendrecv');
assert_equals(transceiver.currentDirection, null);

transceiver.setDirection('recvonly');
transceiver.direction = 'recvonly';
assert_equals(transceiver.direction, 'recvonly');
assert_equals(transceiver.currentDirection, null,
'Expect transceiver.currentDirection to not change');

}, 'setDirection should change transceiver.direction');
}, 'setting direction should change transceiver.direction');

/*
5.4. setDirection
5.4. direction
3. If newDirection is equal to transceiver's [[Direction]] slot, abort
these steps.
*/
test(t => {
const pc = new RTCPeerConnection();
const transceiver = pc.addTransceiver('audio', { direction: 'sendonly' });
assert_equals(transceiver.direction, 'sendonly');
transceiver.setDirection('sendonly');
transceiver.direction = 'sendonly';
assert_equals(transceiver.direction, 'sendonly');

}, 'setDirection with same direction should have no effect');
}, 'setting direction with same direction should have no effect');

promise_test(t => {
const pc = new RTCPeerConnection();
Expand All @@ -67,22 +66,22 @@
.then(() => generateAnswer(offer)))
.then(answer => pc.setRemoteDescription(answer))
.then(() => {
assert_equals(transceiver.currentDirection, 'recvonly');
transceiver.setDirection('sendrecv');
assert_equals(transceiver.currentDirection, 'inactive');
transceiver.direction = 'sendrecv';
assert_equals(transceiver.direction, 'sendrecv');
assert_equals(transceiver.currentDirection, 'recvonly');
assert_equals(transceiver.currentDirection, 'inactive');
});
}, 'setDirection should change transceiver.direction independent of transceiver.currentDirection');
}, 'setting direction should change transceiver.direction independent of transceiver.currentDirection');

/*
TODO
Calls to setDirection() do not take effect immediately. Instead, future calls
An update of directionality does not take effect immediately. Instead, future calls
to createOffer and createAnswer mark the corresponding media description as
sendrecv, sendonly, recvonly or inactive as defined in [JSEP] (section 5.2.2.
and section 5.3.2.).

Tested in RTCPeerConnection-onnegotiationneeded.html
5.4. setDirection
5.4. direction
6. Update the negotiation-needed flag for connection.

Coverage Report
Expand Down
4 changes: 2 additions & 2 deletions webrtc/RTCRtpTransceiver.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@
"InvalidStateError", "replaceTrack on stopped transceiver");

checkThrows(() => transceiver.direction = "sendrecv",
"InvalidStateError", "setDirection on stopped transceiver");
"InvalidStateError", "set direction on stopped transceiver");

checkThrows(() => transceiver.sender.dtmf.insertDTMF("111"),
"InvalidStateError", "insertDTMF on stopped transceiver");
Expand Down Expand Up @@ -1775,7 +1775,7 @@
await pc2.setRemoteDescription({type: "rollback"});

// Transceiver should be _gone_, again. replaceTrack doesn't prevent this,
// nor does setDirection.
// nor does setting direction.
hasProps(pc2.getTransceivers(), []);

// Setting the same offer for a _third_ time should do the same thing
Expand Down