OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 keyboardEvent->text[0] = keyCode; | 72 keyboardEvent->text[0] = keyCode; |
73 keyboardEvent->setKeyIdentifierFromWindowsKeyCode(); | 73 keyboardEvent->setKeyIdentifierFromWindowsKeyCode(); |
74 } | 74 } |
75 | 75 |
76 // Like interpretKeyEvent, but with pressing down OSModifier+|keyCode|. | 76 // Like interpretKeyEvent, but with pressing down OSModifier+|keyCode|. |
77 // OSModifier is the platform's standard modifier key: control on most | 77 // OSModifier is the platform's standard modifier key: control on most |
78 // platforms, but meta (command) on Mac. | 78 // platforms, but meta (command) on Mac. |
79 const char* interpretOSModifierKeyPress(char keyCode) | 79 const char* interpretOSModifierKeyPress(char keyCode) |
80 { | 80 { |
81 WebKeyboardEvent keyboardEvent; | 81 WebKeyboardEvent keyboardEvent; |
82 #if OS(DARWIN) | 82 #if OS(MACOSX) |
83 WebInputEvent::Modifiers osModifier = WebInputEvent::MetaKey; | 83 WebInputEvent::Modifiers osModifier = WebInputEvent::MetaKey; |
84 #else | 84 #else |
85 WebInputEvent::Modifiers osModifier = WebInputEvent::ControlKey; | 85 WebInputEvent::Modifiers osModifier = WebInputEvent::ControlKey; |
86 #endif | 86 #endif |
87 setupKeyDownEvent(&keyboardEvent, keyCode, osModifier); | 87 setupKeyDownEvent(&keyboardEvent, keyCode, osModifier); |
88 return interpretKeyEvent(keyboardEvent, PlatformEvent::RawKeyDown); | 88 return interpretKeyEvent(keyboardEvent, PlatformEvent::RawKeyDown); |
89 } | 89 } |
90 | 90 |
91 // Like interpretKeyEvent, but with pressing down ctrl+|keyCode|. | 91 // Like interpretKeyEvent, but with pressing down ctrl+|keyCode|. |
92 const char* interpretCtrlKeyPress(char keyCode) | 92 const char* interpretCtrlKeyPress(char keyCode) |
(...skipping 23 matching lines...) Expand all Loading... |
116 static const int noModifiers = 0; | 116 static const int noModifiers = 0; |
117 }; | 117 }; |
118 | 118 |
119 TEST_F(KeyboardTest, TestCtrlReturn) | 119 TEST_F(KeyboardTest, TestCtrlReturn) |
120 { | 120 { |
121 EXPECT_STREQ("InsertNewline", interpretCtrlKeyPress(0xD)); | 121 EXPECT_STREQ("InsertNewline", interpretCtrlKeyPress(0xD)); |
122 } | 122 } |
123 | 123 |
124 TEST_F(KeyboardTest, TestOSModifierZ) | 124 TEST_F(KeyboardTest, TestOSModifierZ) |
125 { | 125 { |
126 #if !OS(DARWIN) | 126 #if !OS(MACOSX) |
127 EXPECT_STREQ("Undo", interpretOSModifierKeyPress('Z')); | 127 EXPECT_STREQ("Undo", interpretOSModifierKeyPress('Z')); |
128 #endif | 128 #endif |
129 } | 129 } |
130 | 130 |
131 TEST_F(KeyboardTest, TestOSModifierY) | 131 TEST_F(KeyboardTest, TestOSModifierY) |
132 { | 132 { |
133 #if !OS(DARWIN) | 133 #if !OS(MACOSX) |
134 EXPECT_STREQ("Redo", interpretOSModifierKeyPress('Y')); | 134 EXPECT_STREQ("Redo", interpretOSModifierKeyPress('Y')); |
135 #endif | 135 #endif |
136 } | 136 } |
137 | 137 |
138 TEST_F(KeyboardTest, TestOSModifierA) | 138 TEST_F(KeyboardTest, TestOSModifierA) |
139 { | 139 { |
140 #if !OS(DARWIN) | 140 #if !OS(MACOSX) |
141 EXPECT_STREQ("SelectAll", interpretOSModifierKeyPress('A')); | 141 EXPECT_STREQ("SelectAll", interpretOSModifierKeyPress('A')); |
142 #endif | 142 #endif |
143 } | 143 } |
144 | 144 |
145 TEST_F(KeyboardTest, TestOSModifierX) | 145 TEST_F(KeyboardTest, TestOSModifierX) |
146 { | 146 { |
147 #if !OS(DARWIN) | 147 #if !OS(MACOSX) |
148 EXPECT_STREQ("Cut", interpretOSModifierKeyPress('X')); | 148 EXPECT_STREQ("Cut", interpretOSModifierKeyPress('X')); |
149 #endif | 149 #endif |
150 } | 150 } |
151 | 151 |
152 TEST_F(KeyboardTest, TestOSModifierC) | 152 TEST_F(KeyboardTest, TestOSModifierC) |
153 { | 153 { |
154 #if !OS(DARWIN) | 154 #if !OS(MACOSX) |
155 EXPECT_STREQ("Copy", interpretOSModifierKeyPress('C')); | 155 EXPECT_STREQ("Copy", interpretOSModifierKeyPress('C')); |
156 #endif | 156 #endif |
157 } | 157 } |
158 | 158 |
159 TEST_F(KeyboardTest, TestOSModifierV) | 159 TEST_F(KeyboardTest, TestOSModifierV) |
160 { | 160 { |
161 #if !OS(DARWIN) | 161 #if !OS(MACOSX) |
162 EXPECT_STREQ("Paste", interpretOSModifierKeyPress('V')); | 162 EXPECT_STREQ("Paste", interpretOSModifierKeyPress('V')); |
163 #endif | 163 #endif |
164 } | 164 } |
165 | 165 |
166 TEST_F(KeyboardTest, TestEscape) | 166 TEST_F(KeyboardTest, TestEscape) |
167 { | 167 { |
168 WebKeyboardEvent keyboardEvent; | 168 WebKeyboardEvent keyboardEvent; |
169 setupKeyDownEvent(&keyboardEvent, WebCore::VKEY_ESCAPE, noModifiers); | 169 setupKeyDownEvent(&keyboardEvent, WebCore::VKEY_ESCAPE, noModifiers); |
170 | 170 |
171 const char* result = interpretKeyEvent(keyboardEvent, | 171 const char* result = interpretKeyEvent(keyboardEvent, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 TEST_F(KeyboardTest, TestInsertNewline4) | 206 TEST_F(KeyboardTest, TestInsertNewline4) |
207 { | 207 { |
208 int modifiers = WebInputEvent::AltKey | WebInputEvent::ShiftKey; | 208 int modifiers = WebInputEvent::AltKey | WebInputEvent::ShiftKey; |
209 const char* result = interpretNewLine(modifiers); | 209 const char* result = interpretNewLine(modifiers); |
210 EXPECT_STREQ("InsertNewline", result); | 210 EXPECT_STREQ("InsertNewline", result); |
211 } | 211 } |
212 | 212 |
213 } // empty namespace | 213 } // empty namespace |
OLD | NEW |