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

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

Issue 2787153002: MD Settings: Move easy unlock from people to lock screen. (Closed)
Patch Set: Closure. Created 3 years, 8 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/options/options_ui.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 /** @fileoverview Suite of tests for Easy Unlock within People section. */ 5 /** @fileoverview Suite of tests for Easy Unlock within People section. */
6 6
7 GEN_INCLUDE(['settings_page_browsertest.js']); 7 GEN_INCLUDE(['settings_page_browsertest.js']);
8 8
9 /** 9 /**
10 * @constructor 10 * @constructor
(...skipping 19 matching lines...) Expand all
30 30
31 // Times out on debug builders and may time out on memory bots because 31 // Times out on debug builders and may time out on memory bots because
32 // the Settings page can take several seconds to load in a Release build 32 // the Settings page can take several seconds to load in a Release build
33 // and several times that in a Debug build. See https://crbug.com/558434. 33 // and several times that in a Debug build. See https://crbug.com/558434.
34 GEN('#if defined(MEMORY_SANITIZER) || !defined(NDEBUG)'); 34 GEN('#if defined(MEMORY_SANITIZER) || !defined(NDEBUG)');
35 GEN('#define MAYBE_EasyUnlock DISABLED_EasyUnlock'); 35 GEN('#define MAYBE_EasyUnlock DISABLED_EasyUnlock');
36 GEN('#else'); 36 GEN('#else');
37 GEN('#define MAYBE_EasyUnlock EasyUnlock'); 37 GEN('#define MAYBE_EasyUnlock EasyUnlock');
38 GEN('#endif'); 38 GEN('#endif');
39 39
40 // Runs change picture tests. 40 // Runs easy unlock tests.
41 TEST_F('SettingsEasyUnlockBrowserTest', 'MAYBE_EasyUnlock', function() { 41 TEST_F('SettingsEasyUnlockBrowserTest', 'MAYBE_EasyUnlock', function() {
42 /** 42 /**
43 * A test version of EasyUnlockBrowserProxy. Provides helper methods 43 * A test version of EasyUnlockBrowserProxy. Provides helper methods
44 * for allowing tests to know when a method was called, as well as 44 * for allowing tests to know when a method was called, as well as
45 * specifying mock responses. 45 * specifying mock responses.
46 * 46 *
47 * @constructor 47 * @constructor
48 * @implements {settings.EasyUnlockBrowserProxy} 48 * @implements {settings.EasyUnlockBrowserProxy}
49 * @extends {settings.TestBrowserProxy} 49 * @extends {settings.TestBrowserProxy}
50 */ 50 */
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 startTurnOffFlow: function() { 92 startTurnOffFlow: function() {
93 this.methodCalled('startTurnOffFlow'); 93 this.methodCalled('startTurnOffFlow');
94 }, 94 },
95 95
96 /** @override */ 96 /** @override */
97 cancelTurnOffFlow: function() { 97 cancelTurnOffFlow: function() {
98 this.methodCalled('cancelTurnOffFlow'); 98 this.methodCalled('cancelTurnOffFlow');
99 }, 99 },
100 }; 100 };
101 101
102 /** @type {?SettingsPeoplePageElement} */ 102 /** @type {?SettingsLockScreenElement} */
103 var page = null; 103 var lockScreen = null;
104 104
105 /** @type {?TestEasyUnlockBrowserProxy} */ 105 /** @type {?TestEasyUnlockBrowserProxy} */
106 var browserProxy = null; 106 var browserProxy = null;
107 107
108 /** @type {?CrSettingsPrefs} */
109 var prefs = null;
110
111 var self = this;
112
113 suite('SettingsEasyUnlock', function() { 108 suite('SettingsEasyUnlock', function() {
114 suiteSetup(function() { 109 suiteSetup(function() {
115 self.basicPage.set('pageVisibility.people', true);
116 Polymer.dom.flush(); 110 Polymer.dom.flush();
117 111
118 // These overrides are necessary for this test to function on ChromeOS 112 // These overrides are necessary for this test to function on ChromeOS
119 // bots that do not have Bluetooth (don't actually support Easy Unlock). 113 // bots that do not have Bluetooth (don't actually support Easy Unlock).
120 loadTimeData.overrideValues({ 114 loadTimeData.overrideValues({
121 easyUnlockAllowed: true, 115 easyUnlockAllowed: true,
122 easyUnlockProximityDetectionAllowed: false, 116 easyUnlockProximityDetectionAllowed: false,
123 117
124 easyUnlockSectionTitle: '', 118 easyUnlockSectionTitle: '',
125 easyUnlockLearnMoreURL: '', 119 easyUnlockLearnMoreURL: '',
126 easyUnlockSetupIntro: '', 120 easyUnlockSetupIntro: '',
127 easyUnlockSetupButton: '', 121 easyUnlockSetupButton: '',
128 122
129 easyUnlockDescription: '', 123 easyUnlockDescription: '',
130 easyUnlockTurnOffTitle: '', 124 easyUnlockTurnOffTitle: '',
131 easyUnlockTurnOffDescription: '', 125 easyUnlockTurnOffDescription: '',
132 easyUnlockTurnOffButton: '', 126 easyUnlockTurnOffButton: '',
133 }); 127 });
134
135 // Before clearing the body, save a copy of the real prefs so we can
136 // cleanly re-create the People page element.
137 prefs = document.querySelector('settings-ui').$$('settings-prefs').prefs;
138 }); 128 });
139 129
140 setup(function() { 130 setup(function() {
141 browserProxy = new TestEasyUnlockBrowserProxy(); 131 browserProxy = new TestEasyUnlockBrowserProxy();
142 settings.EasyUnlockBrowserProxyImpl.instance_ = browserProxy; 132 settings.EasyUnlockBrowserProxyImpl.instance_ = browserProxy;
143 133
144 PolymerTest.clearBody(); 134 PolymerTest.clearBody();
145 page = document.createElement('settings-people-page'); 135 lockScreen = document.createElement('settings-lock-screen');
146 page.currentRoute = {
147 page: 'basic',
148 section: '',
149 subpage: [],
150 };
151 page.prefs = prefs;
152 }); 136 });
153 137
154 test('setup button', function() { 138 test('setup button', function() {
155 document.body.appendChild(page); 139 document.body.appendChild(lockScreen);
156 140
157 return browserProxy.whenCalled('getEnabledStatus').then(function() { 141 return browserProxy.whenCalled('getEnabledStatus').then(function() {
158 assertTrue(page.easyUnlockAllowed_); 142 assertTrue(lockScreen.easyUnlockAllowed_);
159 expectFalse(page.easyUnlockEnabled_); 143 expectFalse(lockScreen.easyUnlockEnabled_);
160 144
161 Polymer.dom.flush(); 145 Polymer.dom.flush();
162 146
163 var setupButton = page.$$('#easyUnlockSetup'); 147 var setupButton = lockScreen.$$('#easyUnlockSetup');
164 assertTrue(!!setupButton); 148 assertTrue(!!setupButton);
165 expectFalse(setupButton.hidden); 149 expectFalse(setupButton.hidden);
166 150
167 MockInteractions.tap(setupButton); 151 MockInteractions.tap(setupButton);
168 return browserProxy.whenCalled('startTurnOnFlow'); 152 return browserProxy.whenCalled('startTurnOnFlow');
169 }); 153 });
170 }); 154 });
171 155
172 test('turn off dialog', function() { 156 test('turn off dialog', function() {
173 browserProxy.setEnabledStatus(true); 157 browserProxy.setEnabledStatus(true);
174 document.body.appendChild(page); 158 document.body.appendChild(lockScreen);
175 159
176 var turnOffDialog = null; 160 var turnOffDialog = null;
177 161
178 return browserProxy.whenCalled('getEnabledStatus').then(function() { 162 return browserProxy.whenCalled('getEnabledStatus')
179 assertTrue(page.easyUnlockAllowed_); 163 .then(function() {
180 expectTrue(page.easyUnlockEnabled_); 164 assertTrue(lockScreen.easyUnlockAllowed_);
165 expectTrue(lockScreen.easyUnlockEnabled_);
181 166
182 Polymer.dom.flush(); 167 Polymer.dom.flush();
183 168
184 var turnOffButton = page.$$('#easyUnlockTurnOff'); 169 var turnOffButton = lockScreen.$$('#easyUnlockTurnOff');
185 assertTrue(!!turnOffButton); 170 assertTrue(!!turnOffButton);
186 expectFalse(turnOffButton.hidden) 171 expectFalse(turnOffButton.hidden)
187 172
188 MockInteractions.tap(turnOffButton); 173 MockInteractions.tap(turnOffButton);
189 return browserProxy.whenCalled('getTurnOffFlowStatus'); 174 return browserProxy.whenCalled('getTurnOffFlowStatus');
190 }).then(function() { 175 })
191 Polymer.dom.flush(); 176 .then(function() {
177 Polymer.dom.flush();
192 178
193 turnOffDialog = page.$$('#easyUnlockTurnOffDialog'); 179 turnOffDialog = lockScreen.$$('#easyUnlockTurnOffDialog');
194 assertTrue(!!turnOffDialog); 180 assertTrue(!!turnOffDialog);
195 181
196 // Verify that elements on the turn off dialog are hidden or active 182 // Verify that elements on the turn off dialog are hidden or active
197 // according to the easy unlock turn off status. 183 // according to the easy unlock turn off status.
198 var turnOffDialogButtonContainer = 184 var turnOffDialogButtonContainer =
199 turnOffDialog.$$('.button-container'); 185 turnOffDialog.$$('.button-container');
200 var turnOffDialogButtonSpinner = turnOffDialog.$$('paper-spinner'); 186 var turnOffDialogButtonSpinner = turnOffDialog.$$('paper-spinner');
201 var turnOffDialogConfirmButton = turnOffDialog.$$('#turnOff'); 187 var turnOffDialogConfirmButton = turnOffDialog.$$('#turnOff');
202 var turnOffDialogCancelButton = turnOffDialog.$$('.cancel-button'); 188 var turnOffDialogCancelButton = turnOffDialog.$$('.cancel-button');
203 assertTrue(!!turnOffDialogButtonContainer); 189 assertTrue(!!turnOffDialogButtonContainer);
204 assertTrue(!!turnOffDialogButtonSpinner); 190 assertTrue(!!turnOffDialogButtonSpinner);
205 assertTrue(!!turnOffDialogConfirmButton); 191 assertTrue(!!turnOffDialogConfirmButton);
206 assertTrue(!!turnOffDialogCancelButton); 192 assertTrue(!!turnOffDialogCancelButton);
207 193
208 cr.webUIListenerCallback('easy-unlock-turn-off-flow-status', 'offline'); 194 cr.webUIListenerCallback(
209 expectTrue(turnOffDialogButtonContainer.hidden); 195 'easy-unlock-turn-off-flow-status', 'offline');
210 expectFalse(turnOffDialogButtonSpinner.active); 196 expectTrue(turnOffDialogButtonContainer.hidden);
197 expectFalse(turnOffDialogButtonSpinner.active);
211 198
212 cr.webUIListenerCallback('easy-unlock-turn-off-flow-status', 'pending'); 199 cr.webUIListenerCallback(
213 expectFalse(turnOffDialogButtonContainer.hidden); 200 'easy-unlock-turn-off-flow-status', 'pending');
214 expectTrue(turnOffDialogButtonSpinner.active); 201 expectFalse(turnOffDialogButtonContainer.hidden);
202 expectTrue(turnOffDialogButtonSpinner.active);
215 203
216 cr.webUIListenerCallback('easy-unlock-turn-off-flow-status', 204 cr.webUIListenerCallback(
217 'server-error'); 205 'easy-unlock-turn-off-flow-status', 'server-error');
218 expectFalse(turnOffDialogButtonContainer.hidden); 206 expectFalse(turnOffDialogButtonContainer.hidden);
219 expectTrue(turnOffDialogCancelButton.hidden); 207 expectTrue(turnOffDialogCancelButton.hidden);
220 208
221 cr.webUIListenerCallback('easy-unlock-turn-off-flow-status', 'idle'); 209 cr.webUIListenerCallback(
222 expectFalse(turnOffDialogConfirmButton.hidden); 210 'easy-unlock-turn-off-flow-status', 'idle');
211 expectFalse(turnOffDialogConfirmButton.hidden);
223 212
224 MockInteractions.tap(turnOffDialogConfirmButton); 213 MockInteractions.tap(turnOffDialogConfirmButton);
225 214
226 return browserProxy.whenCalled('startTurnOffFlow'); 215 return browserProxy.whenCalled('startTurnOffFlow');
227 }).then(function() { 216 })
228 // To signal successful turnoff, the enabled status is broadcast 217 .then(function() {
229 // as false. At that point, the dialog should close and cancel 218 // To signal successful turnoff, the enabled status is broadcast
230 // any in-progress turnoff flow. The cancellation should be 219 // as false. At that point, the dialog should close and cancel
231 // a no-op assuming the turnoff originated from this tab. 220 // any in-progress turnoff flow. The cancellation should be
232 cr.webUIListenerCallback('easy-unlock-enabled-status', false); 221 // a no-op assuming the turnoff originated from this tab.
233 return browserProxy.whenCalled('cancelTurnOffFlow'); 222 cr.webUIListenerCallback('easy-unlock-enabled-status', false);
234 }).then(function() { 223 return browserProxy.whenCalled('cancelTurnOffFlow');
235 Polymer.dom.flush(); 224 })
236 expectFalse(turnOffDialog.$.dialog.open); 225 .then(function() {
237 }); 226 Polymer.dom.flush();
227 expectFalse(turnOffDialog.$.dialog.open);
228 });
238 }); 229 });
239 }); 230 });
240 231
241 // Run all registered tests. 232 // Run all registered tests.
242 mocha.run(); 233 mocha.run();
243 }); 234 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/options_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698