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 'getChannelInfo', | 21 'getChannelInfo', |
22 'getVersionInfo', | 22 'getVersionInfo', |
23 'getRegulatoryInfo', | 23 'getRegulatoryInfo', |
24 'setChannel'); | 24 'setChannel'); |
25 } | 25 } |
26 | 26 |
| 27 if (cr.isMac) |
| 28 methodNames.push('promoteUpdater'); |
| 29 |
27 settings.TestBrowserProxy.call(this, methodNames); | 30 settings.TestBrowserProxy.call(this, methodNames); |
28 | 31 |
29 /** @private {!UpdateStatus} */ | 32 /** @private {!UpdateStatus} */ |
30 this.updateStatus_ = UpdateStatus.UPDATED; | 33 this.updateStatus_ = UpdateStatus.UPDATED; |
31 | 34 |
32 if (cr.isChromeOS) { | 35 if (cr.isChromeOS) { |
33 /** @private {!VersionInfo} */ | 36 /** @private {!VersionInfo} */ |
34 this.versionInfo_ = { | 37 this.versionInfo_ = { |
35 arcVersion: '', | 38 arcVersion: '', |
36 osFirmware: '', | 39 osFirmware: '', |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 openFeedbackDialog: function() { | 78 openFeedbackDialog: function() { |
76 this.methodCalled('openFeedbackDialog'); | 79 this.methodCalled('openFeedbackDialog'); |
77 }, | 80 }, |
78 | 81 |
79 /** @override */ | 82 /** @override */ |
80 openHelpPage: function() { | 83 openHelpPage: function() { |
81 this.methodCalled('openHelpPage'); | 84 this.methodCalled('openHelpPage'); |
82 }, | 85 }, |
83 }; | 86 }; |
84 | 87 |
| 88 if (cr.isMac) { |
| 89 /** @override */ |
| 90 TestAboutPageBrowserProxy.prototype.promoteUpdater = function() { |
| 91 this.methodCalled('promoteUpdater'); |
| 92 }; |
| 93 } |
| 94 |
85 if (cr.isChromeOS) { | 95 if (cr.isChromeOS) { |
86 /** @param {!VersionInfo} */ | 96 /** @param {!VersionInfo} */ |
87 TestAboutPageBrowserProxy.prototype.setVersionInfo = function(versionInfo) { | 97 TestAboutPageBrowserProxy.prototype.setVersionInfo = function(versionInfo) { |
88 this.versionInfo_ = versionInfo; | 98 this.versionInfo_ = versionInfo; |
89 }; | 99 }; |
90 | 100 |
91 /** @param {boolean} canChangeChannel */ | 101 /** @param {boolean} canChangeChannel */ |
92 TestAboutPageBrowserProxy.prototype.setCanChangeChannel = function( | 102 TestAboutPageBrowserProxy.prototype.setCanChangeChannel = function( |
93 canChangeChannel) { | 103 canChangeChannel) { |
94 this.channelInfo_.canChangeChannel = canChangeChannel; | 104 this.channelInfo_.canChangeChannel = canChangeChannel; |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 PolymerTest.clearBody(); | 560 PolymerTest.clearBody(); |
551 page = document.createElement('settings-about-page'); | 561 page = document.createElement('settings-about-page'); |
552 document.body.appendChild(page); | 562 document.body.appendChild(page); |
553 }); | 563 }); |
554 | 564 |
555 test('ReportAnIssue', function() { | 565 test('ReportAnIssue', function() { |
556 assertTrue(!!page.$.reportIssue); | 566 assertTrue(!!page.$.reportIssue); |
557 MockInteractions.tap(page.$.reportIssue); | 567 MockInteractions.tap(page.$.reportIssue); |
558 return browserProxy.whenCalled('openFeedbackDialog'); | 568 return browserProxy.whenCalled('openFeedbackDialog'); |
559 }); | 569 }); |
| 570 |
| 571 if (cr.isMac) { |
| 572 /** |
| 573 * A list of possible scenarios for the promoteUpdater. |
| 574 * @enum {!PromoteUpdaterStatus} |
| 575 */ |
| 576 var PromoStatusScenarios = { |
| 577 CANT_PROMOTE: { |
| 578 hidden: true, |
| 579 disabled: true, |
| 580 actionable: false, |
| 581 }, |
| 582 CAN_PROMOTE: { |
| 583 hidden: false, |
| 584 disabled: false, |
| 585 actionable: true, |
| 586 }, |
| 587 IN_BETWEEN: { |
| 588 hidden: false, |
| 589 disabled: true, |
| 590 actionable: true, |
| 591 }, |
| 592 PROMOTED: { |
| 593 hidden: false, |
| 594 disabled: true, |
| 595 actionable: false, |
| 596 }, |
| 597 }; |
| 598 |
| 599 /** |
| 600 * @param {!PromoteUpdaterStatus} status |
| 601 */ |
| 602 function firePromoteUpdaterStatusChanged(status) { |
| 603 cr.webUIListenerCallback('promotion-state-changed', status); |
| 604 } |
| 605 |
| 606 /** |
| 607 * Tests that the button's states are wired up to the status correctly. |
| 608 */ |
| 609 test('PromoteUpdaterButtonCorrectStates', function() { |
| 610 var item = page.$$('#promoteUpdater'); |
| 611 var arrow = page.$$('#promoteUpdater button'); |
| 612 assertFalse(!!item); |
| 613 assertFalse(!!arrow); |
| 614 |
| 615 firePromoteUpdaterStatusChanged(PromoStatusScenarios.CANT_PROMOTE); |
| 616 Polymer.dom.flush(); |
| 617 item = page.$$('#promoteUpdater'); |
| 618 arrow = page.$$('#promoteUpdater button'); |
| 619 assertFalse(!!item); |
| 620 assertFalse(!!arrow); |
| 621 |
| 622 firePromoteUpdaterStatusChanged(PromoStatusScenarios.CAN_PROMOTE); |
| 623 Polymer.dom.flush(); |
| 624 |
| 625 item = page.$$('#promoteUpdater'); |
| 626 assertTrue(!!item); |
| 627 assertFalse(item.hasAttribute('disabled')); |
| 628 assertTrue(item.hasAttribute('actionable')); |
| 629 |
| 630 arrow = page.$$('#promoteUpdater button'); |
| 631 assertTrue(!!arrow); |
| 632 assertFalse(arrow.hidden); |
| 633 assertFalse(arrow.hasAttribute('disabled')); |
| 634 |
| 635 firePromoteUpdaterStatusChanged(PromoStatusScenarios.IN_BETWEEN); |
| 636 Polymer.dom.flush(); |
| 637 item = page.$$('#promoteUpdater'); |
| 638 assertTrue(!!item); |
| 639 assertTrue(item.hasAttribute('disabled')); |
| 640 assertTrue(item.hasAttribute('actionable')); |
| 641 |
| 642 arrow = page.$$('#promoteUpdater button'); |
| 643 assertTrue(!!arrow); |
| 644 assertFalse(arrow.hidden); |
| 645 assertTrue(arrow.hasAttribute('disabled')); |
| 646 |
| 647 firePromoteUpdaterStatusChanged(PromoStatusScenarios.PROMOTED); |
| 648 Polymer.dom.flush(); |
| 649 item = page.$$('#promoteUpdater'); |
| 650 assertTrue(!!item); |
| 651 assertTrue(item.hasAttribute('disabled')); |
| 652 assertFalse(item.hasAttribute('actionable')); |
| 653 |
| 654 arrow = page.$$('#promoteUpdater button'); |
| 655 assertTrue(!!arrow); |
| 656 assertTrue(arrow.hidden); |
| 657 assertTrue(arrow.hasAttribute('disabled')); |
| 658 }); |
| 659 |
| 660 test('PromoteUpdaterButtonWorksWhenEnabled', function() { |
| 661 firePromoteUpdaterStatusChanged(PromoStatusScenarios.CAN_PROMOTE); |
| 662 Polymer.dom.flush(); |
| 663 var item = page.$$('#promoteUpdater'); |
| 664 assertTrue(!!item); |
| 665 |
| 666 MockInteractions.tap(item); |
| 667 |
| 668 return browserProxy.whenCalled('promoteUpdater'); |
| 669 }); |
| 670 } |
560 }); | 671 }); |
561 } | 672 } |
562 | 673 |
563 if (cr.isChromeOS) { | 674 if (cr.isChromeOS) { |
564 function registerDetailedBuildInfoTests() { | 675 function registerDetailedBuildInfoTests() { |
565 suite('DetailedBuildInfoTest', function() { | 676 suite('DetailedBuildInfoTest', function() { |
566 var page = null; | 677 var page = null; |
567 var browserProxy = null; | 678 var browserProxy = null; |
568 | 679 |
569 setup(function() { | 680 setup(function() { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 registerTests: function() { | 840 registerTests: function() { |
730 if (cr.isChromeOS) { | 841 if (cr.isChromeOS) { |
731 registerDetailedBuildInfoTests(); | 842 registerDetailedBuildInfoTests(); |
732 registerChannelSwitcherDialogTests(); | 843 registerChannelSwitcherDialogTests(); |
733 } | 844 } |
734 registerAboutPageTests(); | 845 registerAboutPageTests(); |
735 }, | 846 }, |
736 registerOfficialBuildTests: registerOfficialBuildTests, | 847 registerOfficialBuildTests: registerOfficialBuildTests, |
737 }; | 848 }; |
738 }); | 849 }); |
OLD | NEW |