OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 Common OOBE controller methods. | 6 * @fileoverview Common OOBE controller methods. |
7 */ | 7 */ |
8 | 8 |
9 <include src="test_util.js"> | 9 <include src="test_util.js"> |
10 <include src="../../../../../ui/login/screen.js"> | 10 <include src="../../../../../ui/login/screen.js"> |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 */ | 286 */ |
287 Oobe.skipToLoginForTesting = function() { | 287 Oobe.skipToLoginForTesting = function() { |
288 Oobe.disableSigninUI(); | 288 Oobe.disableSigninUI(); |
289 chrome.send('skipToLoginForTesting'); | 289 chrome.send('skipToLoginForTesting'); |
290 }; | 290 }; |
291 | 291 |
292 /** | 292 /** |
293 * Login for telemetry. | 293 * Login for telemetry. |
294 * @param {string} username Login username. | 294 * @param {string} username Login username. |
295 * @param {string} password Login password. | 295 * @param {string} password Login password. |
| 296 * @param {boolean} enterpriseEnroll Login as an enterprise enrollment? |
296 */ | 297 */ |
297 Oobe.loginForTesting = function(username, password, gaia_id) { | 298 Oobe.loginForTesting = function(username, password, gaia_id, |
| 299 enterpriseEnroll = false) { |
| 300 // Helper method that runs |fn| after |screenName| is visible. |
| 301 function waitForOobeScreen(screenName, fn) { |
| 302 if (Oobe.getInstance().currentScreen.id === screenName) { |
| 303 fn(); |
| 304 } else { |
| 305 $('oobe').addEventListener('screenchanged', function handler(e) { |
| 306 if (e.detail == screenName) { |
| 307 $('oobe').removeEventListener('screenchanged', handler); |
| 308 fn(); |
| 309 } |
| 310 }); |
| 311 } |
| 312 } |
| 313 |
| 314 if (!gaia_id) { |
| 315 // TODO (alemate): Remove this backward compatibility hack when |
| 316 // as soon as all telemetry tests will pass gaia_id directly. |
| 317 gaia_id = '12345'; |
| 318 } |
| 319 |
298 Oobe.disableSigninUI(); | 320 Oobe.disableSigninUI(); |
299 chrome.send('skipToLoginForTesting', [username]); | 321 chrome.send('skipToLoginForTesting', [username]); |
300 if (!gaia_id) { | 322 |
301 /* TODO (alemate): Remove this backward compatibility hack when | 323 if (!enterpriseEnroll) { |
302 as soon as all telemetry tests will pass gaia_id directly. | 324 chrome.send('completeLogin', [gaia_id, username, password, false]); |
303 */ | 325 } else { |
304 gaia_id = '12345'; | 326 waitForOobeScreen('gaia-signin', function() { |
| 327 chrome.send('toggleEnrollmentScreen'); |
| 328 chrome.send('toggleFakeEnrollment'); |
| 329 }); |
| 330 |
| 331 waitForOobeScreen('oauth-enrollment', function() { |
| 332 chrome.send('oauthEnrollCompleteLogin', [username, 'authcode']); |
| 333 chrome.send('completeLogin', ['12345', username, password, false]); |
| 334 }); |
305 } | 335 } |
306 chrome.send('completeLogin', [gaia_id, username, password, false]); | |
307 }; | 336 }; |
308 | 337 |
309 /** | 338 /** |
310 * Guest login for telemetry. | 339 * Guest login for telemetry. |
311 */ | 340 */ |
312 Oobe.guestLoginForTesting = function() { | 341 Oobe.guestLoginForTesting = function() { |
313 Oobe.skipToLoginForTesting(); | 342 Oobe.skipToLoginForTesting(); |
314 chrome.send('launchIncognito'); | 343 chrome.send('launchIncognito'); |
315 }; | 344 }; |
316 | 345 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 cr.ui.login.ResourceLoader.loadAssets(SCREEN_OOBE_ENROLLMENT, function() { | 452 cr.ui.login.ResourceLoader.loadAssets(SCREEN_OOBE_ENROLLMENT, function() { |
424 // This screen is async-loaded so we manually trigger i18n processing. | 453 // This screen is async-loaded so we manually trigger i18n processing. |
425 i18nTemplate.process($('oauth-enrollment'), loadTimeData); | 454 i18nTemplate.process($('oauth-enrollment'), loadTimeData); |
426 // Delayed binding since this isn't defined yet. | 455 // Delayed binding since this isn't defined yet. |
427 login.OAuthEnrollmentScreen.register(); | 456 login.OAuthEnrollmentScreen.register(); |
428 }); | 457 }); |
429 | 458 |
430 cr.ui.Oobe.initialize(); | 459 cr.ui.Oobe.initialize(); |
431 }); | 460 }); |
432 })(); | 461 })(); |
OLD | NEW |