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

Side by Side Diff: components/test_runner/event_sender.cc

Issue 2039233002: Allow the exact DOM Code value to be sent from layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/test_runner/event_sender.h" 5 #include "components/test_runner/event_sender.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 bool generate_char = false; 1390 bool generate_char = false;
1391 1391
1392 // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when 1392 // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when
1393 // Windows uses \r for "Enter". 1393 // Windows uses \r for "Enter".
1394 int code = 0; 1394 int code = 0;
1395 int text = 0; 1395 int text = 0;
1396 bool needs_shift_key_modifier = false; 1396 bool needs_shift_key_modifier = false;
1397 std::string domKeyString; 1397 std::string domKeyString;
1398 std::string domCodeString; 1398 std::string domCodeString;
1399 1399
1400 if ("\n" == code_str) { 1400 // TODO(dtapuska): Convert all layout tests to use the proper code_str
1401 // values that match the DOM Code specification. crbug.com/617606
1402 if ("\n" == code_str ||
1403 "Enter" == code_str) {
1401 generate_char = true; 1404 generate_char = true;
1402 text = code = ui::VKEY_RETURN; 1405 text = code = ui::VKEY_RETURN;
1403 domKeyString.assign("Enter"); 1406 domKeyString.assign("Enter");
1404 domCodeString.assign("Enter"); 1407 domCodeString.assign("Enter");
1405 } else if ("rightArrow" == code_str) { 1408 } else if ("rightArrow" == code_str ||
1409 "ArrowRight" == code_str) {
1406 code = ui::VKEY_RIGHT; 1410 code = ui::VKEY_RIGHT;
1407 domKeyString.assign("ArrowRight"); 1411 domKeyString.assign("ArrowRight");
1408 domCodeString.assign("ArrowRight"); 1412 domCodeString.assign("ArrowRight");
1409 } else if ("downArrow" == code_str) { 1413 } else if ("downArrow" == code_str ||
1414 "ArrowDown" == code_str) {
1410 code = ui::VKEY_DOWN; 1415 code = ui::VKEY_DOWN;
1411 domKeyString.assign("ArrowDown"); 1416 domKeyString.assign("ArrowDown");
1412 domCodeString.assign("ArrowDown"); 1417 domCodeString.assign("ArrowDown");
1413 } else if ("leftArrow" == code_str) { 1418 } else if ("leftArrow" == code_str ||
1419 "ArrowLeft" == code_str) {
1414 code = ui::VKEY_LEFT; 1420 code = ui::VKEY_LEFT;
1415 domKeyString.assign("ArrowLeft"); 1421 domKeyString.assign("ArrowLeft");
1416 domCodeString.assign("ArrowLeft"); 1422 domCodeString.assign("ArrowLeft");
1417 } else if ("upArrow" == code_str) { 1423 } else if ("upArrow" == code_str ||
1424 "ArrowUp" == code_str) {
1418 code = ui::VKEY_UP; 1425 code = ui::VKEY_UP;
1419 domKeyString.assign("ArrowUp"); 1426 domKeyString.assign("ArrowUp");
1420 domCodeString.assign("ArrowUp"); 1427 domCodeString.assign("ArrowUp");
1421 } else if ("insert" == code_str) { 1428 } else if ("insert" == code_str ||
1429 "Insert" == code_str) {
1422 code = ui::VKEY_INSERT; 1430 code = ui::VKEY_INSERT;
1423 domKeyString.assign("Insert"); 1431 domKeyString.assign("Insert");
1424 domCodeString.assign("Insert"); 1432 domCodeString.assign("Insert");
1425 } else if ("delete" == code_str) { 1433 } else if ("delete" == code_str ||
1434 "Delete" == code_str) {
1426 code = ui::VKEY_DELETE; 1435 code = ui::VKEY_DELETE;
1427 domKeyString.assign("Delete"); 1436 domKeyString.assign("Delete");
1428 domCodeString.assign("Delete"); 1437 domCodeString.assign("Delete");
1429 } else if ("pageUp" == code_str) { 1438 } else if ("pageUp" == code_str ||
1439 "PageUp" == code_str) {
1430 code = ui::VKEY_PRIOR; 1440 code = ui::VKEY_PRIOR;
1431 domKeyString.assign("PageUp"); 1441 domKeyString.assign("PageUp");
1432 domCodeString.assign("PageUp"); 1442 domCodeString.assign("PageUp");
1433 } else if ("pageDown" == code_str) { 1443 } else if ("pageDown" == code_str ||
1444 "PageDown" == code_str) {
1434 code = ui::VKEY_NEXT; 1445 code = ui::VKEY_NEXT;
1435 domKeyString.assign("PageDown"); 1446 domKeyString.assign("PageDown");
1436 domCodeString.assign("PageDown"); 1447 domCodeString.assign("PageDown");
1437 } else if ("home" == code_str) { 1448 } else if ("home" == code_str ||
1449 "Home" == code_str) {
1438 code = ui::VKEY_HOME; 1450 code = ui::VKEY_HOME;
1439 domKeyString.assign("Home"); 1451 domKeyString.assign("Home");
1440 domCodeString.assign("Home"); 1452 domCodeString.assign("Home");
1441 } else if ("end" == code_str) { 1453 } else if ("end" == code_str ||
1454 "End" == code_str) {
1442 code = ui::VKEY_END; 1455 code = ui::VKEY_END;
1443 domKeyString.assign("End"); 1456 domKeyString.assign("End");
1444 domCodeString.assign("End"); 1457 domCodeString.assign("End");
1445 } else if ("printScreen" == code_str) { 1458 } else if ("printScreen" == code_str ||
1459 "PrintScreen" == code_str) {
1446 code = ui::VKEY_SNAPSHOT; 1460 code = ui::VKEY_SNAPSHOT;
1447 domKeyString.assign("PrintScreen"); 1461 domKeyString.assign("PrintScreen");
1448 domCodeString.assign("PrintScreen"); 1462 domCodeString.assign("PrintScreen");
1449 } else if ("menu" == code_str) { 1463 } else if ("menu" == code_str ||
1464 "ContextMenu" == code_str) {
1450 code = ui::VKEY_APPS; 1465 code = ui::VKEY_APPS;
1451 domKeyString.assign("ContextMenu"); 1466 domKeyString.assign("ContextMenu");
1452 domCodeString.assign("ContextMenu"); 1467 domCodeString.assign("ContextMenu");
1453 } else if ("leftControl" == code_str) { 1468 } else if ("leftControl" == code_str ||
1469 "ControlLeft" == code_str) {
1454 code = ui::VKEY_CONTROL; 1470 code = ui::VKEY_CONTROL;
1455 domKeyString.assign("Control"); 1471 domKeyString.assign("Control");
1456 domCodeString.assign("ControlLeft"); 1472 domCodeString.assign("ControlLeft");
1457 location = DOMKeyLocationLeft; 1473 location = DOMKeyLocationLeft;
1458 } else if ("rightControl" == code_str) { 1474 } else if ("rightControl" == code_str ||
1475 "ControlRight" == code_str) {
1459 code = ui::VKEY_CONTROL; 1476 code = ui::VKEY_CONTROL;
1460 domKeyString.assign("Control"); 1477 domKeyString.assign("Control");
1461 domCodeString.assign("ControlRight"); 1478 domCodeString.assign("ControlRight");
1462 location = DOMKeyLocationRight; 1479 location = DOMKeyLocationRight;
1463 } else if ("leftShift" == code_str) { 1480 } else if ("leftShift" == code_str ||
1481 "ShiftLeft" == code_str) {
1464 code = ui::VKEY_SHIFT; 1482 code = ui::VKEY_SHIFT;
1465 domKeyString.assign("Shift"); 1483 domKeyString.assign("Shift");
1466 domCodeString.assign("ShiftLeft"); 1484 domCodeString.assign("ShiftLeft");
1467 location = DOMKeyLocationLeft; 1485 location = DOMKeyLocationLeft;
1468 } else if ("rightShift" == code_str) { 1486 } else if ("rightShift" == code_str ||
1487 "ShiftRight" == code_str) {
1469 code = ui::VKEY_SHIFT; 1488 code = ui::VKEY_SHIFT;
1470 domKeyString.assign("Shift"); 1489 domKeyString.assign("Shift");
1471 domCodeString.assign("ShiftRight"); 1490 domCodeString.assign("ShiftRight");
1472 location = DOMKeyLocationRight; 1491 location = DOMKeyLocationRight;
1473 } else if ("leftAlt" == code_str) { 1492 } else if ("leftAlt" == code_str ||
1493 "AltLeft" == code_str) {
1474 code = ui::VKEY_MENU; 1494 code = ui::VKEY_MENU;
1475 domKeyString.assign("Alt"); 1495 domKeyString.assign("Alt");
1476 domCodeString.assign("AltLeft"); 1496 domCodeString.assign("AltLeft");
1477 location = DOMKeyLocationLeft; 1497 location = DOMKeyLocationLeft;
1478 } else if ("rightAlt" == code_str) { 1498 } else if ("rightAlt" == code_str ||
1499 "AltRight" == code_str) {
1479 code = ui::VKEY_MENU; 1500 code = ui::VKEY_MENU;
1480 domKeyString.assign("Alt"); 1501 domKeyString.assign("Alt");
1481 domCodeString.assign("AltRight"); 1502 domCodeString.assign("AltRight");
1482 location = DOMKeyLocationRight; 1503 location = DOMKeyLocationRight;
1483 } else if ("numLock" == code_str) { 1504 } else if ("numLock" == code_str ||
1505 "NumLock" == code_str) {
1484 code = ui::VKEY_NUMLOCK; 1506 code = ui::VKEY_NUMLOCK;
1485 domKeyString.assign("NumLock"); 1507 domKeyString.assign("NumLock");
1486 domCodeString.assign("NumLock"); 1508 domCodeString.assign("NumLock");
1487 } else if ("backspace" == code_str) { 1509 } else if ("backspace" == code_str ||
1510 "Backspace" == code_str) {
1488 code = ui::VKEY_BACK; 1511 code = ui::VKEY_BACK;
1489 domKeyString.assign("Backspace"); 1512 domKeyString.assign("Backspace");
1490 domCodeString.assign("Backspace"); 1513 domCodeString.assign("Backspace");
1491 } else if ("escape" == code_str) { 1514 } else if ("escape" == code_str ||
1515 "Escape" == code_str) {
1492 code = ui::VKEY_ESCAPE; 1516 code = ui::VKEY_ESCAPE;
1493 domKeyString.assign("Escape"); 1517 domKeyString.assign("Escape");
1494 domCodeString.assign("Escape"); 1518 domCodeString.assign("Escape");
1495 } else { 1519 } else {
1496 // Compare the input string with the function-key names defined by the 1520 // Compare the input string with the function-key names defined by the
1497 // DOM spec (i.e. "F1",...,"F24"). If the input string is a function-key 1521 // DOM spec (i.e. "F1",...,"F24"). If the input string is a function-key
1498 // name, set its key code. 1522 // name, set its key code.
1499 for (int i = 1; i <= 24; ++i) { 1523 for (int i = 1; i <= 24; ++i) {
1500 std::string function_key_name = base::StringPrintf("F%d", i); 1524 std::string function_key_name = base::StringPrintf("F%d", i);
1501 if (function_key_name == code_str) { 1525 if (function_key_name == code_str) {
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 2814
2791 const blink::WebView* EventSender::view() const { 2815 const blink::WebView* EventSender::view() const {
2792 return web_test_proxy_base_->web_view(); 2816 return web_test_proxy_base_->web_view();
2793 } 2817 }
2794 2818
2795 blink::WebView* EventSender::view() { 2819 blink::WebView* EventSender::view() {
2796 return web_test_proxy_base_->web_view(); 2820 return web_test_proxy_base_->web_view();
2797 } 2821 }
2798 2822
2799 } // namespace test_runner 2823 } // namespace test_runner
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698