Index: chrome/test/data/chromeos/virtual_keyboard/virtual_keyboard_test_base.js |
diff --git a/chrome/test/data/chromeos/virtual_keyboard/virtual_keyboard_test_base.js b/chrome/test/data/chromeos/virtual_keyboard/virtual_keyboard_test_base.js |
index b8150b98d7dfb23e99d21b22d53d833216e6d3bb..21381d612caa52ea88a567e79615e2f344883afa 100644 |
--- a/chrome/test/data/chromeos/virtual_keyboard/virtual_keyboard_test_base.js |
+++ b/chrome/test/data/chromeos/virtual_keyboard/virtual_keyboard_test_base.js |
@@ -120,6 +120,38 @@ function findKey(label) { |
} |
/** |
+ * Mock typing of basic keys. Each keystroke should trigger a pair of |
+ * API calls to send viritual key events. |
+ * @param {string} label The character being typed. |
+ * @param {number} keyCode The legacy key code for the character. |
+ * @param {boolean} shiftModifier Indicates if the shift key is being |
+ * virtually pressed. |
+ * @param {number=} opt_unicode Optional unicode value for the character. Only |
+ * required if it cannot be directly calculated from the label. |
+ */ |
+function mockTypeCharacter(label, keyCode, shiftModifier, opt_unicode) { |
+ var key = findKey(label); |
+ assertTrue(!!key, 'Unable to find key labelled "' + label + '".'); |
+ var unicodeValue = opt_unicode | label.charCodeAt(0); |
+ var send = chrome.virtualKeyboardPrivate.sendKeyEvent; |
+ send.addExpectation({ |
+ type: 'keydown', |
+ charValue: unicodeValue, |
+ keyCode: keyCode, |
+ shiftKey: shiftModifier |
+ }); |
+ send.addExpectation({ |
+ type: 'keyup', |
+ charValue: unicodeValue, |
+ keyCode: keyCode, |
+ shiftKey: shiftModifier |
+ }); |
+ // Fake typing the key. |
+ key.down(); |
+ key.up(); |
+} |
+ |
+/** |
* Triggers a callback function to run post initialization of the virtual |
* keyboard. |
* @param {string} testName The name of the test. |