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

Side by Side Diff: chrome/test/media_router/resources/common.js

Issue 2492393002: [Presentation API] Fix integration test - initial state of connection can be 'connecting' or 'conne… (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * Copyright 2015 The Chromium Authors. All rights reserved. 2 * Copyright 2015 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 * 5 *
6 * @fileoverview Common APIs for presentation integration tests. 6 * @fileoverview Common APIs for presentation integration tests.
7 * 7 *
8 */ 8 */
9 9
10 var startSessionPromise = null; 10 var startSessionPromise = null;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 function checkSession() { 64 function checkSession() {
65 if (!startSessionPromise) { 65 if (!startSessionPromise) {
66 sendResult(false, 'Did not attempt to start session'); 66 sendResult(false, 'Did not attempt to start session');
67 } else { 67 } else {
68 startSessionPromise.then(function(session) { 68 startSessionPromise.then(function(session) {
69 if(!session) { 69 if(!session) {
70 sendResult(false, 'Failed to start session: connection is null'); 70 sendResult(false, 'Failed to start session: connection is null');
71 } else { 71 } else {
72 // set the new session 72 // set the new session
73 startedConnection = session; 73 startedConnection = session;
74 if (startedConnection.state != "connecting") { 74 console.log('connection state is "' + startedConnection.state + '"');
75 if (startedConnection.state == "connected") {
76 sendResult(true, '');
77 } else if (startedConnection.state == "connecting") {
78 startedConnection.onconnect = () => {
79 sendResult(true, '');
80 };
81 } else {
75 sendResult(false, 82 sendResult(false,
76 'Expect connection state to be "connecting", actual "' + 83 'Expect connection state to be "connecting" or "connected", ' +
77 startedConnection.state + '"'); 84 'actual "' + startedConnection.state + '"');
78 } 85 }
79 startedConnection.onconnect = () => {
80 sendResult(true, '');
81 };
82 } 86 }
83 }).catch(function(e) { 87 }).catch(function(e) {
84 // terminate old session if exists 88 // terminate old session if exists
85 startedConnection && startedConnection.terminate(); 89 startedConnection && startedConnection.terminate();
86 sendResult(false, 'Failed to start session: encountered exception ' + e); 90 sendResult(false, 'Failed to start session: encountered exception ' + e);
87 }) 91 })
88 } 92 }
89 } 93 }
90 94
91 /** 95 /**
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 passed: passed, 223 passed: passed,
220 errorMessage: errorMessage 224 errorMessage: errorMessage
221 })); 225 }));
222 } else { 226 } else {
223 lastExecutionResult = JSON.stringify({ 227 lastExecutionResult = JSON.stringify({
224 passed: passed, 228 passed: passed,
225 errorMessage: errorMessage 229 errorMessage: errorMessage
226 }); 230 });
227 } 231 }
228 } 232 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698