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

Side by Side Diff: chrome/test/webdriver/keymap.cc

Issue 3165064: Move the keyboard files from base/ to app/. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: latest merge Created 10 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 unified diff | Download patch
« no previous file with comments | « chrome/test/webdriver/keymap.h ('k') | remoting/host/event_executor_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/test/webdriver/keymap.h" 5 #include "chrome/test/webdriver/keymap.h"
6 6
7 #include "chrome/browser/automation/ui_controls.h" 7 #include "chrome/browser/automation/ui_controls.h"
8 #include "views/event.h" 8 #include "views/event.h"
9 9
10 namespace webdriver { 10 namespace webdriver {
11 11
12 KeyMap::KeyMap() { 12 KeyMap::KeyMap() {
13 // These are keys stored in the Unicode PUA (Private Use Area) code points, 13 // These are keys stored in the Unicode PUA (Private Use Area) code points,
14 // 0xE000-0xF8FF. 14 // 0xE000-0xF8FF.
15 15
16 // Special WebDriver NULL key; clears all modifiers. 16 // Special WebDriver NULL key; clears all modifiers.
17 keys_[L'\uE000'] = base::VKEY_UNKNOWN; 17 keys_[L'\uE000'] = app::VKEY_UNKNOWN;
18 18
19 keys_[L'\uE001'] = base::VKEY_UNKNOWN; // TODO(jmikhail): CANCEL 19 keys_[L'\uE001'] = app::VKEY_UNKNOWN; // TODO(jmikhail): CANCEL
20 keys_[L'\uE002'] = base::VKEY_HELP; 20 keys_[L'\uE002'] = app::VKEY_HELP;
21 keys_[L'\uE003'] = base::VKEY_BACK; // BACKSPACE 21 keys_[L'\uE003'] = app::VKEY_BACK; // BACKSPACE
22 keys_[L'\uE004'] = base::VKEY_TAB; 22 keys_[L'\uE004'] = app::VKEY_TAB;
23 keys_[L'\uE005'] = base::VKEY_CLEAR; 23 keys_[L'\uE005'] = app::VKEY_CLEAR;
24 keys_[L'\uE006'] = base::VKEY_RETURN; 24 keys_[L'\uE006'] = app::VKEY_RETURN;
25 keys_[L'\uE007'] = base::VKEY_UNKNOWN; // TODO(jmikhail): ENTER 25 keys_[L'\uE007'] = app::VKEY_UNKNOWN; // TODO(jmikhail): ENTER
26 keys_[L'\uE008'] = base::VKEY_SHIFT; 26 keys_[L'\uE008'] = app::VKEY_SHIFT;
27 keys_[L'\uE009'] = base::VKEY_CONTROL; 27 keys_[L'\uE009'] = app::VKEY_CONTROL;
28 keys_[L'\uE00A'] = base::VKEY_MENU; // ALT 28 keys_[L'\uE00A'] = app::VKEY_MENU; // ALT
29 keys_[L'\uE00B'] = base::VKEY_PAUSE; 29 keys_[L'\uE00B'] = app::VKEY_PAUSE;
30 keys_[L'\uE00C'] = base::VKEY_ESCAPE; 30 keys_[L'\uE00C'] = app::VKEY_ESCAPE;
31 keys_[L'\uE00D'] = base::VKEY_SPACE; 31 keys_[L'\uE00D'] = app::VKEY_SPACE;
32 keys_[L'\uE00E'] = base::VKEY_PRIOR; // PAGEUP 32 keys_[L'\uE00E'] = app::VKEY_PRIOR; // PAGEUP
33 keys_[L'\uE00F'] = base::VKEY_NEXT; // PAGEDOWN 33 keys_[L'\uE00F'] = app::VKEY_NEXT; // PAGEDOWN
34 keys_[L'\uE010'] = base::VKEY_END; 34 keys_[L'\uE010'] = app::VKEY_END;
35 keys_[L'\uE011'] = base::VKEY_HOME; 35 keys_[L'\uE011'] = app::VKEY_HOME;
36 keys_[L'\uE012'] = base::VKEY_LEFT; 36 keys_[L'\uE012'] = app::VKEY_LEFT;
37 keys_[L'\uE013'] = base::VKEY_UP; 37 keys_[L'\uE013'] = app::VKEY_UP;
38 keys_[L'\uE014'] = base::VKEY_RIGHT; 38 keys_[L'\uE014'] = app::VKEY_RIGHT;
39 keys_[L'\uE015'] = base::VKEY_DOWN; 39 keys_[L'\uE015'] = app::VKEY_DOWN;
40 keys_[L'\uE016'] = base::VKEY_INSERT; 40 keys_[L'\uE016'] = app::VKEY_INSERT;
41 keys_[L'\uE017'] = base::VKEY_DELETE; 41 keys_[L'\uE017'] = app::VKEY_DELETE;
42 42
43 keys_[L'\uE01A'] = base::VKEY_NUMPAD0; 43 keys_[L'\uE01A'] = app::VKEY_NUMPAD0;
44 keys_[L'\uE01B'] = base::VKEY_NUMPAD1; 44 keys_[L'\uE01B'] = app::VKEY_NUMPAD1;
45 keys_[L'\uE01C'] = base::VKEY_NUMPAD2; 45 keys_[L'\uE01C'] = app::VKEY_NUMPAD2;
46 keys_[L'\uE01D'] = base::VKEY_NUMPAD3; 46 keys_[L'\uE01D'] = app::VKEY_NUMPAD3;
47 keys_[L'\uE01E'] = base::VKEY_NUMPAD4; 47 keys_[L'\uE01E'] = app::VKEY_NUMPAD4;
48 keys_[L'\uE01F'] = base::VKEY_NUMPAD5; 48 keys_[L'\uE01F'] = app::VKEY_NUMPAD5;
49 keys_[L'\uE020'] = base::VKEY_NUMPAD6; 49 keys_[L'\uE020'] = app::VKEY_NUMPAD6;
50 keys_[L'\uE021'] = base::VKEY_NUMPAD7; 50 keys_[L'\uE021'] = app::VKEY_NUMPAD7;
51 keys_[L'\uE022'] = base::VKEY_NUMPAD8; 51 keys_[L'\uE022'] = app::VKEY_NUMPAD8;
52 keys_[L'\uE023'] = base::VKEY_NUMPAD9; 52 keys_[L'\uE023'] = app::VKEY_NUMPAD9;
53 keys_[L'\uE024'] = base::VKEY_MULTIPLY; 53 keys_[L'\uE024'] = app::VKEY_MULTIPLY;
54 keys_[L'\uE025'] = base::VKEY_ADD; 54 keys_[L'\uE025'] = app::VKEY_ADD;
55 keys_[L'\uE026'] = base::VKEY_SEPARATOR; 55 keys_[L'\uE026'] = app::VKEY_SEPARATOR;
56 keys_[L'\uE027'] = base::VKEY_SUBTRACT; 56 keys_[L'\uE027'] = app::VKEY_SUBTRACT;
57 keys_[L'\uE028'] = base::VKEY_DECIMAL; 57 keys_[L'\uE028'] = app::VKEY_DECIMAL;
58 keys_[L'\uE029'] = base::VKEY_DIVIDE; 58 keys_[L'\uE029'] = app::VKEY_DIVIDE;
59 59
60 keys_[L'\uE031'] = base::VKEY_F1; 60 keys_[L'\uE031'] = app::VKEY_F1;
61 keys_[L'\uE032'] = base::VKEY_F2; 61 keys_[L'\uE032'] = app::VKEY_F2;
62 keys_[L'\uE033'] = base::VKEY_F3; 62 keys_[L'\uE033'] = app::VKEY_F3;
63 keys_[L'\uE034'] = base::VKEY_F4; 63 keys_[L'\uE034'] = app::VKEY_F4;
64 keys_[L'\uE035'] = base::VKEY_F5; 64 keys_[L'\uE035'] = app::VKEY_F5;
65 keys_[L'\uE036'] = base::VKEY_F6; 65 keys_[L'\uE036'] = app::VKEY_F6;
66 keys_[L'\uE037'] = base::VKEY_F7; 66 keys_[L'\uE037'] = app::VKEY_F7;
67 keys_[L'\uE038'] = base::VKEY_F8; 67 keys_[L'\uE038'] = app::VKEY_F8;
68 keys_[L'\uE039'] = base::VKEY_F9; 68 keys_[L'\uE039'] = app::VKEY_F9;
69 keys_[L'\uE03A'] = base::VKEY_F10; 69 keys_[L'\uE03A'] = app::VKEY_F10;
70 keys_[L'\uE03B'] = base::VKEY_F11; 70 keys_[L'\uE03B'] = app::VKEY_F11;
71 keys_[L'\uE03C'] = base::VKEY_F12; 71 keys_[L'\uE03C'] = app::VKEY_F12;
72 72
73 // Common aliases. 73 // Common aliases.
74 keys_[L'\t'] = base::VKEY_TAB; 74 keys_[L'\t'] = app::VKEY_TAB;
75 keys_[L'\n'] = base::VKEY_RETURN; 75 keys_[L'\n'] = app::VKEY_RETURN;
76 keys_[L'\r'] = base::VKEY_RETURN; 76 keys_[L'\r'] = app::VKEY_RETURN;
77 keys_[L'\b'] = base::VKEY_BACK; 77 keys_[L'\b'] = app::VKEY_BACK;
78 78
79 keys_[L' '] = base::VKEY_SPACE; 79 keys_[L' '] = app::VKEY_SPACE;
80 80
81 // Alpha keys match their ASCII values 81 // Alpha keys match their ASCII values
82 for (int i = 0; i < 26; ++i) { 82 for (int i = 0; i < 26; ++i) {
83 keys_[static_cast<wchar_t>(L'a' + i)] = \ 83 keys_[static_cast<wchar_t>(L'a' + i)] = \
84 static_cast<base::KeyboardCode>(base::VKEY_A + i); 84 static_cast<app::KeyboardCode>(app::VKEY_A + i);
85 shifted_keys_[static_cast<wchar_t>(L'A' + i)] = \ 85 shifted_keys_[static_cast<wchar_t>(L'A' + i)] = \
86 static_cast<base::KeyboardCode>(base::VKEY_A + i); 86 static_cast<app::KeyboardCode>(app::VKEY_A + i);
87 } 87 }
88 88
89 // Numeric keys match their ASCII values 89 // Numeric keys match their ASCII values
90 for (int i = 0; i < 10; ++i) { 90 for (int i = 0; i < 10; ++i) {
91 keys_[static_cast<wchar_t>(L'0' + i)] = \ 91 keys_[static_cast<wchar_t>(L'0' + i)] = \
92 static_cast<base::KeyboardCode>(base::VKEY_0 + i); 92 static_cast<app::KeyboardCode>(app::VKEY_0 + i);
93 } 93 }
94 94
95 // The following all assumes the standard US keyboard. 95 // The following all assumes the standard US keyboard.
96 // TODO(jmikhail): Lookup correct keycode based on the current system keyboard 96 // TODO(jmikhail): Lookup correct keycode based on the current system keyboard
97 // layout. Right now it's fixed assuming standard ANSI 97 // layout. Right now it's fixed assuming standard ANSI
98 keys_[L'='] = shifted_keys_[L'+'] = base::VKEY_OEM_PLUS; 98 keys_[L'='] = shifted_keys_[L'+'] = app::VKEY_OEM_PLUS;
99 keys_[L'-'] = shifted_keys_[L'_'] = base::VKEY_OEM_MINUS; 99 keys_[L'-'] = shifted_keys_[L'_'] = app::VKEY_OEM_MINUS;
100 keys_[L';'] = shifted_keys_[L':'] = base::VKEY_OEM_1; 100 keys_[L';'] = shifted_keys_[L':'] = app::VKEY_OEM_1;
101 keys_[L'/'] = shifted_keys_[L'?'] = base::VKEY_OEM_2; 101 keys_[L'/'] = shifted_keys_[L'?'] = app::VKEY_OEM_2;
102 keys_[L'`'] = shifted_keys_[L'~'] = base::VKEY_OEM_3; 102 keys_[L'`'] = shifted_keys_[L'~'] = app::VKEY_OEM_3;
103 keys_[L'['] = shifted_keys_[L'{'] = base::VKEY_OEM_4; 103 keys_[L'['] = shifted_keys_[L'{'] = app::VKEY_OEM_4;
104 keys_[L'\\'] = shifted_keys_[L'|'] = base::VKEY_OEM_5; 104 keys_[L'\\'] = shifted_keys_[L'|'] = app::VKEY_OEM_5;
105 keys_[L']'] = shifted_keys_[L'}'] = base::VKEY_OEM_6; 105 keys_[L']'] = shifted_keys_[L'}'] = app::VKEY_OEM_6;
106 keys_[L'\''] = shifted_keys_[L'"'] = base::VKEY_OEM_7; 106 keys_[L'\''] = shifted_keys_[L'"'] = app::VKEY_OEM_7;
107 keys_[L','] = shifted_keys_[L'<'] = base::VKEY_OEM_COMMA; 107 keys_[L','] = shifted_keys_[L'<'] = app::VKEY_OEM_COMMA;
108 keys_[L'.'] = shifted_keys_[L'>'] = base::VKEY_OEM_PERIOD; 108 keys_[L'.'] = shifted_keys_[L'>'] = app::VKEY_OEM_PERIOD;
109 shifted_keys_[L'!'] = base::VKEY_1; 109 shifted_keys_[L'!'] = app::VKEY_1;
110 shifted_keys_[L'@'] = base::VKEY_2; 110 shifted_keys_[L'@'] = app::VKEY_2;
111 shifted_keys_[L'#'] = base::VKEY_3; 111 shifted_keys_[L'#'] = app::VKEY_3;
112 shifted_keys_[L'$'] = base::VKEY_4; 112 shifted_keys_[L'$'] = app::VKEY_4;
113 shifted_keys_[L'%'] = base::VKEY_5; 113 shifted_keys_[L'%'] = app::VKEY_5;
114 shifted_keys_[L'^'] = base::VKEY_6; 114 shifted_keys_[L'^'] = app::VKEY_6;
115 shifted_keys_[L'&'] = base::VKEY_7; 115 shifted_keys_[L'&'] = app::VKEY_7;
116 shifted_keys_[L'*'] = base::VKEY_8; 116 shifted_keys_[L'*'] = app::VKEY_8;
117 shifted_keys_[L'('] = base::VKEY_9; 117 shifted_keys_[L'('] = app::VKEY_9;
118 shifted_keys_[L')'] = base::VKEY_0; 118 shifted_keys_[L')'] = app::VKEY_0;
119 } 119 }
120 120
121 base::KeyboardCode KeyMap::Get(const wchar_t& key) const { 121 app::KeyboardCode KeyMap::Get(const wchar_t& key) const {
122 std::map<wchar_t, base::KeyboardCode>::const_iterator it; 122 std::map<wchar_t, app::KeyboardCode>::const_iterator it;
123 it = keys_.find(key); 123 it = keys_.find(key);
124 if (it == keys_.end()) { 124 if (it == keys_.end()) {
125 it = shifted_keys_.find(key); 125 it = shifted_keys_.find(key);
126 if (it == shifted_keys_.end()) { 126 if (it == shifted_keys_.end()) {
127 return base::VKEY_UNKNOWN; 127 return app::VKEY_UNKNOWN;
128 } 128 }
129 } 129 }
130 return it->second; 130 return it->second;
131 } 131 }
132 132
133 bool KeyMap::Press(const scoped_refptr<WindowProxy>& window, 133 bool KeyMap::Press(const scoped_refptr<WindowProxy>& window,
134 const base::KeyboardCode key_code, 134 const app::KeyboardCode key_code,
135 const wchar_t& key) { 135 const wchar_t& key) {
136 if (key_code == base::VKEY_SHIFT) { 136 if (key_code == app::VKEY_SHIFT) {
137 shift_ = !shift_; 137 shift_ = !shift_;
138 } else if (key_code == base::VKEY_CONTROL) { 138 } else if (key_code == app::VKEY_CONTROL) {
139 control_ = !control_; 139 control_ = !control_;
140 } else if (key_code == base::VKEY_MENU) { // ALT 140 } else if (key_code == app::VKEY_MENU) { // ALT
141 alt_ = !alt_; 141 alt_ = !alt_;
142 } else if (key_code == base::VKEY_COMMAND) { 142 } else if (key_code == app::VKEY_COMMAND) {
143 command_ = !command_; 143 command_ = !command_;
144 } 144 }
145 145
146 int modifiers = 0; 146 int modifiers = 0;
147 if (shift_ || shifted_keys_.find(key) != shifted_keys_.end()) { 147 if (shift_ || shifted_keys_.find(key) != shifted_keys_.end()) {
148 modifiers = modifiers | views::Event::EF_SHIFT_DOWN; 148 modifiers = modifiers | views::Event::EF_SHIFT_DOWN;
149 } 149 }
150 if (control_) { 150 if (control_) {
151 modifiers = modifiers | views::Event::EF_CONTROL_DOWN; 151 modifiers = modifiers | views::Event::EF_CONTROL_DOWN;
152 } 152 }
(...skipping 12 matching lines...) Expand all
165 } 165 }
166 166
167 void KeyMap::ClearModifiers() { 167 void KeyMap::ClearModifiers() {
168 shift_ = false; 168 shift_ = false;
169 alt_ = false; 169 alt_ = false;
170 control_ = false; 170 control_ = false;
171 command_ = false; 171 command_ = false;
172 } 172 }
173 } // namespace webdriver 173 } // namespace webdriver
174 174
OLDNEW
« no previous file with comments | « chrome/test/webdriver/keymap.h ('k') | remoting/host/event_executor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698