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

Unified Diff: chrome/test/data/chromeos/virtual_keyboard/virtual_keyboard_test_base.js

Issue 25305003: Automated tests for the shift key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits. Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/chromeos/virtual_keyboard/typing_test.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « chrome/test/data/chromeos/virtual_keyboard/typing_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698