OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * | 7 * |
8 * Provides basic functionality for JavaScript based browser test. | 8 * Provides basic functionality for JavaScript based browser test. |
9 * | 9 * |
10 * To define a browser test, create a class under the browserTest namespace. | 10 * To define a browser test, create a class under the browserTest namespace. |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 | 266 |
267 /** | 267 /** |
268 * @param {remoting.DesktopRemoting.Mode} connectionMode | 268 * @param {remoting.DesktopRemoting.Mode} connectionMode |
269 * @param {Array<remoting.Error.Tag>} errorTags | 269 * @param {Array<remoting.Error.Tag>} errorTags |
270 * @return {Promise} | 270 * @return {Promise} |
271 */ | 271 */ |
272 browserTest.expectConnectionError = function(connectionMode, errorTags) { | 272 browserTest.expectConnectionError = function(connectionMode, errorTags) { |
273 var AppMode = remoting.AppMode; | 273 var AppMode = remoting.AppMode; |
274 var Timeout = browserTest.Timeout; | 274 var Timeout = browserTest.Timeout; |
275 | 275 |
276 // Timeout if the session is not failed within 30 seconds. | |
277 var SESSION_CONNECTION_TIMEOUT = 30000; | |
278 | |
276 var finishButton = 'client-finished-me2me-button'; | 279 var finishButton = 'client-finished-me2me-button'; |
280 var failureMode = AppMode.CLIENT_CONNECT_FAILED_ME2ME; | |
277 | 281 |
278 if (connectionMode == remoting.DesktopRemoting.Mode.IT2ME) { | 282 if (connectionMode == remoting.DesktopRemoting.Mode.IT2ME) { |
279 finishButton = 'client-finished-it2me-button'; | 283 finishButton = 'client-finished-it2me-button'; |
284 failureMode = AppMode.CLIENT_CONNECT_FAILED_IT2ME; | |
280 } | 285 } |
281 | 286 |
282 var onConnected = browserTest.onUIMode(AppMode.IN_SESSION, Timeout.NONE); | 287 var onConnected = browserTest.onUIMode(AppMode.IN_SESSION, Timeout.NONE); |
283 var onFailure = Promise.race([ | 288 var onFailure = browserTest.onUIMode(failureMode, SESSION_CONNECTION_TIMEOUT); |
Jamie
2015/06/18 01:05:30
You've also made the test stricter, which is a goo
| |
284 browserTest.onUIMode(AppMode.CLIENT_CONNECT_FAILED_ME2ME), | |
285 browserTest.onUIMode(AppMode.CLIENT_CONNECT_FAILED_IT2ME)]); | |
286 | 289 |
287 onConnected = onConnected.then(function() { | 290 onConnected = onConnected.then(function() { |
288 return Promise.reject( | 291 return Promise.reject( |
289 'Expected the connection to fail.'); | 292 'Expected the connection to fail.'); |
290 }); | 293 }); |
291 | 294 |
292 onFailure = onFailure.then(function() { | 295 onFailure = onFailure.then(function() { |
293 /** @type {Element} */ | 296 /** @type {Element} */ |
294 var errorDiv = document.getElementById('connect-error-message'); | 297 var errorDiv = document.getElementById('connect-error-message'); |
295 var actual = errorDiv.innerText; | 298 var actual = errorDiv.innerText; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 */ | 441 */ |
439 browserTest.ensureRemoteConnectionEnabled = function(pin) { | 442 browserTest.ensureRemoteConnectionEnabled = function(pin) { |
440 browserTest.ensureHostStartedWithPIN(pin).then(function() { | 443 browserTest.ensureHostStartedWithPIN(pin).then(function() { |
441 browserTest.pass(); | 444 browserTest.pass(); |
442 }, function(reason) { | 445 }, function(reason) { |
443 browserTest.fail(reason); | 446 browserTest.fail(reason); |
444 }); | 447 }); |
445 }; | 448 }; |
446 | 449 |
447 browserTest.init(); | 450 browserTest.init(); |
OLD | NEW |