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

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

Issue 2525783002: MD Settings: Hide Profile Shortcut switch for single-profile machines. (Closed)
Patch Set: one more fix to make it actually work Created 4 years 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
« no previous file with comments | « chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_people_page_manage_profile', function() { 5 cr.define('settings_people_page_manage_profile', function() {
6 /** 6 /**
7 * @constructor 7 * @constructor
8 * @implements {settings.ManageProfileBrowserProxy} 8 * @implements {settings.ManageProfileBrowserProxy}
9 * @extends {settings.TestBrowserProxy} 9 * @extends {settings.TestBrowserProxy}
10 */ 10 */
11 var TestManageProfileBrowserProxy = function() { 11 var TestManageProfileBrowserProxy = function() {
12 settings.TestBrowserProxy.call(this, [ 12 settings.TestBrowserProxy.call(this, [
13 'getAvailableIcons', 13 'getAvailableIcons',
14 'setProfileIconAndName', 14 'setProfileIconAndName',
15 'getHasProfileShortcut', 15 'getProfileShortcutStatus',
16 'addProfileShortcut', 16 'addProfileShortcut',
17 'removeProfileShortcut', 17 'removeProfileShortcut',
18 ]); 18 ]);
19
20 /** @private {!ProfileShortcutStatus} */
21 this.profileShortcutStatus_ = ProfileShortcutStatus.PROFILE_SHORTCUT_FOUND;
19 }; 22 };
20 23
21 TestManageProfileBrowserProxy.prototype = { 24 TestManageProfileBrowserProxy.prototype = {
22 __proto__: settings.TestBrowserProxy.prototype, 25 __proto__: settings.TestBrowserProxy.prototype,
23 26
27 /** @param {!ProfileShortcutStatus} status */
28 setProfileShortcutStatus: function(status) {
29 this.profileShortcutStatus_ = status;
30 },
31
24 /** @override */ 32 /** @override */
25 getAvailableIcons: function() { 33 getAvailableIcons: function() {
26 this.methodCalled('getAvailableIcons'); 34 this.methodCalled('getAvailableIcons');
27 return Promise.resolve([{url: 'fake-icon-1.png', label: 'fake-icon-1'}, 35 return Promise.resolve([{url: 'fake-icon-1.png', label: 'fake-icon-1'},
28 {url: 'fake-icon-2.png', label: 'fake-icon-2'}]); 36 {url: 'fake-icon-2.png', label: 'fake-icon-2'}]);
29 }, 37 },
30 38
31 /** @override */ 39 /** @override */
32 setProfileIconAndName: function(iconUrl, name) { 40 setProfileIconAndName: function(iconUrl, name) {
33 this.methodCalled('setProfileIconAndName', [iconUrl, name]); 41 this.methodCalled('setProfileIconAndName', [iconUrl, name]);
34 }, 42 },
35 43
36 getHasProfileShortcut: function() { 44 /** @override */
37 this.methodCalled('getHasProfileShortcut'); 45 getProfileShortcutStatus: function() {
38 return Promise.resolve(true); 46 this.methodCalled('getProfileShortcutStatus');
47 return Promise.resolve([this.profileShortcutStatus_]);
39 }, 48 },
40 49
41 /** @override */ 50 /** @override */
42 addProfileShortcut: function() { 51 addProfileShortcut: function() {
43 this.methodCalled('addProfileShortcut'); 52 this.methodCalled('addProfileShortcut');
44 }, 53 },
45 54
46 /** @override */ 55 /** @override */
47 removeProfileShortcut: function() { 56 removeProfileShortcut: function() {
48 this.methodCalled('removeProfileShortcut'); 57 this.methodCalled('removeProfileShortcut');
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 }); 178 });
170 179
171 browserProxy = new TestManageProfileBrowserProxy(); 180 browserProxy = new TestManageProfileBrowserProxy();
172 settings.ManageProfileBrowserProxyImpl.instance_ = browserProxy; 181 settings.ManageProfileBrowserProxyImpl.instance_ = browserProxy;
173 PolymerTest.clearBody(); 182 PolymerTest.clearBody();
174 manageProfile = document.createElement('settings-manage-profile'); 183 manageProfile = document.createElement('settings-manage-profile');
175 manageProfile.profileIconUrl = 'fake-icon-1.png'; 184 manageProfile.profileIconUrl = 'fake-icon-1.png';
176 manageProfile.profileName = 'Initial Fake Name'; 185 manageProfile.profileName = 'Initial Fake Name';
177 manageProfile.syncStatus = {supervisedUser: false, childUser: false}; 186 manageProfile.syncStatus = {supervisedUser: false, childUser: false};
178 document.body.appendChild(manageProfile); 187 document.body.appendChild(manageProfile);
179 settings.navigateTo(settings.Route.MANAGE_PROFILE);
180 Polymer.dom.flush();
181 }); 188 });
182 189
183 teardown(function() { manageProfile.remove(); }); 190 teardown(function() { manageProfile.remove(); });
184 191
185 // Tests profile shortcut toggle is visible and toggling it removes and 192 // Tests profile shortcut toggle is visible and toggling it removes and
186 // creates the profile shortcut respectively. 193 // creates the profile shortcut respectively.
187 test('ManageProfileShortcutToggle', function() { 194 test('ManageProfileShortcutToggle', function() {
188 var hasShortcutToggle = manageProfile.$$('#hasShortcutToggle'); 195 settings.navigateTo(settings.Route.MANAGE_PROFILE);
189 assertTrue(!!hasShortcutToggle); 196 Polymer.dom.flush();
190 197
191 return browserProxy.whenCalled('getHasProfileShortcut') 198 assertFalse(!!manageProfile.$$('#hasShortcutToggle'));
199
200 return browserProxy.whenCalled('getProfileShortcutStatus')
192 .then(function() { 201 .then(function() {
193 Polymer.dom.flush(); 202 Polymer.dom.flush();
194 203
204 var hasShortcutToggle = manageProfile.$$('#hasShortcutToggle');
205 assertTrue(!!hasShortcutToggle);
206
195 // The profile shortcut toggle is checked. 207 // The profile shortcut toggle is checked.
196 assertTrue(hasShortcutToggle.active); 208 assertTrue(hasShortcutToggle.checked);
197 209
198 // Simulate tapping the profile shortcut toggle. 210 // Simulate tapping the profile shortcut toggle.
199 MockInteractions.tap(hasShortcutToggle); 211 MockInteractions.tap(hasShortcutToggle);
200 return browserProxy.whenCalled('removeProfileShortcut') 212 return browserProxy.whenCalled('removeProfileShortcut')
201 .then(function() { 213 .then(function() {
202 Polymer.dom.flush(); 214 Polymer.dom.flush();
203 215
204 // The profile shortcut toggle is checked. 216 // The profile shortcut toggle is checked.
205 assertFalse(hasShortcutToggle.active); 217 assertFalse(hasShortcutToggle.checked);
206 218
207 // Simulate tapping the profile shortcut toggle. 219 // Simulate tapping the profile shortcut toggle.
208 MockInteractions.tap(hasShortcutToggle); 220 MockInteractions.tap(hasShortcutToggle);
209 return browserProxy.whenCalled('addProfileShortcut'); 221 return browserProxy.whenCalled('addProfileShortcut');
210 }); 222 });
211 }); 223 });
212 }); 224 });
225
226 // Tests profile shortcut toggle is visible and toggled off when no
227 // profile shortcut is found.
228 test('ManageProfileShortcutToggle', function() {
229 browserProxy.setProfileShortcutStatus(
230 ProfileShortcutStatus.PROFILE_SHORTCUT_NOT_FOUND);
231
232 settings.navigateTo(settings.Route.MANAGE_PROFILE);
233 Polymer.dom.flush();
234
235 assertFalse(!!manageProfile.$$('#hasShortcutToggle'));
236
237 return browserProxy.whenCalled('getProfileShortcutStatus')
238 .then(function() {
239 Polymer.dom.flush();
240
241 var hasShortcutToggle = manageProfile.$$('#hasShortcutToggle');
242 assertTrue(!!hasShortcutToggle);
243
244 assertFalse(hasShortcutToggle.checked);
245 });
246 });
247
248 // Tests the case when the profile shortcut setting is hidden. This can
249 // occur in the single profile case.
250 test('ManageProfileShortcutSettingHIdden', function() {
251 browserProxy.setProfileShortcutStatus(
252 ProfileShortcutStatus.PROFILE_SHORTCUT_SETTING_HIDDEN);
253
254 settings.navigateTo(settings.Route.MANAGE_PROFILE);
255 Polymer.dom.flush();
256
257 assertFalse(!!manageProfile.$$('#hasShortcutToggle'));
258
259 return browserProxy.whenCalled('getProfileShortcutStatus')
260 .then(function() {
261 Polymer.dom.flush();
262
263 assertFalse(!!manageProfile.$$('#hasShortcutToggle'));
264 });
265 });
213 }); 266 });
214 } 267 }
215 268
216 return { 269 return {
217 registerTests: function() { 270 registerTests: function() {
218 registerManageProfileTests(); 271 registerManageProfileTests();
219 }, 272 },
220 }; 273 };
221 }); 274 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698