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 */ |
| 11 var TestAboutPageBrowserProxy = function() { | 11 var TestAboutPageBrowserProxy = function() { |
| 12 var methodNames = [ | 12 var methodNames = [ |
| 13 'pageReady', | 13 'pageReady', |
| 14 'refreshUpdateStatus', | 14 'refreshUpdateStatus', |
| 15 'openHelpPage', | 15 'openHelpPage', |
| 16 'openFeedbackDialog', | 16 'openFeedbackDialog', |
| 17 ]; | 17 ]; |
| 18 | 18 |
| 19 if (cr.isChromeOS) { | 19 if (cr.isChromeOS) { |
| 20 methodNames.push( | 20 methodNames.push( |
| 21 'getCurrentChannel', | 21 'getCurrentChannel', |
| 22 'getTargetChannel', | 22 'getTargetChannel', |
| 23 'getVersionInfo', | 23 'getVersionInfo', |
| 24 'getCanChangeChannel', | |
| 24 'getRegulatoryInfo', | 25 'getRegulatoryInfo', |
| 25 'setChannel'); | 26 'setChannel'); |
| 26 } | 27 } |
| 27 | 28 |
| 28 settings.TestBrowserProxy.call(this, methodNames); | 29 settings.TestBrowserProxy.call(this, methodNames); |
| 29 | 30 |
| 30 /** @private {!UpdateStatus} */ | 31 /** @private {!UpdateStatus} */ |
| 31 this.updateStatus_ = UpdateStatus.UPDATED; | 32 this.updateStatus_ = UpdateStatus.UPDATED; |
| 32 | 33 |
| 33 if (cr.isChromeOS) { | 34 if (cr.isChromeOS) { |
| 34 /** @type {!VersionInfo} */ | 35 /** @type {!VersionInfo} */ |
| 35 this.versionInfo_ = { | 36 this.versionInfo_ = { |
| 36 arcVersion: '', | 37 arcVersion: '', |
| 37 osFirmware: '', | 38 osFirmware: '', |
| 38 osVersion: '', | 39 osVersion: '', |
| 39 }; | 40 }; |
| 40 | 41 |
| 42 /** @type {boolean} */ | |
|
dpapad
2016/12/05 18:52:27
@private
stevenjb
2016/12/06 20:38:03
Done.
| |
| 43 this.canChangeChannel_ = true; | |
| 44 | |
| 41 /** @private {!BrowserChannel} */ | 45 /** @private {!BrowserChannel} */ |
| 42 this.currentChannel_ = BrowserChannel.BETA; | 46 this.currentChannel_ = BrowserChannel.BETA; |
| 43 | 47 |
| 44 /** @private {!BrowserChannel} */ | 48 /** @private {!BrowserChannel} */ |
| 45 this.targetChannel_ = BrowserChannel.BETA; | 49 this.targetChannel_ = BrowserChannel.BETA; |
| 46 | 50 |
| 47 /** @private {?RegulatoryInfo} */ | 51 /** @private {?RegulatoryInfo} */ |
| 48 this.regulatoryInfo_ = null; | 52 this.regulatoryInfo_ = null; |
| 49 } | 53 } |
| 50 }; | 54 }; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 81 this.methodCalled('openHelpPage'); | 85 this.methodCalled('openHelpPage'); |
| 82 }, | 86 }, |
| 83 }; | 87 }; |
| 84 | 88 |
| 85 if (cr.isChromeOS) { | 89 if (cr.isChromeOS) { |
| 86 /** @param {!VersionInfo} */ | 90 /** @param {!VersionInfo} */ |
| 87 TestAboutPageBrowserProxy.prototype.setVersionInfo = function(versionInfo) { | 91 TestAboutPageBrowserProxy.prototype.setVersionInfo = function(versionInfo) { |
| 88 this.versionInfo_ = versionInfo; | 92 this.versionInfo_ = versionInfo; |
| 89 }; | 93 }; |
| 90 | 94 |
| 95 /** @param {boolean} */ | |
| 96 TestAboutPageBrowserProxy.prototype.setCanChangeChannel = function( | |
| 97 canChangeChannel) { | |
| 98 this.canChangeChannel_ = canChangeChannel; | |
| 99 }; | |
| 100 | |
| 91 /** | 101 /** |
| 92 * @param {!BrowserChannel} current | 102 * @param {!BrowserChannel} current |
| 93 * @param {!BrowserChannel} target | 103 * @param {!BrowserChannel} target |
| 94 */ | 104 */ |
| 95 TestAboutPageBrowserProxy.prototype.setChannels = function( | 105 TestAboutPageBrowserProxy.prototype.setChannels = function( |
| 96 current, target) { | 106 current, target) { |
| 97 this.currentChannel_ = current; | 107 this.currentChannel_ = current; |
| 98 this.targetChannel_ = target; | 108 this.targetChannel_ = target; |
| 99 }; | 109 }; |
| 100 | 110 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 117 return Promise.resolve(this.targetChannel_); | 127 return Promise.resolve(this.targetChannel_); |
| 118 }; | 128 }; |
| 119 | 129 |
| 120 /** @override */ | 130 /** @override */ |
| 121 TestAboutPageBrowserProxy.prototype.getVersionInfo = function() { | 131 TestAboutPageBrowserProxy.prototype.getVersionInfo = function() { |
| 122 this.methodCalled('getVersionInfo'); | 132 this.methodCalled('getVersionInfo'); |
| 123 return Promise.resolve(this.versionInfo_); | 133 return Promise.resolve(this.versionInfo_); |
| 124 }; | 134 }; |
| 125 | 135 |
| 126 /** @override */ | 136 /** @override */ |
| 137 TestAboutPageBrowserProxy.prototype.getCanChangeChannel = function() { | |
| 138 this.methodCalled('getCanChangeChannel'); | |
| 139 return Promise.resolve(this.canChangeChannel_); | |
| 140 }; | |
| 141 | |
| 142 /** @override */ | |
| 127 TestAboutPageBrowserProxy.prototype.getRegulatoryInfo = function() { | 143 TestAboutPageBrowserProxy.prototype.getRegulatoryInfo = function() { |
| 128 this.methodCalled('getRegulatoryInfo'); | 144 this.methodCalled('getRegulatoryInfo'); |
| 129 return Promise.resolve(this.regulatoryInfo_); | 145 return Promise.resolve(this.regulatoryInfo_); |
| 130 }; | 146 }; |
| 131 | 147 |
| 132 /** @override */ | 148 /** @override */ |
| 133 TestAboutPageBrowserProxy.prototype.setChannel = function( | 149 TestAboutPageBrowserProxy.prototype.setChannel = function( |
| 134 channel, isPowerwashAllowed) { | 150 channel, isPowerwashAllowed) { |
| 135 this.methodCalled('setChannel', [channel, isPowerwashAllowed]); | 151 this.methodCalled('setChannel', [channel, isPowerwashAllowed]); |
| 136 }; | 152 }; |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 573 osVersion: 'dummyOsVersion', | 589 osVersion: 'dummyOsVersion', |
| 574 }; | 590 }; |
| 575 browserProxy.setVersionInfo(versionInfo); | 591 browserProxy.setVersionInfo(versionInfo); |
| 576 | 592 |
| 577 page = document.createElement('settings-detailed-build-info'); | 593 page = document.createElement('settings-detailed-build-info'); |
| 578 document.body.appendChild(page); | 594 document.body.appendChild(page); |
| 579 | 595 |
| 580 return Promise.all([ | 596 return Promise.all([ |
| 581 browserProxy.whenCalled('pageReady'), | 597 browserProxy.whenCalled('pageReady'), |
| 582 browserProxy.whenCalled('getVersionInfo'), | 598 browserProxy.whenCalled('getVersionInfo'), |
| 583 browserProxy.whenCalled('getCurrentChannel'), | 599 browserProxy.whenCalled('getTargetChannel'), |
| 584 ]).then(function() { | 600 ]).then(function() { |
| 585 assertEquals(versionInfo.arcVersion, page.$.arcVersion.textContent); | 601 assertEquals(versionInfo.arcVersion, page.$.arcVersion.textContent); |
| 586 assertEquals(versionInfo.osVersion, page.$.osVersion.textContent); | 602 assertEquals(versionInfo.osVersion, page.$.osVersion.textContent); |
| 587 assertEquals(versionInfo.osFirmware, page.$.osFirmware.textContent); | 603 assertEquals(versionInfo.osFirmware, page.$.osFirmware.textContent); |
| 588 }); | 604 }); |
| 589 }); | 605 }); |
| 590 | 606 |
| 591 /** | 607 /** |
| 592 * Checks whether the "change channel" button state (enabled/disabled) | 608 * Checks whether the "change channel" button state (enabled/disabled) |
| 593 * correctly reflects whether the user is allowed to change channel (as | 609 * correctly reflects whether the user is allowed to change channel (as |
| 594 * dictated by the browser via loadTimeData boolean). | 610 * dictated by the browser via loadTimeData boolean). |
| 595 * @param {boolean} canChangeChannel Whether to simulate the case where | 611 * @param {boolean} canChangeChannel Whether to simulate the case where |
| 596 * changing channels is allowed. | 612 * changing channels is allowed. |
|
dpapad
2016/12/05 18:52:27
@return {!Promise} missing
| |
| 597 */ | 613 */ |
| 598 function checkChangeChannelButton(canChangeChannel) { | 614 function checkChangeChannelButton(canChangeChannel) { |
| 599 loadTimeData.overrideValues({ | 615 browserProxy.setCanChangeChannel(canChangeChannel); |
| 600 aboutCanChangeChannel: canChangeChannel | |
| 601 }); | |
| 602 page = document.createElement('settings-detailed-build-info'); | 616 page = document.createElement('settings-detailed-build-info'); |
| 603 document.body.appendChild(page); | 617 document.body.appendChild(page); |
| 604 | 618 return Promise.all([ |
| 605 var changeChannelButton = page.$$('paper-button'); | 619 browserProxy.whenCalled('getCanChangeChannel'), |
|
dpapad
2016/12/05 18:52:27
Why use Promise.all() for a single Promise?
stevenjb
2016/12/06 20:38:03
Done.
| |
| 606 assertTrue(!!changeChannelButton); | 620 ]).then(function() { |
| 607 assertEquals(canChangeChannel, !changeChannelButton.disabled) | 621 var changeChannelButton = page.$$('paper-button'); |
| 622 assertTrue(!!changeChannelButton); | |
| 623 assertEquals(canChangeChannel, !changeChannelButton.disabled); | |
| 624 }); | |
| 608 } | 625 } |
| 609 | 626 |
| 610 test('ChangeChannel_Enabled', function() { | 627 test('ChangeChannel_Enabled', function() { |
| 611 checkChangeChannelButton(true); | 628 return checkChangeChannelButton(true); |
| 612 }); | 629 }); |
| 613 | 630 |
| 614 test('ChangeChannel_Disabled', function() { | 631 test('ChangeChannel_Disabled', function() { |
| 615 checkChangeChannelButton(false); | 632 return checkChangeChannelButton(false); |
| 616 }); | 633 }); |
| 617 }); | 634 }); |
| 618 } | 635 } |
| 619 | 636 |
| 620 function registerChannelSwitcherDialogTests() { | 637 function registerChannelSwitcherDialogTests() { |
| 621 suite('ChannelSwitcherDialogTest', function() { | 638 suite('ChannelSwitcherDialogTest', function() { |
| 622 var dialog = null; | 639 var dialog = null; |
| 623 var radioButtons = null; | 640 var radioButtons = null; |
| 624 var browserProxy = null; | 641 var browserProxy = null; |
| 625 var currentChannel = BrowserChannel.BETA; | 642 var currentChannel = BrowserChannel.BETA; |
| 626 | 643 |
| 627 setup(function() { | 644 setup(function() { |
| 628 browserProxy = new TestAboutPageBrowserProxy(); | 645 browserProxy = new TestAboutPageBrowserProxy(); |
| 629 browserProxy.setChannels(currentChannel, currentChannel); | 646 browserProxy.setChannels(currentChannel, currentChannel); |
| 630 settings.AboutPageBrowserProxyImpl.instance_ = browserProxy; | 647 settings.AboutPageBrowserProxyImpl.instance_ = browserProxy; |
| 631 PolymerTest.clearBody(); | 648 PolymerTest.clearBody(); |
| 632 dialog = document.createElement('settings-channel-switcher-dialog'); | 649 dialog = document.createElement('settings-channel-switcher-dialog'); |
| 633 document.body.appendChild(dialog); | 650 document.body.appendChild(dialog); |
| 634 | 651 |
| 635 radioButtons = dialog.shadowRoot.querySelectorAll( | 652 radioButtons = dialog.shadowRoot.querySelectorAll( |
| 636 'paper-radio-button'); | 653 'paper-radio-button'); |
| 637 assertEquals(3, radioButtons.length); | 654 assertEquals(3, radioButtons.length); |
| 638 return browserProxy.whenCalled('getCurrentChannel'); | 655 return browserProxy.whenCalled('getTargetChannel'); |
| 639 }); | 656 }); |
| 640 | 657 |
| 641 teardown(function() { dialog.remove(); }); | 658 teardown(function() { dialog.remove(); }); |
| 642 | 659 |
| 643 test('Initialization', function() { | 660 test('Initialization', function() { |
| 644 var radioGroup = dialog.$$('paper-radio-group'); | 661 var radioGroup = dialog.$$('paper-radio-group'); |
| 645 assertTrue(!!radioGroup); | 662 assertTrue(!!radioGroup); |
| 646 assertTrue(!!dialog.$.warning); | 663 assertTrue(!!dialog.$.warning); |
| 647 assertTrue(!!dialog.$.changeChannel); | 664 assertTrue(!!dialog.$.changeChannel); |
| 648 assertTrue(!!dialog.$.changeChannelAndPowerwash); | 665 assertTrue(!!dialog.$.changeChannelAndPowerwash); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 714 registerTests: function() { | 731 registerTests: function() { |
| 715 if (cr.isChromeOS) { | 732 if (cr.isChromeOS) { |
| 716 registerDetailedBuildInfoTests(); | 733 registerDetailedBuildInfoTests(); |
| 717 registerChannelSwitcherDialogTests(); | 734 registerChannelSwitcherDialogTests(); |
| 718 } | 735 } |
| 719 registerAboutPageTests(); | 736 registerAboutPageTests(); |
| 720 }, | 737 }, |
| 721 registerOfficialBuildTests: registerOfficialBuildTests, | 738 registerOfficialBuildTests: registerOfficialBuildTests, |
| 722 }; | 739 }; |
| 723 }); | 740 }); |
| OLD | NEW |