OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/shell/renderer/test_runner/event_sender.h" | 5 #include "content/shell/renderer/test_runner/event_sender.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1272 // event. This seems to work in the cases I tested. | 1272 // event. This seems to work in the cases I tested. |
1273 // FIXME: Should we also generate a KEY_UP? | 1273 // FIXME: Should we also generate a KEY_UP? |
1274 | 1274 |
1275 bool generate_char = false; | 1275 bool generate_char = false; |
1276 | 1276 |
1277 // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when | 1277 // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when |
1278 // Windows uses \r for "Enter". | 1278 // Windows uses \r for "Enter". |
1279 int code = 0; | 1279 int code = 0; |
1280 int text = 0; | 1280 int text = 0; |
1281 bool needs_shift_key_modifier = false; | 1281 bool needs_shift_key_modifier = false; |
1282 std::string domString; | 1282 std::string domString; |
Wez
2015/04/21 02:25:58
Looks like this should be domCode, to match naming
Habib Virji
2015/04/29 16:05:18
Done.
| |
1283 std::string domKey; | |
1283 | 1284 |
1284 if ("\n" == code_str) { | 1285 if ("\n" == code_str) { |
1285 generate_char = true; | 1286 generate_char = true; |
1286 text = code = ui::VKEY_RETURN; | 1287 text = code = ui::VKEY_RETURN; |
1287 domString.assign("Enter"); | 1288 domString.assign("Enter"); |
1288 } else if ("rightArrow" == code_str) { | 1289 } else if ("rightArrow" == code_str) { |
1289 code = ui::VKEY_RIGHT; | 1290 code = ui::VKEY_RIGHT; |
1290 domString.assign("ArrowRight"); | 1291 domString.assign("ArrowRight"); |
1291 } else if ("downArrow" == code_str) { | 1292 } else if ("downArrow" == code_str) { |
1292 code = ui::VKEY_DOWN; | 1293 code = ui::VKEY_DOWN; |
(...skipping 21 matching lines...) Expand all Loading... | |
1314 domString.assign("Home"); | 1315 domString.assign("Home"); |
1315 } else if ("end" == code_str) { | 1316 } else if ("end" == code_str) { |
1316 code = ui::VKEY_END; | 1317 code = ui::VKEY_END; |
1317 domString.assign("End"); | 1318 domString.assign("End"); |
1318 } else if ("printScreen" == code_str) { | 1319 } else if ("printScreen" == code_str) { |
1319 code = ui::VKEY_SNAPSHOT; | 1320 code = ui::VKEY_SNAPSHOT; |
1320 domString.assign("PrintScreen"); | 1321 domString.assign("PrintScreen"); |
1321 } else if ("menu" == code_str) { | 1322 } else if ("menu" == code_str) { |
1322 code = ui::VKEY_APPS; | 1323 code = ui::VKEY_APPS; |
1323 domString.assign("ContextMenu"); | 1324 domString.assign("ContextMenu"); |
1325 domKey.assign("MediaApps"); | |
1324 } else if ("leftControl" == code_str) { | 1326 } else if ("leftControl" == code_str) { |
1325 code = ui::VKEY_LCONTROL; | 1327 code = ui::VKEY_LCONTROL; |
1326 domString.assign("ControlLeft"); | 1328 domString.assign("ControlLeft"); |
1329 domKey.assign("Control"); | |
1327 } else if ("rightControl" == code_str) { | 1330 } else if ("rightControl" == code_str) { |
1328 code = ui::VKEY_RCONTROL; | 1331 code = ui::VKEY_RCONTROL; |
1329 domString.assign("ControlRight"); | 1332 domString.assign("ControlRight"); |
1333 domKey.assign("Control"); | |
1330 } else if ("leftShift" == code_str) { | 1334 } else if ("leftShift" == code_str) { |
1331 code = ui::VKEY_LSHIFT; | 1335 code = ui::VKEY_LSHIFT; |
1332 domString.assign("ShiftLeft"); | 1336 domString.assign("ShiftLeft"); |
1337 domKey.assign("Shift"); | |
1333 } else if ("rightShift" == code_str) { | 1338 } else if ("rightShift" == code_str) { |
1334 code = ui::VKEY_RSHIFT; | 1339 code = ui::VKEY_RSHIFT; |
1335 domString.assign("ShiftRight"); | 1340 domString.assign("ShiftRight"); |
1341 domKey.assign("Shift"); | |
1336 } else if ("leftAlt" == code_str) { | 1342 } else if ("leftAlt" == code_str) { |
1337 code = ui::VKEY_LMENU; | 1343 code = ui::VKEY_LMENU; |
1338 domString.assign("AltLeft"); | 1344 domString.assign("AltLeft"); |
1345 domKey.assign("Alt"); | |
1339 } else if ("rightAlt" == code_str) { | 1346 } else if ("rightAlt" == code_str) { |
1340 code = ui::VKEY_RMENU; | 1347 code = ui::VKEY_RMENU; |
1341 domString.assign("AltRight"); | 1348 domString.assign("AltRight"); |
1349 domKey.assign("AltGraph"); | |
1342 } else if ("numLock" == code_str) { | 1350 } else if ("numLock" == code_str) { |
1343 code = ui::VKEY_NUMLOCK; | 1351 code = ui::VKEY_NUMLOCK; |
1344 domString.assign("NumLock"); | 1352 domString.assign("NumLock"); |
1345 } else if ("backspace" == code_str) { | 1353 } else if ("backspace" == code_str) { |
1346 code = ui::VKEY_BACK; | 1354 code = ui::VKEY_BACK; |
1347 domString.assign("Backspace"); | 1355 domString.assign("Backspace"); |
1348 } else if ("escape" == code_str) { | 1356 } else if ("escape" == code_str) { |
1349 code = ui::VKEY_ESCAPE; | 1357 code = ui::VKEY_ESCAPE; |
1350 domString.assign("Escape"); | 1358 domString.assign("Escape"); |
1351 } else { | 1359 } else { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1392 // pair; | 1400 // pair; |
1393 // On Windows, we might also need to generate a char event to mimic the | 1401 // On Windows, we might also need to generate a char event to mimic the |
1394 // Windows event flow; on other platforms we create a merged event and test | 1402 // Windows event flow; on other platforms we create a merged event and test |
1395 // the event flow that that platform provides. | 1403 // the event flow that that platform provides. |
1396 WebKeyboardEvent event_down; | 1404 WebKeyboardEvent event_down; |
1397 event_down.type = WebInputEvent::RawKeyDown; | 1405 event_down.type = WebInputEvent::RawKeyDown; |
1398 event_down.modifiers = modifiers; | 1406 event_down.modifiers = modifiers; |
1399 event_down.windowsKeyCode = code; | 1407 event_down.windowsKeyCode = code; |
1400 event_down.domCode = static_cast<int>( | 1408 event_down.domCode = static_cast<int>( |
1401 ui::KeycodeConverter::CodeStringToDomCode(domString.c_str())); | 1409 ui::KeycodeConverter::CodeStringToDomCode(domString.c_str())); |
1410 if (domKey.empty()) | |
1411 domKey = domString; | |
Wez
2015/04/21 02:25:58
This looks wrong; DOM |code| and |key| are differe
Habib Virji
2015/04/29 16:05:18
Agreed but for some keys such as Enter, ArrowRight
Wez
2015/05/07 00:23:22
It doesn't make sense in general, though, since th
Habib Virji
2015/05/19 16:16:28
I agree with the point you are making and it appea
| |
1412 event_down.domKey = static_cast<int>( | |
1413 ui::KeycodeConverter::KeyStringToDomKey(domKey.c_str())); | |
Wez
2015/05/07 00:23:22
This handles the DomKey enum values, but those onl
Habib Virji
2015/05/19 16:16:28
This is already handled in unmodifiedText: https:/
| |
1402 | 1414 |
1403 if (generate_char) { | 1415 if (generate_char) { |
1404 event_down.text[0] = text; | 1416 event_down.text[0] = text; |
1405 event_down.unmodifiedText[0] = text; | 1417 event_down.unmodifiedText[0] = text; |
1406 } | 1418 } |
1407 | 1419 |
1408 event_down.setKeyIdentifierFromWindowsKeyCode(); | 1420 event_down.setKeyIdentifierFromWindowsKeyCode(); |
1409 | 1421 |
1410 if (event_down.modifiers != 0) | 1422 if (event_down.modifiers != 0) |
1411 event_down.isSystemKey = IsSystemKeyEvent(event_down); | 1423 event_down.isSystemKey = IsSystemKeyEvent(event_down); |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2481 | 2493 |
2482 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { | 2494 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { |
2483 if (WebPagePopup* popup = view_->pagePopup()) { | 2495 if (WebPagePopup* popup = view_->pagePopup()) { |
2484 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2496 if (!WebInputEvent::isKeyboardEventType(event.type)) |
2485 return popup->handleInputEvent(event); | 2497 return popup->handleInputEvent(event); |
2486 } | 2498 } |
2487 return view_->handleInputEvent(event); | 2499 return view_->handleInputEvent(event); |
2488 } | 2500 } |
2489 | 2501 |
2490 } // namespace content | 2502 } // namespace content |
OLD | NEW |