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

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

Issue 2110833003: MD Settings: Add mouse settings, update pointer settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@PointersFake
Patch Set: 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
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('device_page_tests', function() { 5 cr.define('device_page_tests', function() {
6 /** @enum {string} */ 6 /** @enum {string} */
7 var TestNames = { 7 var TestNames = {
8 DevicePage: 'device page',
8 Display: 'display', 9 Display: 'display',
9 Keyboard: 'keyboard', 10 Keyboard: 'keyboard',
10 Touchpad: 'touchpad', 11 Pointers: 'pointers',
11 }; 12 };
12 13
13 /** 14 /**
14 * @constructor 15 * @constructor
15 * @implements {settings.DevicePageBrowserProxy} 16 * @implements {settings.DevicePageBrowserProxy}
16 */ 17 */
17 function TestDevicePageBrowserProxy() { 18 function TestDevicePageBrowserProxy() {
18 this.keyboardShortcutsOverlayShown_ = 0; 19 this.keyboardShortcutsOverlayShown_ = 0;
19 } 20 }
20 21
21 TestDevicePageBrowserProxy.prototype = { 22 TestDevicePageBrowserProxy.prototype = {
23 /** override */
24 initializePointers: function() {
25 // Enable mouse and touchpad.
26 cr.webUIListenerCallback('has-mouse-changed', true);
27 cr.webUIListenerCallback('has-touchpad-changed', true);
28 },
29
22 /** @override */ 30 /** @override */
23 handleLinkEvent: function(e) { 31 handleLinkEvent: function(e) {
24 settings.DevicePageBrowserProxyImpl.prototype.handleLinkEvent.call( 32 settings.DevicePageBrowserProxyImpl.prototype.handleLinkEvent.call(
25 this, e); 33 this, e);
26 // Prevent opening the link, which can block the test. 34 // Prevent opening the link, which can block the test.
27 e.preventDefault(); 35 e.preventDefault();
28 }, 36 },
29 37
30 /** override */ 38 /** override */
31 initializeKeyboard: function() {}, 39 initializeKeyboard: function() {},
(...skipping 16 matching lines...) Expand all
48 enable_tap_dragging: { 56 enable_tap_dragging: {
49 key: 'settings.touchpad.enable_tap_dragging', 57 key: 'settings.touchpad.enable_tap_dragging',
50 type: chrome.settingsPrivate.PrefType.BOOLEAN, 58 type: chrome.settingsPrivate.PrefType.BOOLEAN,
51 value: true, 59 value: true,
52 }, 60 },
53 natural_scroll: { 61 natural_scroll: {
54 key: 'settings.touchpad.natural_scroll', 62 key: 'settings.touchpad.natural_scroll',
55 type: chrome.settingsPrivate.PrefType.BOOLEAN, 63 type: chrome.settingsPrivate.PrefType.BOOLEAN,
56 value: false, 64 value: false,
57 }, 65 },
66 sensitivity2: {
67 key: 'settings.touchpad.sensitivity2',
68 type: chrome.settingsPrivate.PrefType.NUMBER,
69 value: 3,
70 },
71 },
72 mouse: {
73 primary_right: {
74 key: 'settings.mouse.primary_right',
75 type: chrome.settingsPrivate.PrefType.BOOLEAN,
76 value: false,
77 },
78 sensitivity2: {
79 key: 'settings.mouse.sensitivity2',
80 type: chrome.settingsPrivate.PrefType.NUMBER,
81 value: 4,
82 },
58 }, 83 },
59 language: { 84 language: {
60 xkb_remap_search_key_to: { 85 xkb_remap_search_key_to: {
61 key: 'settings.language.xkb_remap_search_key_to', 86 key: 'settings.language.xkb_remap_search_key_to',
62 type: chrome.settingsPrivate.PrefType.NUMBER, 87 type: chrome.settingsPrivate.PrefType.NUMBER,
63 value: 0, 88 value: 0,
64 }, 89 },
65 xkb_remap_control_key_to: { 90 xkb_remap_control_key_to: {
66 key: 'settings.language.xkb_remap_control_key_to', 91 key: 'settings.language.xkb_remap_control_key_to',
67 type: chrome.settingsPrivate.PrefType.NUMBER, 92 type: chrome.settingsPrivate.PrefType.NUMBER,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 expectEquals(subpage, devicePage.currentRoute.subpage[0]); 171 expectEquals(subpage, devicePage.currentRoute.subpage[0]);
147 var page = devicePage.$$('#' + subpage + ' settings-' + subpage); 172 var page = devicePage.$$('#' + subpage + ' settings-' + subpage);
148 assertTrue(!!page); 173 assertTrue(!!page);
149 setTimeout(function() { 174 setTimeout(function() {
150 resolve(page); 175 resolve(page);
151 }); 176 });
152 }); 177 });
153 }; 178 };
154 179
155 /** 180 /**
156 * @param {!HTMLElement} touchpadPage 181 * @param {!HTMLElement} pointersPage
157 * @param {Boolean} expected 182 * @param {Boolean} expected
158 */ 183 */
159 function expectNaturalScrollValue(touchpadPage, expected) { 184 function expectNaturalScrollValue(pointersPage, expected) {
160 var naturalScrollOff = 185 var naturalScrollOff =
161 touchpadPage.$$('paper-radio-button[name="false"]'); 186 pointersPage.$$('paper-radio-button[name="false"]');
162 var naturalScrollOn = 187 var naturalScrollOn =
163 touchpadPage.$$('paper-radio-button[name="true"]'); 188 pointersPage.$$('paper-radio-button[name="true"]');
164 assertTrue(!!naturalScrollOff); 189 assertTrue(!!naturalScrollOff);
165 assertTrue(!!naturalScrollOn); 190 assertTrue(!!naturalScrollOn);
166 191
167 expectEquals(!expected, naturalScrollOff.checked); 192 expectEquals(!expected, naturalScrollOff.checked);
168 expectEquals(expected, naturalScrollOn.checked); 193 expectEquals(expected, naturalScrollOn.checked);
169 expectEquals(expected, 194 expectEquals(expected,
170 devicePage.prefs.settings.touchpad.natural_scroll.value); 195 devicePage.prefs.settings.touchpad.natural_scroll.value);
171 } 196 }
172 197
173 test(assert(TestNames.Touchpad), function(done) { 198 test(assert(TestNames.DevicePage), function() {
174 showAndGetDeviceSubpage('touchpad').then(function(touchpadPage) { 199 expectLT(0, devicePage.$.pointersRow.offsetHeight);
175 expectNaturalScrollValue(touchpadPage, false); 200 expectLT(0, devicePage.$.keyboardRow.offsetHeight);
201 expectLT(0, devicePage.$.displayRow.offsetHeight);
176 202
177 // Tapping the link shouldn't enable the radio button. 203 cr.webUIListenerCallback('has-mouse-changed', false);
178 var naturalScrollOn = 204 expectLT(0, devicePage.$.pointersRow.offsetHeight);
179 touchpadPage.$$('paper-radio-button[name="true"]'); 205 cr.webUIListenerCallback('has-touchpad-changed', false);
180 var a = naturalScrollOn.querySelector('a'); 206 expectEquals(0, devicePage.$.pointersRow.offsetHeight);
207 cr.webUIListenerCallback('has-mouse-changed', true);
208 expectLT(0, devicePage.$.pointersRow.offsetHeight);
209 });
181 210
182 MockInteractions.tap(a); 211 suite(assert(TestNames.Pointers), function() {
183 expectNaturalScrollValue(touchpadPage, false); 212 test('subpage', function() {
213 return showAndGetDeviceSubpage('pointers').then(function(pointersPage) {
214 expectLT(0, pointersPage.$.mouse.offsetHeight);
215 expectLT(0, pointersPage.$.touchpad.offsetHeight);
216 expectLT(0, pointersPage.$$('#mouse h2').offsetHeight);
217 expectLT(0, pointersPage.$$('#touchpad h2').offsetHeight);
184 218
185 MockInteractions.tap(naturalScrollOn); 219 cr.webUIListenerCallback('has-touchpad-changed', false);
186 expectNaturalScrollValue(touchpadPage, true); 220 expectLT(0, pointersPage.$.mouse.offsetHeight);
221 expectEquals(0, pointersPage.$.touchpad.offsetHeight);
222 expectEquals(0, pointersPage.$$('#mouse h2').offsetHeight);
223 expectEquals(0, pointersPage.$$('#touchpad h2').offsetHeight);
187 224
188 devicePage.set('prefs.settings.touchpad.natural_scroll.value', false); 225 cr.webUIListenerCallback('has-mouse-changed', false);
189 expectNaturalScrollValue(touchpadPage, false); 226 expectEquals(0, pointersPage.$.mouse.offsetHeight);
227 expectEquals(0, pointersPage.$.touchpad.offsetHeight);
228 expectEquals(0, pointersPage.$$('#mouse h2').offsetHeight);
229 expectEquals(0, pointersPage.$$('#touchpad h2').offsetHeight);
190 230
191 // Enter on the link shouldn't enable the radio button either. 231 cr.webUIListenerCallback('has-touchpad-changed', true);
192 MockInteractions.pressEnter(a); 232 expectEquals(0, pointersPage.$.mouse.offsetHeight);
233 expectLT(0, pointersPage.$.touchpad.offsetHeight);
234 expectEquals(0, pointersPage.$$('#mouse h2').offsetHeight);
235 expectEquals(0, pointersPage.$$('#touchpad h2').offsetHeight);
193 236
194 // Annoyingly, we have to schedule an async event with a timeout greater 237 cr.webUIListenerCallback('has-mouse-changed', true);
195 // than or equal to the timeout used by IronButtonState (1). 238 expectLT(0, pointersPage.$.mouse.offsetHeight);
196 // https://github.com/PolymerElements/iron-behaviors/issues/54 239 expectLT(0, pointersPage.$.touchpad.offsetHeight);
197 Polymer.Base.async(function() { 240 expectLT(0, pointersPage.$$('#mouse h2').offsetHeight);
198 expectNaturalScrollValue(touchpadPage, false); 241 expectLT(0, pointersPage.$$('#touchpad h2').offsetHeight);
242 });
243 });
199 244
200 MockInteractions.pressEnter(naturalScrollOn); 245 test('link doesn\'t activate control', function(done) {
246 showAndGetDeviceSubpage('pointers').then(function(pointersPage) {
247 expectNaturalScrollValue(pointersPage, false);
248
249 // Tapping the link shouldn't enable the radio button.
250 var naturalScrollOn =
251 pointersPage.$$('paper-radio-button[name="true"]');
252 var a = naturalScrollOn.querySelector('a');
253
254 MockInteractions.tap(a);
255 expectNaturalScrollValue(pointersPage, false);
256
257 MockInteractions.tap(naturalScrollOn);
258 expectNaturalScrollValue(pointersPage, true);
259 devicePage.set('prefs.settings.touchpad.natural_scroll.value', false);
260 expectNaturalScrollValue(pointersPage, false);
261
262 // Enter on the link shouldn't enable the radio button either.
263 MockInteractions.pressEnter(a);
264
265 // Annoyingly, we have to schedule an async event with a timeout
266 // greater than or equal to the timeout used by IronButtonState (1).
267 // https://github.com/PolymerElements/iron-behaviors/issues/54
201 Polymer.Base.async(function() { 268 Polymer.Base.async(function() {
202 expectNaturalScrollValue(touchpadPage, true); 269 expectNaturalScrollValue(pointersPage, false);
203 done(); 270
271 MockInteractions.pressEnter(naturalScrollOn);
272 Polymer.Base.async(function() {
273 expectNaturalScrollValue(pointersPage, true);
274 done();
275 }, 1);
204 }, 1); 276 }, 1);
205 }, 1); 277 });
206 }); 278 });
207 }); 279 });
208 280
209 test(assert(TestNames.Keyboard), function() { 281 test(assert(TestNames.Keyboard), function() {
210 // Open the keyboard subpage. 282 // Open the keyboard subpage.
211 return showAndGetDeviceSubpage('keyboard').then(function(keyboardPage) { 283 return showAndGetDeviceSubpage('keyboard').then(function(keyboardPage) {
212 // Initially, the optional keys are hidden. 284 // Initially, the optional keys are hidden.
213 expectFalse(!!keyboardPage.$$('#capsLockKey')); 285 expectFalse(!!keyboardPage.$$('#capsLockKey'));
214 expectFalse(!!keyboardPage.$$('#diamondKey')); 286 expectFalse(!!keyboardPage.$$('#diamondKey'));
215 287
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 expectTrue(displayPage.showMirror_(displayPage.displays)); 469 expectTrue(displayPage.showMirror_(displayPage.displays));
398 expectTrue(displayPage.isMirrored_(displayPage.displays)); 470 expectTrue(displayPage.isMirrored_(displayPage.displays));
399 }); 471 });
400 }); 472 });
401 }); 473 });
402 474
403 return { 475 return {
404 TestNames: TestNames 476 TestNames: TestNames
405 }; 477 };
406 }); 478 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698