OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 cr.define('settings_about_page', function() { | 5 cr.define('settings_about_page', function() { |
6 /** | 6 /** |
7 * @constructor | 7 * @constructor |
8 * @implements {settings.AboutPageBrowserProxy} | 8 * @implements {settings.AboutPageBrowserProxy} |
9 * @extends {settings.TestBrowserProxy} | 9 * @extends {settings.TestBrowserProxy} |
10 */ | 10 */ |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 return initNewPage().then(function() { | 283 return initNewPage().then(function() { |
284 assertTrue(!!page.$.relaunch); | 284 assertTrue(!!page.$.relaunch); |
285 assertTrue(!!page.$.relaunchAndPowerwash); | 285 assertTrue(!!page.$.relaunchAndPowerwash); |
286 | 286 |
287 assertFalse(page.$.relaunch.hidden); | 287 assertFalse(page.$.relaunch.hidden); |
288 assertTrue(page.$.relaunchAndPowerwash.hidden); | 288 assertTrue(page.$.relaunchAndPowerwash.hidden); |
289 }); | 289 }); |
290 }); | 290 }); |
291 | 291 |
| 292 /** |
| 293 * Test that buttons update as a result of receiving a |
| 294 * 'target-channel-changed' event (normally fired from |
| 295 * <settings-channel-switcher-dialog>). |
| 296 */ |
| 297 test('ButtonsUpdate_TargetChannelChangedEvent', function() { |
| 298 browserProxy.setChannels(BrowserChannel.BETA, BrowserChannel.BETA); |
| 299 browserProxy.setUpdateStatus(UpdateStatus.NEARLY_UPDATED); |
| 300 |
| 301 return initNewPage().then(function() { |
| 302 assertFalse(page.$.relaunch.hidden); |
| 303 assertTrue(page.$.relaunchAndPowerwash.hidden); |
| 304 |
| 305 page.fire('target-channel-changed', BrowserChannel.DEV); |
| 306 assertFalse(page.$.relaunch.hidden); |
| 307 assertTrue(page.$.relaunchAndPowerwash.hidden); |
| 308 |
| 309 page.fire('target-channel-changed', BrowserChannel.STABLE); |
| 310 assertTrue(page.$.relaunch.hidden); |
| 311 assertFalse(page.$.relaunchAndPowerwash.hidden); |
| 312 }); |
| 313 }); |
| 314 |
292 test('RegulatoryInfo', function() { | 315 test('RegulatoryInfo', function() { |
293 var regulatoryInfo = null; | 316 var regulatoryInfo = null; |
294 | 317 |
295 /** | 318 /** |
296 * Checks the visibility of the "regulatory info" section. | 319 * Checks the visibility of the "regulatory info" section. |
297 * @param {boolean} isShowing Whether the section is expected to be | 320 * @param {boolean} isShowing Whether the section is expected to be |
298 * visible. | 321 * visible. |
299 * @return {!Promise} | 322 * @return {!Promise} |
300 */ | 323 */ |
301 function checkRegulatoryInfo(isShowing) { | 324 function checkRegulatoryInfo(isShowing) { |
(...skipping 17 matching lines...) Expand all Loading... |
319 browserProxy.setRegulatoryInfo(regulatoryInfo); | 342 browserProxy.setRegulatoryInfo(regulatoryInfo); |
320 return initNewPage(); | 343 return initNewPage(); |
321 }).then(function() { | 344 }).then(function() { |
322 return checkRegulatoryInfo(true); | 345 return checkRegulatoryInfo(true); |
323 }); | 346 }); |
324 }); | 347 }); |
325 } | 348 } |
326 | 349 |
327 if (!cr.isChromeOS) { | 350 if (!cr.isChromeOS) { |
328 /* | 351 /* |
329 * Test that the "Check for updates" button updates according to | 352 * Test that the "Relaunch" button updates according to incoming |
330 * incoming 'update-status-changed' events. | 353 * 'update-status-changed' events. |
331 */ | 354 */ |
332 test('ButtonsUpdate', function() { | 355 test('ButtonsUpdate', function() { |
333 var relaunch = page.$.relaunch; | 356 var relaunch = page.$.relaunch; |
334 assertTrue(!!relaunch); | 357 assertTrue(!!relaunch); |
335 | 358 |
336 fireStatusChanged(UpdateStatus.CHECKING); | 359 fireStatusChanged(UpdateStatus.CHECKING); |
337 assertTrue(relaunch.hidden); | 360 assertTrue(relaunch.hidden); |
338 | 361 |
339 fireStatusChanged(UpdateStatus.UPDATING); | 362 fireStatusChanged(UpdateStatus.UPDATING); |
340 assertTrue(relaunch.hidden); | 363 assertTrue(relaunch.hidden); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 suite('DetailedBuildInfoTest', function() { | 413 suite('DetailedBuildInfoTest', function() { |
391 var page = null; | 414 var page = null; |
392 var browserProxy = null; | 415 var browserProxy = null; |
393 | 416 |
394 setup(function() { | 417 setup(function() { |
395 browserProxy = new TestAboutPageBrowserProxy(); | 418 browserProxy = new TestAboutPageBrowserProxy(); |
396 settings.AboutPageBrowserProxyImpl.instance_ = browserProxy; | 419 settings.AboutPageBrowserProxyImpl.instance_ = browserProxy; |
397 PolymerTest.clearBody(); | 420 PolymerTest.clearBody(); |
398 }); | 421 }); |
399 | 422 |
400 teardown(function() { page.remove(); }); | 423 teardown(function() { |
| 424 page.remove(); |
| 425 page = null; |
| 426 }); |
401 | 427 |
402 test('Initialization', function() { | 428 test('Initialization', function() { |
403 var versionInfo = { | 429 var versionInfo = { |
404 arcVersion: 'dummyArcVersion', | 430 arcVersion: 'dummyArcVersion', |
405 osFirmware: 'dummyOsFirmware', | 431 osFirmware: 'dummyOsFirmware', |
406 osVersion: 'dummyOsVersion', | 432 osVersion: 'dummyOsVersion', |
407 }; | 433 }; |
408 browserProxy.setVersionInfo(versionInfo); | 434 browserProxy.setVersionInfo(versionInfo); |
409 | 435 |
410 page = document.createElement('settings-detailed-build-info'); | 436 page = document.createElement('settings-detailed-build-info'); |
411 document.body.appendChild(page); | 437 document.body.appendChild(page); |
412 | 438 |
413 return Promise.all([ | 439 return Promise.all([ |
414 browserProxy.whenCalled('pageReady'), | 440 browserProxy.whenCalled('pageReady'), |
415 browserProxy.whenCalled('getVersionInfo'), | 441 browserProxy.whenCalled('getVersionInfo'), |
416 browserProxy.whenCalled('getCurrentChannel'), | 442 browserProxy.whenCalled('getCurrentChannel'), |
417 ]).then(function() { | 443 ]).then(function() { |
418 assertEquals(versionInfo.arcVersion, page.$.arcVersion.textContent); | 444 assertEquals(versionInfo.arcVersion, page.$.arcVersion.textContent); |
419 assertEquals(versionInfo.osVersion, page.$.osVersion.textContent); | 445 assertEquals(versionInfo.osVersion, page.$.osVersion.textContent); |
420 assertEquals(versionInfo.osFirmware, page.$.osFirmware.textContent); | 446 assertEquals(versionInfo.osFirmware, page.$.osFirmware.textContent); |
421 }); | 447 }); |
422 }); | 448 }); |
| 449 |
| 450 /** |
| 451 * Checks whether the "change channel" button state (enabled/disabled) |
| 452 * correctly reflects whether the user is allowed to change channel (as |
| 453 * dictated by the browser via loadTimeData boolean). |
| 454 * @param {boolean} canChangeChannel Whether to simulate the case where |
| 455 * changing channels is allowed. |
| 456 */ |
| 457 function checkChangeChannelButton(canChangeChannel) { |
| 458 loadTimeData.overrideValues({ |
| 459 aboutCanChangeChannel: canChangeChannel |
| 460 }); |
| 461 page = document.createElement('settings-detailed-build-info'); |
| 462 document.body.appendChild(page); |
| 463 |
| 464 var changeChannelButton = page.$$('paper-button'); |
| 465 assertTrue(!!changeChannelButton); |
| 466 assertEquals(canChangeChannel, !changeChannelButton.disabled) |
| 467 } |
| 468 |
| 469 test('ChangeChannel_Enabled', function() { |
| 470 checkChangeChannelButton(true); |
| 471 }); |
| 472 |
| 473 test('ChangeChannel_Disabled', function() { |
| 474 checkChangeChannelButton(false); |
| 475 }); |
423 }); | 476 }); |
424 } | 477 } |
425 | 478 |
426 function registerChannelSwitcherDialogTests() { | 479 function registerChannelSwitcherDialogTests() { |
427 /** | 480 /** |
428 * Converts an event occurrence to a promise. | 481 * Converts an event occurrence to a promise. |
429 * @param {string} eventType | 482 * @param {string} eventType |
430 * @param {!HTMLElement} target | 483 * @param {!HTMLElement} target |
431 * @return {!Promise} A promise firing once the event occurs. | 484 * @return {!Promise} A promise firing once the event occurs. |
432 * TODO(dpapad); Share this code with certificate_manager_page_test.js | 485 * TODO(dpapad); Share this code with certificate_manager_page_test.js |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 registerTests: function() { | 587 registerTests: function() { |
535 if (cr.isChromeOS) { | 588 if (cr.isChromeOS) { |
536 registerDetailedBuildInfoTests(); | 589 registerDetailedBuildInfoTests(); |
537 registerChannelSwitcherDialogTests(); | 590 registerChannelSwitcherDialogTests(); |
538 } | 591 } |
539 registerAboutPageTests(); | 592 registerAboutPageTests(); |
540 }, | 593 }, |
541 registerOfficialBuildTests: registerOfficialBuildTests, | 594 registerOfficialBuildTests: registerOfficialBuildTests, |
542 }; | 595 }; |
543 }); | 596 }); |
OLD | NEW |