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

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

Issue 2102803002: Settings People Revamp: Add special Disconnect logic for domain profiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test Created 4 years, 5 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
« no previous file with comments | « chrome/browser/ui/webui/settings/people_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', function() { 5 cr.define('settings_people_page', function() {
6 /**
7 * @constructor
8 * @implements {settings.ProfileInfoBrowserProxy}
9 * @extends {settings.TestBrowserProxy}
10 */
11 var TestProfileInfoBrowserProxy = function() {
12 settings.TestBrowserProxy.call(this, [
13 'getProfileInfo',
14 'getProfileManagesSupervisedUsers',
15 ]);
16 };
17
18 TestProfileInfoBrowserProxy.prototype = {
19 __proto__: settings.TestBrowserProxy.prototype,
20
21 fakeProfileInfo: {
22 name: 'fakeName',
23 iconUrl: 'http://fake-icon-url.com/',
24 },
25
26 /** @override */
27 getProfileInfo: function() {
28 this.methodCalled('getProfileInfo');
29 return Promise.resolve(this.fakeProfileInfo);
30 },
31
32 /** @override */
33 getProfileManagesSupervisedUsers: function() {
34 this.methodCalled('getProfileManagesSupervisedUsers');
35 return Promise.resolve(false);
36 }
37 };
38
39 function registerProfileInfoTests() { 6 function registerProfileInfoTests() {
40 suite('ProfileInfoTests', function() { 7 suite('ProfileInfoTests', function() {
8 /**
9 * @constructor
10 * @implements {settings.ProfileInfoBrowserProxy}
11 * @extends {settings.TestBrowserProxy}
12 */
13 var TestProfileInfoBrowserProxy = function() {
14 settings.TestBrowserProxy.call(this, [
15 'getProfileInfo',
16 'getProfileManagesSupervisedUsers',
17 ]);
18 };
19
20 TestProfileInfoBrowserProxy.prototype = {
21 __proto__: settings.TestBrowserProxy.prototype,
22
23 fakeProfileInfo: {
dpapad 2016/06/29 22:09:34 You probably want this declared in the constructor
tommycli 2016/06/29 22:30:10 Done.
24 name: 'fakeName',
25 iconUrl: 'http://fake-icon-url.com/',
26 },
27
28 /** @override */
29 getProfileInfo: function() {
30 this.methodCalled('getProfileInfo');
31 return Promise.resolve(this.fakeProfileInfo);
32 },
33
34 /** @override */
35 getProfileManagesSupervisedUsers: function() {
36 this.methodCalled('getProfileManagesSupervisedUsers');
37 return Promise.resolve(false);
38 }
39 };
40
41 var peoplePage = null; 41 var peoplePage = null;
42 var browserProxy = null; 42 var browserProxy = null;
43 43
44 suiteSetup(function() { 44 suiteSetup(function() {
45 // Force easy unlock off. Those have their own ChromeOS-only tests. 45 // Force easy unlock off. Those have their own ChromeOS-only tests.
46 loadTimeData.overrideValues({ 46 loadTimeData.overrideValues({
47 easyUnlockAllowed: false, 47 easyUnlockAllowed: false,
48 }); 48 });
49 }); 49 });
50 50
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 'profile-manages-supervised-users-changed', 89 'profile-manages-supervised-users-changed',
90 true); 90 true);
91 91
92 Polymer.dom.flush(); 92 Polymer.dom.flush();
93 assertTrue(!!peoplePage.$$('#manageSupervisedUsersContainer')); 93 assertTrue(!!peoplePage.$$('#manageSupervisedUsersContainer'));
94 }); 94 });
95 }); 95 });
96 }); 96 });
97 } 97 }
98 98
99 function registerSyncStatusTests() {
100 suite('SyncStatusTests', function() {
101 /**
dpapad 2016/06/29 22:09:34 Nit(optional): Is a bit odd to define a whole clas
tommycli 2016/06/29 22:30:10 Done.
102 * @constructor
103 * @implements {settings.SyncBrowserProxy}
104 * @extends {settings.TestBrowserProxy}
105 */
106 var TestSyncBrowserProxy = function() {
tommycli 2016/06/29 19:20:31 I realize there is also a TestSyncBrowserProxy wit
107 settings.TestBrowserProxy.call(this, [
108 'getSyncStatus',
109 'signOut',
110 ]);
111 };
112
113 TestSyncBrowserProxy.prototype = {
114 __proto__: settings.TestBrowserProxy.prototype,
115
116 /** @override */
117 getSyncStatus: function() {
118 this.methodCalled('getSyncStatus');
119 return Promise.resolve({
120 signedIn: true,
121 });
122 },
123
124 /** @override */
125 signOut: function(deleteProfile) {
126 this.methodCalled('signOut', deleteProfile);
127 },
128 };
129
130 var peoplePage = null;
131 var browserProxy = null;
132
133 suiteSetup(function() {
134 // Force easy unlock off. Those have their own ChromeOS-only tests.
135 loadTimeData.overrideValues({
136 easyUnlockAllowed: false,
137 });
138 });
139
140 setup(function() {
141 browserProxy = new TestSyncBrowserProxy();
142 settings.SyncBrowserProxyImpl.instance_ = browserProxy;
143
144 PolymerTest.clearBody();
145 peoplePage = document.createElement('settings-people-page');
146 document.body.appendChild(peoplePage);
147 });
148
149 teardown(function() { peoplePage.remove(); });
150
151 test('GetProfileInfo', function() {
152 return browserProxy.whenCalled('getSyncStatus').then(function() {
153 Polymer.dom.flush();
154 var disconnectButton = peoplePage.$$('#disconnectButton');
155 assertTrue(!!disconnectButton);
156
157 MockInteractions.tap(disconnectButton);
158 Polymer.dom.flush();
159
160 assertTrue(peoplePage.$.disconnectDialog.opened);
161 assertFalse(peoplePage.$.deleteProfile.hidden);
162
163 var disconnectConfirm = peoplePage.$.disconnectConfirm;
164 assertTrue(!!disconnectConfirm);
165 assertFalse(disconnectConfirm.hidden);
166 MockInteractions.tap(disconnectConfirm);
167
168 return browserProxy.whenCalled('signOut').then(
169 function(deleteProfile) {
170 Polymer.dom.flush();
171
172 assertFalse(deleteProfile);
173
174 cr.webUIListenerCallback('sync-status-changed', {
175 signedIn: true,
176 domain: 'example.com',
177 });
178 Polymer.dom.flush();
179
180 assertFalse(peoplePage.$.disconnectDialog.opened);
181 MockInteractions.tap(disconnectButton);
182 Polymer.dom.flush();
183
184 assertTrue(peoplePage.$.disconnectDialog.opened);
185 assertTrue(peoplePage.$.deleteProfile.hidden);
186
187 var disconnectManagedProfileConfirm =
188 peoplePage.$.disconnectManagedProfileConfirm;
189 assertTrue(!!disconnectManagedProfileConfirm);
190 assertFalse(disconnectManagedProfileConfirm.hidden);
191
192 browserProxy.resetResolver('signOut');
193 MockInteractions.tap(disconnectManagedProfileConfirm);
194
195 return browserProxy.whenCalled('signOut').then(
196 function(deleteProfile) {
197 assertTrue(deleteProfile);
198 });
199 });
200 });
201 });
202 });
203 }
204
99 return { 205 return {
100 registerTests: function() { 206 registerTests: function() {
101 registerProfileInfoTests(); 207 registerProfileInfoTests();
208 if (!cr.isChromeOS)
209 registerSyncStatusTests();
102 }, 210 },
103 }; 211 };
104 }); 212 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/people_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698