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

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

Issue 255823004: Adds shift and capslock tests to IME Keyboard tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The Chromium Authors. All rights reserved. 2 * Copyright 2014 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 var mockController; 7 var mockController;
8 var mockTimer; 8 var mockTimer;
9 var setComposition; 9 var setComposition;
10 10
11 var DEFAULT_CONTEXT_ID = 0; 11 var DEFAULT_CONTEXT_ID = 0;
12 var LONGPRESS_DELAY = 1100; 12 var LONGPRESS_DELAY = 1100;
13 var CAPSLOCK_ID = "OsLeft";
13 14
14 /** 15 /**
15 * Key alignments. 16 * Key alignments.
16 * @enum {string} 17 * @enum {string}
17 */ 18 */
18 var Alignment = { 19 var Alignment = {
19 LEFT: 'left', 20 LEFT: 'left',
20 RIGHT: 'right', 21 RIGHT: 'right',
21 CENTER: 'center' 22 CENTER: 'center'
22 }; 23 };
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 * @param target {Object} The target of the event. 76 * @param target {Object} The target of the event.
76 * @param type {String} The type of the mouse event. 77 * @param type {String} The type of the mouse event.
77 */ 78 */
78 function generateMouseEvent(target, type) { 79 function generateMouseEvent(target, type) {
79 var e = document.createEvent('MouseEvents'); 80 var e = document.createEvent('MouseEvents');
80 e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1)); 81 e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1));
81 target.dispatchEvent(e); 82 target.dispatchEvent(e);
82 } 83 }
83 84
84 /** 85 /**
85 * Mocks a character type using the mouse. 86 * Mocks a key type using the mouse.
87 * @param {Object} key The key to click on.
88 */
89 function mockMouseTypeOnKey(key) {
90 generateMouseEvent(key, 'mouseover', true, true);
91 generateMouseEvent(key, 'mousedown', true, true);
92 generateMouseEvent(key, 'mouseup', true, true);
93 generateMouseEvent(key, 'click', true, true);
94 generateMouseEvent(key, 'mouseover', true, true);
95 generateMouseEvent(key, 'mouseout', true, true);
96 }
97
98 /**
99 * Mocks a character type using the mouse. Expects the character will be
100 * committed.
86 * @param {String} char The character to type. 101 * @param {String} char The character to type.
87 */ 102 */
88 function mockMouseType(char) { 103 function mockMouseType(char) {
89 var send = chrome.input.ime.commitText; 104 var send = chrome.input.ime.commitText;
90 send.addExpectation({ 105 send.addExpectation({
91 contextId: DEFAULT_CONTEXT_ID, 106 contextId: DEFAULT_CONTEXT_ID,
92 text: char, 107 text: char,
93 }); 108 });
94 var key = getKey(char); 109 var key = getKey(char);
95 generateMouseEvent(key, 'mouseover', true, true); 110 mockMouseTypeOnKey(key);
96 generateMouseEvent(key, 'mousedown', true, true);
97 generateMouseEvent(key, 'mouseup', true, true);
98 generateMouseEvent(key, 'click', true, true);
99 generateMouseEvent(key, 'mouseover', true, true);
100 generateMouseEvent(key, 'mouseout', true, true);
101 } 111 }
102 112
103 /** 113 /**
104 * Generates a touch event and dispatches it on the target. 114 * Generates a touch event and dispatches it on the target.
105 * @param target {Object} The target of the event. 115 * @param target {Object} The target of the event.
106 * @param type {String} The type of the touch event. 116 * @param type {String} The type of the touch event.
107 */ 117 */
108 function generateTouchEvent(target, type) { 118 function generateTouchEvent(target, type) {
109 var e = document.createEvent('UIEvents'); 119 var e = document.createEvent('UIEvents');
110 e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1)); 120 e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 send.addExpectation({ 194 send.addExpectation({
185 contextId: DEFAULT_CONTEXT_ID, 195 contextId: DEFAULT_CONTEXT_ID,
186 text: selection, 196 text: selection,
187 }); 197 });
188 // TODO(rsadam:) Add support for touch move here once latest CRX uploaded to 198 // TODO(rsadam:) Add support for touch move here once latest CRX uploaded to
189 // chrome/test/data. 199 // chrome/test/data.
190 generateTouchEvent(key, 'touchend', true, true) 200 generateTouchEvent(key, 'touchend', true, true)
191 container = getActiveAltContainer(); 201 container = getActiveAltContainer();
192 assertFalse(!!container, "Alt key container was not hidden."); 202 assertFalse(!!container, "Alt key container was not hidden.");
193 } 203 }
204
205 /**
206 * Retrieves the shift key from the current keyset.
207 * @param {Alignment} align The alignment of the shift key.
208 * @return {Object} The key.
209 */
210 function getShiftKey(align) {
211 var id;
212 switch(align) {
213 case Alignment.LEFT:
214 id = 'ShiftLeft';
215 break;
216 case Alignment.RIGHT:
217 id = 'ShiftRight';
218 break;
219 default:
220 break;
221 }
222 assertTrue(!!id, "Invalid shift alignment option: " + align);
223 var shift = document.querySelector('#' + id);
224 assertTrue(!!shift, "Cannot find shift key with alignment: " + align);
225 return shift;
226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698