Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/test/data/webui/settings/about_page_tests.js

Issue 1987813004: MD Settings: About page, implementing update status. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 settings.TestBrowserProxy.call(this, [ 12 settings.TestBrowserProxy.call(this, [
13 'pageReady', 13 'pageReady',
14 'refreshUpdateStatus', 14 'refreshUpdateStatus',
15 'openHelpPage', 15 'openHelpPage',
16 'openFeedbackDialog', 16 'openFeedbackDialog',
17 'getCurrentChannel', 17 'getCurrentChannel',
18 'getTargetChannel',
18 'getVersionInfo', 19 'getVersionInfo',
19 ]); 20 ]);
20 21
21 /** @type {!VersionInfo} */ 22 /** @type {!VersionInfo} */
22 this.versionInfo_ = { 23 this.versionInfo_ = {
23 arcVersion: '', 24 arcVersion: '',
24 osFirmware: '', 25 osFirmware: '',
25 osVersion: '', 26 osVersion: '',
26 }; 27 };
27 }; 28 };
(...skipping 16 matching lines...) Expand all
44 this.methodCalled('refreshUpdateStatus'); 45 this.methodCalled('refreshUpdateStatus');
45 }, 46 },
46 47
47 /** @override */ 48 /** @override */
48 getCurrentChannel: function() { 49 getCurrentChannel: function() {
49 this.methodCalled('getCurrentChannel'); 50 this.methodCalled('getCurrentChannel');
50 return Promise.resolve(BrowserChannel.BETA); 51 return Promise.resolve(BrowserChannel.BETA);
51 }, 52 },
52 53
53 /** @override */ 54 /** @override */
55 getTargetChannel: function() {
56 this.methodCalled('getTargetChannel');
57 return Promise.resolve(BrowserChannel.BETA);
58 },
59
60 /** @override */
54 getVersionInfo: function() { 61 getVersionInfo: function() {
55 this.methodCalled('getVersionInfo'); 62 this.methodCalled('getVersionInfo');
56 return Promise.resolve(this.versionInfo_); 63 return Promise.resolve(this.versionInfo_);
57 }, 64 },
58 65
59 /** @override */ 66 /** @override */
60 openFeedbackDialog: function() { 67 openFeedbackDialog: function() {
61 this.methodCalled('openFeedbackDialog'); 68 this.methodCalled('openFeedbackDialog');
62 }, 69 },
63 70
64 /** @override */ 71 /** @override */
65 openHelpPage: function() { 72 openHelpPage: function() {
66 this.methodCalled('openHelpPage'); 73 this.methodCalled('openHelpPage');
67 }, 74 },
68 }; 75 };
69 76
70 function registerAboutPageTests() { 77 function registerAboutPageTests() {
71 suite('AboutPageTest', function() { 78 suite('AboutPageTest', function() {
72 var page = null; 79 var page = null;
73 var browserProxy = null; 80 var browserProxy = null;
74 81
75 setup(function() { 82 setup(function() {
76 browserProxy = new TestAboutPageBrowserProxy(); 83 browserProxy = new TestAboutPageBrowserProxy();
77 settings.AboutPageBrowserProxyImpl.instance_ = browserProxy; 84 settings.AboutPageBrowserProxyImpl.instance_ = browserProxy;
78 PolymerTest.clearBody(); 85 PolymerTest.clearBody();
79 page = document.createElement('settings-about-page'); 86 page = document.createElement('settings-about-page');
80 document.body.appendChild(page); 87 document.body.appendChild(page);
88 return browserProxy.whenCalled('refreshUpdateStatus');
89 });
90
91 /**
92 * Test that the status icon updates according to incoming
93 * 'update-status-chanhed' events.
94 */
95 test('IconUpdates', function() {
96 function fireStatusChanged(status) {
97 cr.webUIListenerCallback('update-status-changed', {
98 status: status, message: '', progress: 0,
99 });
100 }
101
102 var SPINNER_ICON = 'chrome://resources/images/throbber_small.svg';
103
104 var icon = page.$$('iron-icon');
105 assertTrue(!!icon);
106 assertEquals(undefined, icon.icon);
107 assertEquals(undefined, icon.src);
108
109 fireStatusChanged(UpdateStatus.CHECKING);
110 assertEquals(SPINNER_ICON, icon.src);
111 assertEquals(null, icon.icon);
112
113 fireStatusChanged(UpdateStatus.UPDATING);
114 assertEquals(SPINNER_ICON, icon.src);
115 assertEquals(null, icon.icon);
116
117 fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
118 assertEquals(null, icon.src);
119 assertEquals('settings:check-circle', icon.icon);
120
121 fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
122 assertEquals(null, icon.src);
123 assertEquals('settings:check-circle', icon.icon);
124
125 fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN);
126 assertEquals(null, icon.src);
127 assertEquals('cr:domain', icon.icon);
128
129 fireStatusChanged(UpdateStatus.FAILED);
130 assertEquals(null, icon.src);
131 assertEquals('settings:error', icon.icon);
132
133 fireStatusChanged(UpdateStatus.DISABLED);
134 assertEquals(null, icon.src);
135 assertEquals(null, icon.icon);
81 }); 136 });
82 137
83 test('GetHelp', function() { 138 test('GetHelp', function() {
84 assertTrue(!!page.$.help); 139 assertTrue(!!page.$.help);
85 MockInteractions.tap(page.$.help); 140 MockInteractions.tap(page.$.help);
86 return browserProxy.whenCalled('openHelpPage'); 141 return browserProxy.whenCalled('openHelpPage');
87 }); 142 });
88 }); 143 });
89 } 144 }
90 145
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return { 206 return {
152 registerTests: function() { 207 registerTests: function() {
153 if (cr.isChromeOS) { 208 if (cr.isChromeOS) {
154 registerDetailedBuildInfoTests(); 209 registerDetailedBuildInfoTests();
155 } 210 }
156 registerAboutPageTests(); 211 registerAboutPageTests();
157 }, 212 },
158 registerOfficialBuildTests: registerOfficialBuildTests, 213 registerOfficialBuildTests: registerOfficialBuildTests,
159 }; 214 };
160 }); 215 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698