| OLD | NEW |
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Checks if the session has been started successfully. | 62 * Checks if the session has been started successfully. |
| 63 */ | 63 */ |
| 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'); | 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 sendResult(true, ''); | 74 if (startedConnection.state != "connecting") { |
| 75 sendResult(false, |
| 76 'Expect connection state to be "connecting", actual "' + |
| 77 startedConnection.state + '"'); |
| 78 } |
| 79 startedConnection.onconnect = () => { |
| 80 sendResult(true, ''); |
| 81 }; |
| 75 } | 82 } |
| 76 }).catch(function() { | 83 }).catch(function(e) { |
| 77 // terminate old session if exists | 84 // terminate old session if exists |
| 78 startedConnection && startedConnection.terminate(); | 85 startedConnection && startedConnection.terminate(); |
| 79 sendResult(false, 'Failed to start session'); | 86 sendResult(false, 'Failed to start session: encountered exception ' + e); |
| 80 }) | 87 }) |
| 81 } | 88 } |
| 82 } | 89 } |
| 83 | 90 |
| 84 /** | 91 /** |
| 85 * Checks the start() request fails with expected error and message substring. | 92 * Checks the start() request fails with expected error and message substring. |
| 86 * @param {!string} expectedErrorName | 93 * @param {!string} expectedErrorName |
| 87 * @param {!string} expectedErrorMessageSubstring | 94 * @param {!string} expectedErrorMessageSubstring |
| 88 */ | 95 */ |
| 89 function checkStartFailed(expectedErrorName, expectedErrorMessageSubstring) { | 96 function checkStartFailed(expectedErrorName, expectedErrorMessageSubstring) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 passed: passed, | 219 passed: passed, |
| 213 errorMessage: errorMessage | 220 errorMessage: errorMessage |
| 214 })); | 221 })); |
| 215 } else { | 222 } else { |
| 216 lastExecutionResult = JSON.stringify({ | 223 lastExecutionResult = JSON.stringify({ |
| 217 passed: passed, | 224 passed: passed, |
| 218 errorMessage: errorMessage | 225 errorMessage: errorMessage |
| 219 }); | 226 }); |
| 220 } | 227 } |
| 221 } | 228 } |
| OLD | NEW |