Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: LayoutTests/imported/web-platform-tests/webrtc/promises-call.html

Issue 1160513003: W3C Test: Import web-platform-tests/html/browsers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase, bug links Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/imported/web-platform-tests/subresource-integrity/refresh-header.js.headers ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/imported/web-platform-tests/webrtc/promises-call.html
diff --git a/LayoutTests/imported/web-platform-tests/webrtc/no-media-call.html b/LayoutTests/imported/web-platform-tests/webrtc/promises-call.html
similarity index 57%
copy from LayoutTests/imported/web-platform-tests/webrtc/no-media-call.html
copy to LayoutTests/imported/web-platform-tests/webrtc/promises-call.html
index 0a02b8a1c03de6226eec78d06a452547a4ffba66..e52be7502222917fff4216129a3d9c96fe2cafbb 100644
--- a/LayoutTests/imported/web-platform-tests/webrtc/no-media-call.html
+++ b/LayoutTests/imported/web-platform-tests/webrtc/promises-call.html
@@ -1,12 +1,12 @@
<!doctype html>
<!--
-This test uses no media, and thus does not require fake media devices.
+This test uses data only, and thus does not require fake media devices.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>RTCPeerConnection No-Media Connection Test</title>
+ <title>RTCPeerConnection Data-Only Connection Test with Promises</title>
</head>
<body>
<div id="log"></div>
@@ -25,50 +25,11 @@ This test uses no media, and thus does not require fake media devices.
>
</script>
<script type="text/javascript">
- var test = async_test('Can set up a basic WebRTC call with no data.');
+ var test = async_test('Can set up a basic WebRTC call with only data using promises.');
var gFirstConnection = null;
var gSecondConnection = null;
- var onOfferCreated = test.step_func(function(offer) {
- // TODO: Switch to promise-based interface.
- gFirstConnection.setLocalDescription(offer, ignoreSuccess,
- failed('setLocalDescription first'));
-
- // This would normally go across the application's signaling solution.
- // In our case, the "signaling" is to call this function.
- receiveCall(offer.sdp);
- });
-
- function receiveCall(offerSdp) {
-
- var parsedOffer = new RTCSessionDescription({ type: 'offer',
- sdp: offerSdp });
- // These functions use the legacy interface extensions to RTCPeerConnection.
- // TODO: Switch to promise-based interfaces.
- gSecondConnection.setRemoteDescription(parsedOffer,
- function() {
- gSecondConnection.createAnswer(onAnswerCreated,
- failed('createAnswer'));
- },
- failed('setRemoteDescription second'));
- };
-
- var onAnswerCreated = test.step_func(function(answer) {
- gSecondConnection.setLocalDescription(answer, ignoreSuccess,
- failed('setLocalDescription second'));
-
- // Similarly, this would go over the application's signaling solution.
- handleAnswer(answer.sdp);
- });
-
- function handleAnswer(answerSdp) {
- var parsedAnswer = new RTCSessionDescription({ type: 'answer',
- sdp: answerSdp });
- gFirstConnection.setRemoteDescription(parsedAnswer, ignoreSuccess,
- failed('setRemoteDescription first'));
- };
-
var onIceCandidateToFirst = test.step_func(function(event) {
// If event.candidate is null = no more candidates.
if (event.candidate) {
@@ -115,17 +76,6 @@ This test uses no media, and thus does not require fake media devices.
}
});
- // Returns a suitable error callback.
- function failed(function_name) {
- return test.step_func(function() {
- assert_unreached('WebRTC called error callback for ' + function_name);
- });
- }
-
- // Returns a suitable do-nothing.
- function ignoreSuccess(function_name) {
- }
-
// This function starts the test.
test.step(function() {
gFirstConnection = new RTCPeerConnection(null);
@@ -137,11 +87,42 @@ This test uses no media, and thus does not require fake media devices.
gSecondConnection.onaddstream = onRemoteStream;
gSecondConnection.oniceconnectionstatechange = onIceConnectionStateChange;
- // The offerToReceiveVideo is necessary and sufficient to make
- // an actual connection.
- // TODO: Use a promise-based API. This is legacy.
- gFirstConnection.createOffer(onOfferCreated, failed('createOffer'),
- {offerToReceiveVideo: true});
+ // The createDataChannel is necessary and sufficient to make
+ // sure the ICE connection be attempted.
+ gFirstConnection.createDataChannel('channel');
+
+ var atStep = 'Create offer';
+
+ gFirstConnection.createOffer()
+ .then(function(offer) {
+ atStep = 'Set local description at first';
+ return gFirstConnection.setLocalDescription(offer);
+ })
+ .then(function() {
+ atStep = 'Set remote description at second';
+ return gSecondConnection.setRemoteDescription(
+ gFirstConnection.localDescription);
+ })
+ .then(function() {
+ atStep = 'Create answer';
+ return gSecondConnection.createAnswer()
+ })
+ .then(function(answer) {
+ atStep = 'Set local description at second';
+ return gSecondConnection.setLocalDescription(answer);
+ })
+ .then(function() {
+ atStep = 'Set remote description at first';
+ return gFirstConnection.setRemoteDescription(
+ gSecondConnection.localDescription);
+ })
+ .then(function() {
+ atStep = 'Negotiation completed';
+ })
+ .catch(test.step_func(function(e) {
+ assert_unreached('Error ' + e.name + ': ' + e.message +
+ ' happened at step ' + atStep);
+ }));
});
</script>
« no previous file with comments | « LayoutTests/imported/web-platform-tests/subresource-integrity/refresh-header.js.headers ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698