Chromium Code Reviews| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 136 |
| 137 | 137 |
| 138 function registerAboutPageTests() { | 138 function registerAboutPageTests() { |
| 139 /** @param {!UpdateStatus} status */ | 139 /** @param {!UpdateStatus} status */ |
| 140 function fireStatusChanged(status) { | 140 function fireStatusChanged(status) { |
| 141 cr.webUIListenerCallback('update-status-changed', {status: status}); | 141 cr.webUIListenerCallback('update-status-changed', {status: status}); |
| 142 } | 142 } |
| 143 | 143 |
| 144 suite('AboutPageTest', function() { | 144 suite('AboutPageTest', function() { |
| 145 var page = null; | 145 var page = null; |
| 146 var browserProxy = null; | 146 |
| 147 /** @type {?settings.TestAboutPageBrowserProxy} */ | |
| 148 var aboutBrowserProxy = null; | |
|
tommycli
2016/06/15 16:02:35
nit: in about_page.js this is just called browserP
dpapad
2016/06/15 17:30:19
Done, renamed it accordingly in about_page.js.
| |
| 149 | |
| 150 /** @type {?settings.TestLifetimeBrowserProxy} */ | |
| 151 var lifetimeBrowserProxy = null; | |
| 152 | |
| 147 var SPINNER_ICON = 'chrome://resources/images/throbber_small.svg'; | 153 var SPINNER_ICON = 'chrome://resources/images/throbber_small.svg'; |
| 148 | 154 |
| 149 setup(function() { | 155 setup(function() { |
| 150 browserProxy = new TestAboutPageBrowserProxy(); | 156 lifetimeBrowserProxy = new settings.TestLifetimeBrowserProxy(); |
| 151 settings.AboutPageBrowserProxyImpl.instance_ = browserProxy; | 157 settings.LifetimeBrowserProxyImpl.instance_ = lifetimeBrowserProxy; |
| 158 | |
| 159 aboutBrowserProxy = new TestAboutPageBrowserProxy(); | |
| 160 settings.AboutPageBrowserProxyImpl.instance_ = aboutBrowserProxy; | |
| 152 return initNewPage(); | 161 return initNewPage(); |
| 153 }); | 162 }); |
| 154 | 163 |
| 155 teardown(function() { | 164 teardown(function() { |
| 156 page.remove(); | 165 page.remove(); |
| 157 page = null; | 166 page = null; |
| 158 loadTimeData.overrideValues({ | 167 loadTimeData.overrideValues({ |
| 159 aboutObsoleteNowOrSoon: false, | 168 aboutObsoleteNowOrSoon: false, |
| 160 aboutObsoleteEndOfTheLine: false, | 169 aboutObsoleteEndOfTheLine: false, |
| 161 }); | 170 }); |
| 162 }); | 171 }); |
| 163 | 172 |
| 164 /** @return {!Promise} */ | 173 /** @return {!Promise} */ |
| 165 function initNewPage() { | 174 function initNewPage() { |
| 166 browserProxy.reset(); | 175 aboutBrowserProxy.reset(); |
| 176 lifetimeBrowserProxy.reset(); | |
| 167 PolymerTest.clearBody(); | 177 PolymerTest.clearBody(); |
| 168 page = document.createElement('settings-about-page'); | 178 page = document.createElement('settings-about-page'); |
| 169 document.body.appendChild(page); | 179 document.body.appendChild(page); |
| 170 return browserProxy.whenCalled('refreshUpdateStatus'); | 180 return aboutBrowserProxy.whenCalled('refreshUpdateStatus'); |
| 171 } | 181 } |
| 172 | 182 |
| 173 /** | 183 /** |
| 174 * Test that the status icon and status message update according to | 184 * Test that the status icon and status message update according to |
| 175 * incoming 'update-status-changed' events. | 185 * incoming 'update-status-changed' events. |
| 176 */ | 186 */ |
| 177 test('IconAndMessageUpdates', function() { | 187 test('IconAndMessageUpdates', function() { |
| 178 var icon = page.$$('iron-icon'); | 188 var icon = page.$$('iron-icon'); |
| 179 assertTrue(!!icon); | 189 assertTrue(!!icon); |
| 180 var statusMessageEl = page.$.updateStatusMessage; | 190 var statusMessageEl = page.$.updateStatusMessage; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 assertTrue(page.$.updateStatusMessage.hidden); | 295 assertTrue(page.$.updateStatusMessage.hidden); |
| 286 | 296 |
| 287 fireStatusChanged(UpdateStatus.UPDATED); | 297 fireStatusChanged(UpdateStatus.UPDATED); |
| 288 assertEquals(null, icon.src); | 298 assertEquals(null, icon.src); |
| 289 assertEquals('settings:error', icon.icon); | 299 assertEquals('settings:error', icon.icon); |
| 290 assertFalse(page.$.deprecationWarning.hidden); | 300 assertFalse(page.$.deprecationWarning.hidden); |
| 291 assertTrue(page.$.updateStatusMessage.hidden); | 301 assertTrue(page.$.updateStatusMessage.hidden); |
| 292 }); | 302 }); |
| 293 }); | 303 }); |
| 294 | 304 |
| 305 test('Relaunch', function() { | |
| 306 var relaunch = page.$.relaunch; | |
| 307 assertTrue(!!relaunch); | |
| 308 assertTrue(relaunch.hidden); | |
| 309 | |
| 310 fireStatusChanged(UpdateStatus.NEARLY_UPDATED); | |
| 311 assertFalse(relaunch.hidden); | |
| 312 | |
| 313 MockInteractions.tap(relaunch); | |
| 314 return lifetimeBrowserProxy.whenCalled('relaunch'); | |
| 315 }); | |
| 316 | |
| 295 if (cr.isChromeOS) { | 317 if (cr.isChromeOS) { |
| 296 /** | 318 /** |
| 297 * Test that all buttons update according to incoming | 319 * Test that all buttons update according to incoming |
| 298 * 'update-status-changed' events for the case where target and current | 320 * 'update-status-changed' events for the case where target and current |
| 299 * channel are the same. | 321 * channel are the same. |
| 300 */ | 322 */ |
| 301 test('ButtonsUpdate_SameChannel', function() { | 323 test('ButtonsUpdate_SameChannel', function() { |
| 302 var relaunch = page.$.relaunch; | 324 var relaunch = page.$.relaunch; |
| 303 var checkForUpdates = page.$.checkForUpdates; | 325 var checkForUpdates = page.$.checkForUpdates; |
| 304 var relaunchAndPowerwash = page.$.relaunchAndPowerwash; | 326 var relaunchAndPowerwash = page.$.relaunchAndPowerwash; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN); | 367 fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN); |
| 346 assertAllHidden(); | 368 assertAllHidden(); |
| 347 }); | 369 }); |
| 348 | 370 |
| 349 /** | 371 /** |
| 350 * Test that buttons update according to incoming | 372 * Test that buttons update according to incoming |
| 351 * 'update-status-changed' events for the case where the target channel | 373 * 'update-status-changed' events for the case where the target channel |
| 352 * is more stable than current channel. | 374 * is more stable than current channel. |
| 353 */ | 375 */ |
| 354 test('ButtonsUpdate_BetaToStable', function() { | 376 test('ButtonsUpdate_BetaToStable', function() { |
| 355 browserProxy.setChannels(BrowserChannel.BETA, BrowserChannel.STABLE); | 377 aboutBrowserProxy.setChannels( |
| 356 browserProxy.setUpdateStatus(UpdateStatus.NEARLY_UPDATED); | 378 BrowserChannel.BETA, BrowserChannel.STABLE); |
| 379 aboutBrowserProxy.setUpdateStatus(UpdateStatus.NEARLY_UPDATED); | |
| 357 | 380 |
| 358 return initNewPage().then(function() { | 381 return initNewPage().then(function() { |
| 359 assertTrue(!!page.$.relaunch); | 382 assertTrue(!!page.$.relaunch); |
| 360 assertTrue(!!page.$.relaunchAndPowerwash); | 383 assertTrue(!!page.$.relaunchAndPowerwash); |
| 361 | 384 |
| 362 assertTrue(page.$.relaunch.hidden); | 385 assertTrue(page.$.relaunch.hidden); |
| 363 assertFalse(page.$.relaunchAndPowerwash.hidden); | 386 assertFalse(page.$.relaunchAndPowerwash.hidden); |
| 387 | |
| 388 MockInteractions.tap(page.$.relaunchAndPowerwash); | |
| 389 return lifetimeBrowserProxy.whenCalled('factoryReset'); | |
| 364 }); | 390 }); |
| 365 }); | 391 }); |
| 366 | 392 |
| 367 /** | 393 /** |
| 368 * Test that buttons update according to incoming | 394 * Test that buttons update according to incoming |
| 369 * 'update-status-changed' events for the case where the target channel | 395 * 'update-status-changed' events for the case where the target channel |
| 370 * is less stable than current channel. | 396 * is less stable than current channel. |
| 371 */ | 397 */ |
| 372 test('ButtonsUpdate_StableToBeta', function() { | 398 test('ButtonsUpdate_StableToBeta', function() { |
| 373 browserProxy.setChannels(BrowserChannel.STABLE, BrowserChannel.BETA); | 399 aboutBrowserProxy.setChannels( |
| 374 browserProxy.setUpdateStatus(UpdateStatus.NEARLY_UPDATED); | 400 BrowserChannel.STABLE, BrowserChannel.BETA); |
| 401 aboutBrowserProxy.setUpdateStatus(UpdateStatus.NEARLY_UPDATED); | |
| 375 | 402 |
| 376 return initNewPage().then(function() { | 403 return initNewPage().then(function() { |
| 377 assertTrue(!!page.$.relaunch); | 404 assertTrue(!!page.$.relaunch); |
| 378 assertTrue(!!page.$.relaunchAndPowerwash); | 405 assertTrue(!!page.$.relaunchAndPowerwash); |
| 379 | 406 |
| 380 assertFalse(page.$.relaunch.hidden); | 407 assertFalse(page.$.relaunch.hidden); |
| 381 assertTrue(page.$.relaunchAndPowerwash.hidden); | 408 assertTrue(page.$.relaunchAndPowerwash.hidden); |
| 409 | |
| 410 MockInteractions.tap(page.$.relaunch); | |
| 411 return lifetimeBrowserProxy.whenCalled('relaunch'); | |
| 382 }); | 412 }); |
| 383 }); | 413 }); |
| 384 | 414 |
| 385 /** | 415 /** |
| 386 * Test that buttons update as a result of receiving a | 416 * Test that buttons update as a result of receiving a |
| 387 * 'target-channel-changed' event (normally fired from | 417 * 'target-channel-changed' event (normally fired from |
| 388 * <settings-channel-switcher-dialog>). | 418 * <settings-channel-switcher-dialog>). |
| 389 */ | 419 */ |
| 390 test('ButtonsUpdate_TargetChannelChangedEvent', function() { | 420 test('ButtonsUpdate_TargetChannelChangedEvent', function() { |
| 391 browserProxy.setChannels(BrowserChannel.BETA, BrowserChannel.BETA); | 421 aboutBrowserProxy.setChannels( |
| 392 browserProxy.setUpdateStatus(UpdateStatus.NEARLY_UPDATED); | 422 BrowserChannel.BETA, BrowserChannel.BETA); |
| 423 aboutBrowserProxy.setUpdateStatus(UpdateStatus.NEARLY_UPDATED); | |
| 393 | 424 |
| 394 return initNewPage().then(function() { | 425 return initNewPage().then(function() { |
| 395 assertFalse(page.$.relaunch.hidden); | 426 assertFalse(page.$.relaunch.hidden); |
| 396 assertTrue(page.$.relaunchAndPowerwash.hidden); | 427 assertTrue(page.$.relaunchAndPowerwash.hidden); |
| 397 | 428 |
| 398 page.fire('target-channel-changed', BrowserChannel.DEV); | 429 page.fire('target-channel-changed', BrowserChannel.DEV); |
| 399 assertFalse(page.$.relaunch.hidden); | 430 assertFalse(page.$.relaunch.hidden); |
| 400 assertTrue(page.$.relaunchAndPowerwash.hidden); | 431 assertTrue(page.$.relaunchAndPowerwash.hidden); |
| 401 | 432 |
| 402 page.fire('target-channel-changed', BrowserChannel.STABLE); | 433 page.fire('target-channel-changed', BrowserChannel.STABLE); |
| 403 assertTrue(page.$.relaunch.hidden); | 434 assertTrue(page.$.relaunch.hidden); |
| 404 assertFalse(page.$.relaunchAndPowerwash.hidden); | 435 assertFalse(page.$.relaunchAndPowerwash.hidden); |
| 405 }); | 436 }); |
| 406 }); | 437 }); |
| 407 | 438 |
| 408 test('RegulatoryInfo', function() { | 439 test('RegulatoryInfo', function() { |
| 409 var regulatoryInfo = null; | 440 var regulatoryInfo = null; |
| 410 | 441 |
| 411 /** | 442 /** |
| 412 * Checks the visibility of the "regulatory info" section. | 443 * Checks the visibility of the "regulatory info" section. |
| 413 * @param {boolean} isShowing Whether the section is expected to be | 444 * @param {boolean} isShowing Whether the section is expected to be |
| 414 * visible. | 445 * visible. |
| 415 * @return {!Promise} | 446 * @return {!Promise} |
| 416 */ | 447 */ |
| 417 function checkRegulatoryInfo(isShowing) { | 448 function checkRegulatoryInfo(isShowing) { |
| 418 return browserProxy.whenCalled('getRegulatoryInfo').then( | 449 return aboutBrowserProxy.whenCalled('getRegulatoryInfo').then( |
| 419 function() { | 450 function() { |
| 420 var regulatoryInfoEl = page.$.regulatoryInfo; | 451 var regulatoryInfoEl = page.$.regulatoryInfo; |
| 421 assertTrue(!!regulatoryInfoEl); | 452 assertTrue(!!regulatoryInfoEl); |
| 422 assertEquals(isShowing, !regulatoryInfoEl.hidden); | 453 assertEquals(isShowing, !regulatoryInfoEl.hidden); |
| 423 | 454 |
| 424 if (isShowing) { | 455 if (isShowing) { |
| 425 var img = regulatoryInfoEl.querySelector('img'); | 456 var img = regulatoryInfoEl.querySelector('img'); |
| 426 assertTrue(!!img); | 457 assertTrue(!!img); |
| 427 assertEquals(regulatoryInfo.text, img.getAttribute('alt')); | 458 assertEquals(regulatoryInfo.text, img.getAttribute('alt')); |
| 428 assertEquals(regulatoryInfo.url, img.getAttribute('src')); | 459 assertEquals(regulatoryInfo.url, img.getAttribute('src')); |
| 429 } | 460 } |
| 430 }); | 461 }); |
| 431 } | 462 } |
| 432 | 463 |
| 433 return checkRegulatoryInfo(false).then(function() { | 464 return checkRegulatoryInfo(false).then(function() { |
| 434 regulatoryInfo = {text: 'foo', url: 'bar'}; | 465 regulatoryInfo = {text: 'foo', url: 'bar'}; |
| 435 browserProxy.setRegulatoryInfo(regulatoryInfo); | 466 aboutBrowserProxy.setRegulatoryInfo(regulatoryInfo); |
| 436 return initNewPage(); | 467 return initNewPage(); |
| 437 }).then(function() { | 468 }).then(function() { |
| 438 return checkRegulatoryInfo(true); | 469 return checkRegulatoryInfo(true); |
| 439 }); | 470 }); |
| 440 }); | 471 }); |
| 441 } | 472 } |
| 442 | 473 |
| 443 if (!cr.isChromeOS) { | 474 if (!cr.isChromeOS) { |
| 444 /* | 475 /* |
| 445 * Test that the "Relaunch" button updates according to incoming | 476 * Test that the "Relaunch" button updates according to incoming |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 468 assertTrue(relaunch.hidden); | 499 assertTrue(relaunch.hidden); |
| 469 | 500 |
| 470 fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN); | 501 fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN); |
| 471 assertTrue(relaunch.hidden); | 502 assertTrue(relaunch.hidden); |
| 472 }); | 503 }); |
| 473 } | 504 } |
| 474 | 505 |
| 475 test('GetHelp', function() { | 506 test('GetHelp', function() { |
| 476 assertTrue(!!page.$.help); | 507 assertTrue(!!page.$.help); |
| 477 MockInteractions.tap(page.$.help); | 508 MockInteractions.tap(page.$.help); |
| 478 return browserProxy.whenCalled('openHelpPage'); | 509 return aboutBrowserProxy.whenCalled('openHelpPage'); |
| 479 }); | 510 }); |
| 480 }); | 511 }); |
| 481 } | 512 } |
| 482 | 513 |
| 483 function registerOfficialBuildTests() { | 514 function registerOfficialBuildTests() { |
| 484 suite('AboutPageTest_OfficialBuild', function() { | 515 suite('AboutPageTest_OfficialBuild', function() { |
| 485 var page = null; | 516 var page = null; |
| 486 var browserProxy = null; | 517 var browserProxy = null; |
| 487 | 518 |
| 488 setup(function() { | 519 setup(function() { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 680 registerTests: function() { | 711 registerTests: function() { |
| 681 if (cr.isChromeOS) { | 712 if (cr.isChromeOS) { |
| 682 registerDetailedBuildInfoTests(); | 713 registerDetailedBuildInfoTests(); |
| 683 registerChannelSwitcherDialogTests(); | 714 registerChannelSwitcherDialogTests(); |
| 684 } | 715 } |
| 685 registerAboutPageTests(); | 716 registerAboutPageTests(); |
| 686 }, | 717 }, |
| 687 registerOfficialBuildTests: registerOfficialBuildTests, | 718 registerOfficialBuildTests: registerOfficialBuildTests, |
| 688 }; | 719 }; |
| 689 }); | 720 }); |
| OLD | NEW |