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

Side by Side Diff: content/test/layout_tests/runner/KeyCodeMapping.cpp

Issue 110533009: Import TestRunner library into chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /*
6 * Copyright (C) 2012 Google Inc. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Google Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "content/test/layout_tests/runner/KeyCodeMapping.h"
36
37 #include "content/test/layout_tests/runner/TestCommon.h"
38
39 namespace WebTestRunner {
40
41 int NativeKeyCodeForWindowsKeyCode(int keysym)
42 {
43 #if defined(__linux__) && defined(TOOLKIT_GTK)
44 // See /usr/share/X11/xkb/keycodes/*
45 static const int asciiToKeyCode[] = {
46 0,
47 0,
48 0,
49 0,
50 0,
51 0,
52 0,
53 0,
54 22,
55 23,
56 0,
57 0,
58 0,
59 36,
60 0,
61 0,
62 50,
63 37,
64 64,
65 127,
66 66,
67 0,
68 0,
69 0,
70 0,
71 131,
72 0,
73 9,
74 100,
75 102,
76 0,
77 0,
78 65, // ' '
79 112, // '!'
80 117, // '"'
81 115, // '#'
82 110, // '$'
83 113, // '%'
84 111, // '&'
85 114, // '''
86 116, // '('
87 0, // ')'
88 107, // '*'
89 0, // '+'
90 0, // ','
91 118, // '-'
92 119, // '.'
93 146, // '/'
94 19, // '0'
95 10, // '1'
96 11, // '2'
97 12, // '3'
98 13, // '4'
99 14, // '5'
100 15, // '6'
101 16, // '7'
102 17, // '8'
103 18, // '9'
104 0, // ':'
105 0, // ';'
106 0, // '<'
107 0, // '='
108 0, // '>'
109 0, // '?'
110 0, // '@'
111 38, // 'A'
112 56, // 'B'
113 54, // 'C'
114 40, // 'D'
115 26, // 'E'
116 41, // 'F'
117 42, // 'G'
118 43, // 'H'
119 31, // 'I'
120 44, // 'J'
121 45, // 'K'
122 46, // 'L'
123 58, // 'M'
124 57, // 'N'
125 32, // 'O'
126 33, // 'P'
127 24, // 'Q'
128 27, // 'R'
129 39, // 'S'
130 28, // 'T'
131 30, // 'U'
132 55, // 'V'
133 25, // 'W'
134 53, // 'X'
135 29, // 'Y'
136 52, // 'Z'
137 133, // '['
138 134, // '\'
139 135, // ']'
140 0, // '^'
141 0, // '_'
142 90, // '`'
143 38, // 'a'
144 56, // 'b'
145 54, // 'c'
146 40, // 'd'
147 26, // 'e'
148 41, // 'f'
149 42, // 'g'
150 43, // 'h'
151 31, // 'i'
152 44, // 'j'
153 45, // 'k'
154 46, // 'l'
155 58, // 'm'
156 57, // 'n'
157 32, // 'o'
158 33, // 'p'
159 24, // 'q'
160 27, // 'r'
161 39, // 's'
162 28, // 't'
163 30, // 'u'
164 55, // 'v'
165 25, // 'w'
166 53, // 'x'
167 29, // 'y'
168 52, // 'z'
169 96, // '{'
170 0, // '|'
171 0, // '}'
172 0, // '~'
173 0, // DEL
174 };
175
176 if (keysym <= 127)
177 return asciiToKeyCode[keysym];
178
179 switch (keysym) {
180 case VKEY_PRIOR:
181 return 112;
182 case VKEY_NEXT:
183 return 117;
184 case VKEY_END:
185 return 115;
186 case VKEY_HOME:
187 return 110;
188 case VKEY_LEFT:
189 return 113;
190 case VKEY_UP:
191 return 111;
192 case VKEY_RIGHT:
193 return 114;
194 case VKEY_DOWN:
195 return 116;
196 case VKEY_SNAPSHOT:
197 return 107;
198 case VKEY_INSERT:
199 return 118;
200 case VKEY_DELETE:
201 return 119;
202 case VKEY_APPS:
203 return 135;
204 case VKEY_F1:
205 case VKEY_F1 + 1:
206 case VKEY_F1 + 2:
207 case VKEY_F1 + 3:
208 case VKEY_F1 + 4:
209 case VKEY_F1 + 5:
210 case VKEY_F1 + 6:
211 case VKEY_F1 + 7:
212 case VKEY_F1 + 8:
213 case VKEY_F1 + 9:
214 case VKEY_F1 + 10:
215 case VKEY_F1 + 11:
216 case VKEY_F1 + 12:
217 case VKEY_F1 + 13:
218 case VKEY_F1 + 14:
219 case VKEY_F1 + 15:
220 case VKEY_F1 + 16:
221 case VKEY_F1 + 17:
222 case VKEY_F1 + 18:
223 case VKEY_F1 + 19:
224 case VKEY_F1 + 20:
225 case VKEY_F1 + 21:
226 case VKEY_F1 + 22:
227 case VKEY_F1 + 23:
228 return 67 + (keysym - VKEY_F1);
229 case VKEY_LSHIFT:
230 return 50;
231 case VKEY_RSHIFT:
232 return 62;
233 case VKEY_LCONTROL:
234 return 37;
235 case VKEY_RCONTROL:
236 return 105;
237 case VKEY_LMENU:
238 return 64;
239 case VKEY_RMENU:
240 return 108;
241 case VKEY_NUMLOCK:
242 return 77;
243
244 default:
245 return 0;
246 }
247 #else
248 return keysym - keysym;
249 #endif
250 }
251
252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698