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

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

Issue 2617533003: MD Settings: change most checkboxes to toggles (leave dialogs alone) (Closed)
Patch Set: fix tests Created 3 years, 11 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 (function() { 5 (function() {
6 function getFakePrefs() { 6 function getFakePrefs() {
7 return { 7 return {
8 cros: { 8 cros: {
9 system: { 9 system: {
10 timezone: { 10 timezone: {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 suiteTeardown(function() { 106 suiteTeardown(function() {
107 // TODO(michaelpg): Removes the element before exiting, because the 107 // TODO(michaelpg): Removes the element before exiting, because the
108 // <paper-tooltip> in <cr-policy-pref-indicator> somehow causes warnings 108 // <paper-tooltip> in <cr-policy-pref-indicator> somehow causes warnings
109 // and/or script errors in axs_testing.js. 109 // and/or script errors in axs_testing.js.
110 PolymerTest.clearBody(); 110 PolymerTest.clearBody();
111 }); 111 });
112 112
113 function verifyAutoDetectSetting(autoDetect) { 113 function verifyAutoDetectSetting(autoDetect) {
114 assertEquals(autoDetect, dateTime.$$('settings-dropdown-menu').disabled); 114 assertEquals(autoDetect, dateTime.$$('settings-dropdown-menu').disabled);
115 assertEquals(autoDetect, dateTime.$.timeZoneAutoDetectCheckbox.checked); 115 assertEquals(autoDetect, dateTime.$.timeZoneAutoDetect.checked);
116 } 116 }
117 117
118 function verifyPolicy(policy) { 118 function verifyPolicy(policy) {
119 Polymer.dom.flush(); 119 Polymer.dom.flush();
120 var indicator = dateTime.$$('cr-policy-pref-indicator'); 120 var indicator = dateTime.$$('cr-policy-pref-indicator');
121 121
122 if (policy) { 122 if (policy) {
123 assertTrue(!!indicator); 123 assertTrue(!!indicator);
124 assertGT(indicator.clientHeight, 0); 124 assertGT(indicator.clientHeight, 0);
125 } else { 125 } else {
126 // Indicator should be missing or hidden. 126 // Indicator should be missing or hidden.
127 if (indicator) 127 if (indicator)
128 assertEquals(0, indicator.clientHeight); 128 assertEquals(0, indicator.clientHeight);
129 } 129 }
130 130
131 assertEquals(policy, dateTime.$.timeZoneAutoDetectCheckbox.disabled); 131 assertEquals(policy, dateTime.$.timeZoneAutoDetect.disabled);
132 } 132 }
133 133
134 function verifyTimeZonesPopulated(populated) { 134 function verifyTimeZonesPopulated(populated) {
135 var dropdown = dateTime.$$('settings-dropdown-menu'); 135 var dropdown = dateTime.$$('settings-dropdown-menu');
136 if (populated) 136 if (populated)
137 assertEquals(fakeTimeZones.length, dropdown.menuOptions.length); 137 assertEquals(fakeTimeZones.length, dropdown.menuOptions.length);
138 else 138 else
139 assertEquals(1, dropdown.menuOptions.length); 139 assertEquals(1, dropdown.menuOptions.length);
140 } 140 }
141 141
142 test('auto-detect on', function(done) { 142 test('auto-detect on', function(done) {
143 var prefs = getFakePrefs(); 143 var prefs = getFakePrefs();
144 dateTime = initializeDateTime(prefs, false); 144 dateTime = initializeDateTime(prefs, false);
145 145
146 assertTrue(dateTimePageReadyCalled); 146 assertTrue(dateTimePageReadyCalled);
147 assertFalse(getTimeZonesCalled); 147 assertFalse(getTimeZonesCalled);
148 148
149 verifyAutoDetectSetting(true); 149 verifyAutoDetectSetting(true);
150 verifyTimeZonesPopulated(false); 150 verifyTimeZonesPopulated(false);
151 verifyPolicy(false); 151 verifyPolicy(false);
152 152
153 // Disable auto-detect. 153 // Disable auto-detect.
154 MockInteractions.tap(dateTime.$.timeZoneAutoDetectCheckbox); 154 MockInteractions.tap(dateTime.$.timeZoneAutoDetect);
155 verifyAutoDetectSetting(false); 155 verifyAutoDetectSetting(false);
156 assertTrue(getTimeZonesCalled); 156 assertTrue(getTimeZonesCalled);
157 157
158 setTimeout(function() { 158 setTimeout(function() {
159 verifyTimeZonesPopulated(true); 159 verifyTimeZonesPopulated(true);
160 done(); 160 done();
161 }); 161 });
162 }); 162 });
163 163
164 test('auto-detect off', function(done) { 164 test('auto-detect off', function(done) {
165 var prefs = getFakePrefs(); 165 var prefs = getFakePrefs();
166 prefs.settings.resolve_timezone_by_geolocation.value = false; 166 prefs.settings.resolve_timezone_by_geolocation.value = false;
167 dateTime = initializeDateTime(prefs, false); 167 dateTime = initializeDateTime(prefs, false);
168 168
169 assertTrue(dateTimePageReadyCalled); 169 assertTrue(dateTimePageReadyCalled);
170 assertTrue(getTimeZonesCalled); 170 assertTrue(getTimeZonesCalled);
171 171
172 verifyAutoDetectSetting(false); 172 verifyAutoDetectSetting(false);
173 verifyPolicy(false); 173 verifyPolicy(false);
174 174
175 setTimeout(function() { 175 setTimeout(function() {
176 verifyTimeZonesPopulated(true); 176 verifyTimeZonesPopulated(true);
177 177
178 // Enable auto-detect. 178 // Enable auto-detect.
179 MockInteractions.tap(dateTime.$.timeZoneAutoDetectCheckbox); 179 MockInteractions.tap(dateTime.$.timeZoneAutoDetect);
180 verifyAutoDetectSetting(true); 180 verifyAutoDetectSetting(true);
181 done(); 181 done();
182 }); 182 });
183 }); 183 });
184 184
185 test('auto-detect forced on', function(done) { 185 test('auto-detect forced on', function(done) {
186 var prefs = getFakePrefs(); 186 var prefs = getFakePrefs();
187 prefs.settings.resolve_timezone_by_geolocation.value = false; 187 prefs.settings.resolve_timezone_by_geolocation.value = false;
188 dateTime = initializeDateTime(prefs, true, true); 188 dateTime = initializeDateTime(prefs, true, true);
189 189
190 assertTrue(dateTimePageReadyCalled); 190 assertTrue(dateTimePageReadyCalled);
191 assertFalse(getTimeZonesCalled); 191 assertFalse(getTimeZonesCalled);
192 192
193 verifyAutoDetectSetting(true); 193 verifyAutoDetectSetting(true);
194 verifyTimeZonesPopulated(false); 194 verifyTimeZonesPopulated(false);
195 verifyPolicy(true); 195 verifyPolicy(true);
196 196
197 // Cannot disable auto-detect. 197 // Cannot disable auto-detect.
198 MockInteractions.tap(dateTime.$.timeZoneAutoDetectCheckbox); 198 MockInteractions.tap(dateTime.$.timeZoneAutoDetect);
199 verifyAutoDetectSetting(true); 199 verifyAutoDetectSetting(true);
200 assertFalse(getTimeZonesCalled); 200 assertFalse(getTimeZonesCalled);
201 201
202 // Update the policy: force auto-detect off. 202 // Update the policy: force auto-detect off.
203 cr.webUIListenerCallback('time-zone-auto-detect-policy', true, false); 203 cr.webUIListenerCallback('time-zone-auto-detect-policy', true, false);
204 verifyAutoDetectSetting(false); 204 verifyAutoDetectSetting(false);
205 verifyPolicy(true); 205 verifyPolicy(true);
206 206
207 assertTrue(getTimeZonesCalled); 207 assertTrue(getTimeZonesCalled);
208 setTimeout(function() { 208 setTimeout(function() {
(...skipping 14 matching lines...) Expand all
223 223
224 setTimeout(function() { 224 setTimeout(function() {
225 verifyTimeZonesPopulated(true); 225 verifyTimeZonesPopulated(true);
226 226
227 // Remove the policy so user's preference takes effect. 227 // Remove the policy so user's preference takes effect.
228 cr.webUIListenerCallback('time-zone-auto-detect-policy', false); 228 cr.webUIListenerCallback('time-zone-auto-detect-policy', false);
229 verifyAutoDetectSetting(true); 229 verifyAutoDetectSetting(true);
230 verifyPolicy(false); 230 verifyPolicy(false);
231 231
232 // User can disable auto-detect. 232 // User can disable auto-detect.
233 MockInteractions.tap(dateTime.$.timeZoneAutoDetectCheckbox); 233 MockInteractions.tap(dateTime.$.timeZoneAutoDetect);
234 verifyAutoDetectSetting(false); 234 verifyAutoDetectSetting(false);
235 done(); 235 done();
236 }); 236 });
237 }); 237 });
238 238
239 test('set date and time button', function() { 239 test('set date and time button', function() {
240 dateTime = initializeDateTime(getFakePrefs(), false); 240 dateTime = initializeDateTime(getFakePrefs(), false);
241 241
242 var showSetDateTimeUICalled = false; 242 var showSetDateTimeUICalled = false;
243 registerMessageCallback('showSetDateTimeUI', null, function() { 243 registerMessageCallback('showSetDateTimeUI', null, function() {
(...skipping 11 matching lines...) Expand all
255 assertFalse(showSetDateTimeUICalled); 255 assertFalse(showSetDateTimeUICalled);
256 MockInteractions.tap(setDateTimeButton); 256 MockInteractions.tap(setDateTimeButton);
257 assertTrue(showSetDateTimeUICalled); 257 assertTrue(showSetDateTimeUICalled);
258 258
259 // Make the date and time not editable. 259 // Make the date and time not editable.
260 cr.webUIListenerCallback('can-set-date-time-changed', false); 260 cr.webUIListenerCallback('can-set-date-time-changed', false);
261 assertEquals(setDateTimeButton.offsetHeight, 0); 261 assertEquals(setDateTimeButton.offsetHeight, 0);
262 }); 262 });
263 }); 263 });
264 })(); 264 })();
OLDNEW
« no previous file with comments | « chrome/test/data/webui/settings/android_apps_page_test.js ('k') | chrome/test/data/webui/settings/device_page_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698