Chromium Code Reviews| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 } | 183 } |
| 184 remoting.testEvents.addEventListener(uiModeChanged, onUIModeChanged); | 184 remoting.testEvents.addEventListener(uiModeChanged, onUIModeChanged); |
| 185 }); | 185 }); |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 /** | 188 /** |
| 189 * @return {Promise} | 189 * @return {Promise} |
| 190 */ | 190 */ |
| 191 browserTest.connectMe2Me = function() { | 191 browserTest.connectMe2Me = function() { |
| 192 var AppMode = remoting.AppMode; | 192 var AppMode = remoting.AppMode; |
| 193 browserTest.clickOnControl('this-host-connect'); | 193 // The 1 second is necessary because the click handler of 'this-host-connect' |
| 194 return browserTest.onUIMode(AppMode.CLIENT_HOST_NEEDS_UPGRADE).then( | 194 // is hooked asynchronously. |
|
Jamie
2015/02/23 20:56:26
It's not entirely clear what this means. I suggest
| |
| 195 function() { | 195 return base.Promise.sleep(1000).then(function() { |
| 196 browserTest.clickOnControl('this-host-connect'); | |
| 197 }).then(function(){ | |
| 198 return browserTest.onUIMode(AppMode.CLIENT_HOST_NEEDS_UPGRADE); | |
| 199 }).then(function() { | |
| 196 // On fulfilled. | 200 // On fulfilled. |
| 197 browserTest.clickOnControl('host-needs-update-connect-button'); | 201 browserTest.clickOnControl('host-needs-update-connect-button'); |
| 198 }, function() { | 202 }, function() { |
| 199 // On time out. | 203 // On time out. |
| 200 return Promise.resolve(); | 204 return Promise.resolve(); |
| 201 }).then(function() { | 205 }).then(function() { |
| 202 return browserTest.onUIMode(AppMode.CLIENT_PIN_PROMPT, 10000); | 206 return browserTest.onUIMode(AppMode.CLIENT_PIN_PROMPT, 10000); |
| 203 }); | 207 }); |
| 204 }; | 208 }; |
| 205 | 209 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 var errorMsg = errorDiv.innerText; | 310 var errorMsg = errorDiv.innerText; |
| 307 return Promise.reject('Unexpected error - ' + errorMsg); | 311 return Promise.reject('Unexpected error - ' + errorMsg); |
| 308 }); | 312 }); |
| 309 return Promise.race([onConnected, onFailure]); | 313 return Promise.race([onConnected, onFailure]); |
| 310 }; | 314 }; |
| 311 | 315 |
| 312 /** | 316 /** |
| 313 * @param {base.EventSource} eventSource | 317 * @param {base.EventSource} eventSource |
| 314 * @param {string} event | 318 * @param {string} event |
| 315 * @param {number} timeoutMs | 319 * @param {number} timeoutMs |
| 316 * @param {?string} opt_expectedData | 320 * @param {*=} opt_expectedData |
| 317 * @return {Promise} | 321 * @return {Promise} |
| 318 */ | 322 */ |
| 319 browserTest.expectEvent = function(eventSource, event, timeoutMs, | 323 browserTest.expectEvent = function(eventSource, event, timeoutMs, |
| 320 opt_expectedData) { | 324 opt_expectedData) { |
| 321 return new Promise(function(fullfil, reject) { | 325 return new Promise(function(fullfil, reject) { |
| 322 /** @param {string=} actualData */ | 326 /** @param {string=} actualData */ |
| 323 var verifyEventParameters = function(actualData) { | 327 var verifyEventParameters = function(actualData) { |
| 324 if (opt_expectedData === undefined || opt_expectedData === actualData) { | 328 if (opt_expectedData === undefined || opt_expectedData === actualData) { |
| 325 fullfil(true); | 329 fullfil(true); |
| 326 } else { | 330 } else { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 console.log('browserTest: PIN Setup is done.'); | 380 console.log('browserTest: PIN Setup is done.'); |
| 377 browserTest.clickOnControl('host-config-done-dismiss'); | 381 browserTest.clickOnControl('host-config-done-dismiss'); |
| 378 | 382 |
| 379 // On Linux, we restart the host after changing the PIN, need to sleep | 383 // On Linux, we restart the host after changing the PIN, need to sleep |
| 380 // for ten seconds before the host is ready for connection. | 384 // for ten seconds before the host is ready for connection. |
| 381 return base.Promise.sleep(HOST_SETUP_WAIT); | 385 return base.Promise.sleep(HOST_SETUP_WAIT); |
| 382 }); | 386 }); |
| 383 }; | 387 }; |
| 384 | 388 |
| 385 /** | 389 /** |
| 386 * @return {Promise} | 390 * @return {Promise<boolean>} |
| 387 */ | 391 */ |
| 388 browserTest.isLocalHostStarted = function() { | 392 browserTest.isLocalHostStarted = function() { |
| 389 return new Promise(function(resolve) { | 393 return new Promise(function(resolve) { |
| 390 remoting.hostController.getLocalHostState(function(state) { | 394 remoting.hostController.getLocalHostState(function(state) { |
| 391 resolve(remoting.HostController.State.STARTED == state); | 395 resolve(remoting.HostController.State.STARTED == state); |
| 392 }); | 396 }); |
| 393 }); | 397 }); |
| 394 }; | 398 }; |
| 395 | 399 |
| 396 /** | 400 /** |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 421 */ | 425 */ |
| 422 browserTest.ensureRemoteConnectionEnabled = function(pin) { | 426 browserTest.ensureRemoteConnectionEnabled = function(pin) { |
| 423 browserTest.ensureHostStartedWithPIN(pin).then(function() { | 427 browserTest.ensureHostStartedWithPIN(pin).then(function() { |
| 424 browserTest.pass(); | 428 browserTest.pass(); |
| 425 }, function(reason) { | 429 }, function(reason) { |
| 426 browserTest.fail(reason); | 430 browserTest.fail(reason); |
| 427 }); | 431 }); |
| 428 }; | 432 }; |
| 429 | 433 |
| 430 browserTest.init(); | 434 browserTest.init(); |
| OLD | NEW |