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

Side by Side Diff: chrome/test/data/chromeos/virtual_keyboard/typing_test.js

Issue 99923003: Adds unit tests for swipe flick. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@flickv2
Patch Set: Fixed the nit. Created 7 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 | « no previous file | chrome/test/data/chromeos/virtual_keyboard/virtual_keyboard_test_base.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The Chromium Authors. All rights reserved. 2 * Copyright 2013 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * Tester for lonpress typing accents. 8 * Tester for lonpress typing accents.
9 */ 9 */
10 function LongPressTypingTester(layout) { 10 function LongPressTypingTester(layout) {
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 charValue: unicodeValue, 298 charValue: unicodeValue,
299 keyCode: 0x41, 299 keyCode: 0x41,
300 modifiers: Modifier.NONE 300 modifiers: Modifier.NONE
301 }); 301 });
302 key.down(mockEvent); 302 key.down(mockEvent);
303 key.out(mockEvent); 303 key.out(mockEvent);
304 mockTypeCharacter('s', 0x53, Modifier.NONE); 304 mockTypeCharacter('s', 0x53, Modifier.NONE);
305 }; 305 };
306 onKeyboardReady('testFingerOutType', runTest, testDoneCallback); 306 onKeyboardReady('testFingerOutType', runTest, testDoneCallback);
307 } 307 }
308
309 /**
310 * Tests that flicking upwards on a key with hintText types the hint text.
311 * @param {Function} testDoneCallback The callback function on completion.
312 */
313 function testSwipeFlick(testDoneCallback) {
314 var mockEvent = function(xOffset, yOffset, target, relatedTarget) {
315 var bounds = target.getBoundingClientRect();
316 return {
317 pointerId: 1,
318 isPrimary: true,
319 screenX: bounds.left + xOffset,
320 // Note: Y is negative in the 'up' direction.
321 screenY: bounds.bottom - yOffset,
322 target: target,
323 relatedTarget: relatedTarget
324 };
325 }
326 var runTest = function() {
327 var key = findKey('.');
328 var send = chrome.virtualKeyboardPrivate.sendKeyEvent;
329 // Test flick on the '.', expect '?' to appear.
330 send.addExpectation({
331 type: 'keydown',
332 charValue: '?'.charCodeAt(0),
333 keyCode: 0xBF,
334 modifiers: Modifier.SHIFT
335 });
336 send.addExpectation({
337 type: 'keyup',
338 charValue: '?'.charCodeAt(0),
339 keyCode: 0xBF,
340 modifiers: Modifier.SHIFT
341 });
342 var height = key.clientHeight;
343 var width = key.clientWidth;
344 $('keyboard').down(mockEvent(0, 0, key));
345 $('keyboard').move(mockEvent(0, height/2, key));
346 $('keyboard').up(mockEvent(0, height/2, key));
347
348 // Test flick that exits the keyboard area. Expect '1' to appear.
349 var qKey = findKey('q');
350 send.addExpectation({
351 type: 'keydown',
352 charValue: '1'.charCodeAt(0),
353 keyCode: 0x31,
354 modifiers: Modifier.NONE
355 });
356 send.addExpectation({
357 type: 'keyup',
358 charValue: '1'.charCodeAt(0),
359 keyCode: 0x31,
360 modifiers: Modifier.NONE
361 });
362 $('keyboard').down(mockEvent(width/2, height/2, qKey));
363 $('keyboard').move(mockEvent(width/2, height, qKey));
364 $('keyboard').out(mockEvent(width/2, 2*height, qKey, $('keyboard')));
365
366 // Test basic long flick. Should not have any output.
367 $('keyboard').down(mockEvent(0, 0, key));
368 $('keyboard').move(mockEvent(0, height/2, key));
369 $('keyboard').move(mockEvent(0, 2*height, key));
370 $('keyboard').up(mockEvent(0, 2*height, key));
371
372 // Test flick that crosses the original key boundary.
373 send.addExpectation({
374 type: 'keydown',
375 charValue: '?'.charCodeAt(0),
376 keyCode: 0xBF,
377 modifiers: Modifier.SHIFT
378 });
379 send.addExpectation({
380 type: 'keyup',
381 charValue: '?'.charCodeAt(0),
382 keyCode: 0xBF,
383 modifiers: Modifier.SHIFT
384 });
385 var lKey = findKey('l');
386 $('keyboard').down(mockEvent(0, height/2, key));
387 $('keyboard').move(mockEvent(0, height, key));
388 key.out(mockEvent(0, height, key, lKey));
389 $('keyboard').move(mockEvent(0, height/2, lKey));
390 $('keyboard').up(mockEvent(0, height/2, lKey));
391
392 // Test long flick that crosses the original key boundary.
393 $('keyboard').down(mockEvent(0, 0, key));
394 $('keyboard').move(mockEvent(0, height/2, key));
395 key.out(mockEvent(0, height, key, lKey));
396 $('keyboard').move(mockEvent(0, height, lKey));
397 $('keyboard').up(mockEvent(0, height, lKey));
398
399 // Test composed swipe and flick. Should not have any output.
400 var move = chrome.virtualKeyboardPrivate.moveCursor;
401 move.addExpectation(SwipeDirection.RIGHT,
402 Modifier.CONTROL & Modifier.SHIFT);
403 $('keyboard').down(mockEvent(0, 0, key));
404 $('keyboard').move(mockEvent(0, height, key));
405 $('keyboard').move(mockEvent(width, height, key));
406 $('keyboard').up(mockEvent(width, height, key));
407 };
408 onKeyboardReady('testSwipeFlick', runTest, testDoneCallback);
409 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/chromeos/virtual_keyboard/virtual_keyboard_test_base.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698