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

Side by Side Diff: remoting/webapp/browser_test/browser_test.js

Issue 1007543003: Implements It2MeBrowserTest CancelShare and VerifyAccessCodeNotReusable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 9 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 unified diff | Download patch
OLDNEW
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 var CONNECT_PIN_WAIT = 500; 242 var CONNECT_PIN_WAIT = 500;
243 243
244 document.getElementById('pin-entry').value = pin; 244 document.getElementById('pin-entry').value = pin;
245 245
246 return base.Promise.sleep(CONNECT_PIN_WAIT).then(function() { 246 return base.Promise.sleep(CONNECT_PIN_WAIT).then(function() {
247 browserTest.clickOnControl('pin-connect-button'); 247 browserTest.clickOnControl('pin-connect-button');
248 }).then(function() { 248 }).then(function() {
249 if (opt_expectError) { 249 if (opt_expectError) {
250 return browserTest.expectConnectionError( 250 return browserTest.expectConnectionError(
251 remoting.DesktopConnectedView.Mode.ME2ME, 251 remoting.DesktopConnectedView.Mode.ME2ME,
252 remoting.Error.Tag.INVALID_ACCESS_CODE); 252 [remoting.Error.Tag.INVALID_ACCESS_CODE]);
253 } else { 253 } else {
254 return browserTest.expectConnected(); 254 return browserTest.expectConnected();
255 } 255 }
256 }); 256 });
257 }; 257 };
258 258
259 /** 259 /**
260 * @param {remoting.DesktopConnectedView.Mode} connectionMode 260 * @param {remoting.DesktopConnectedView.Mode} connectionMode
261 * @param {string} errorTag 261 * @param {Array<remoting.Error.Tag>} errorTags
262 * @return {Promise} 262 * @return {Promise}
263 */ 263 */
264 browserTest.expectConnectionError = function(connectionMode, errorTag) { 264 browserTest.expectConnectionError = function(connectionMode, errorTags) {
265 var AppMode = remoting.AppMode; 265 var AppMode = remoting.AppMode;
266 var Timeout = browserTest.Timeout; 266 var Timeout = browserTest.Timeout;
267 267
268 var finishButton = 'client-finished-me2me-button'; 268 var finishButton = 'client-finished-me2me-button';
269 269
270 if (connectionMode == remoting.DesktopConnectedView.Mode.IT2ME) { 270 if (connectionMode == remoting.DesktopConnectedView.Mode.IT2ME) {
271 finishButton = 'client-finished-it2me-button'; 271 finishButton = 'client-finished-it2me-button';
272 } 272 }
273 273
274 var onConnected = browserTest.onUIMode(AppMode.IN_SESSION, Timeout.NONE); 274 var onConnected = browserTest.onUIMode(AppMode.IN_SESSION, Timeout.NONE);
275 var onFailure = Promise.race([ 275 var onFailure = Promise.race([
276 browserTest.onUIMode(AppMode.CLIENT_CONNECT_FAILED_ME2ME), 276 browserTest.onUIMode(AppMode.CLIENT_CONNECT_FAILED_ME2ME),
277 browserTest.onUIMode(AppMode.CLIENT_CONNECT_FAILED_IT2ME)]); 277 browserTest.onUIMode(AppMode.CLIENT_CONNECT_FAILED_IT2ME)]);
278 278
279 onConnected = onConnected.then(function() { 279 onConnected = onConnected.then(function() {
280 return Promise.reject( 280 return Promise.reject(
281 'Expected the connection to fail.'); 281 'Expected the connection to fail.');
282 }); 282 });
283 283
284 onFailure = onFailure.then(function() { 284 onFailure = onFailure.then(function() {
285 /** @type {Element} */ 285 /** @type {Element} */
286 var errorDiv = document.getElementById('connect-error-message'); 286 var errorDiv = document.getElementById('connect-error-message');
287 var actual = errorDiv.innerText; 287 var actual = errorDiv.innerText;
288 var expected = l10n.getTranslationOrError(errorTag); 288 var expected = errorTags.map(function(/** string */errorTag) {
289 return l10n.getTranslationOrError(errorTag);
290 });
289 browserTest.clickOnControl(finishButton); 291 browserTest.clickOnControl(finishButton);
290 292
291 if (actual != expected) { 293 if (expected.indexOf(actual) === -1) {
292 return Promise.reject('Unexpected failure. actual:' + actual + 294 return Promise.reject('Unexpected failure. actual: ' + actual +
293 ' expected:' + expected); 295 ' expected: ' + expected.join(','));
294 } 296 }
295 }); 297 });
296 298
297 return Promise.race([onConnected, onFailure]); 299 return Promise.race([onConnected, onFailure]);
298 }; 300 };
299 301
300 /** 302 /**
301 * @return {Promise} 303 * @return {Promise}
302 */ 304 */
303 browserTest.expectConnected = function() { 305 browserTest.expectConnected = function() {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 */ 430 */
429 browserTest.ensureRemoteConnectionEnabled = function(pin) { 431 browserTest.ensureRemoteConnectionEnabled = function(pin) {
430 browserTest.ensureHostStartedWithPIN(pin).then(function() { 432 browserTest.ensureHostStartedWithPIN(pin).then(function() {
431 browserTest.pass(); 433 browserTest.pass();
432 }, function(reason) { 434 }, function(reason) {
433 browserTest.fail(reason); 435 browserTest.fail(reason);
434 }); 436 });
435 }; 437 };
436 438
437 browserTest.init(); 439 browserTest.init();
OLDNEW
« no previous file with comments | « chrome/test/remoting/it2me_browsertest.cc ('k') | remoting/webapp/browser_test/it2me_browser_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698