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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 1124963003: Remove ui::KeycodeConverter::CodeToNativeKeycode(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@x444048-3a-codes
Patch Set: rebase Created 5 years, 7 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 | « content/content_renderer.gypi ('k') | content/renderer/pepper/event_conversion.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/public/test/browser_test_utils.h" 5 #include "content/public/test/browser_test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/process/kill.h" 10 #include "base/process/kill.h"
(...skipping 25 matching lines...) Expand all
36 #include "net/test/embedded_test_server/embedded_test_server.h" 36 #include "net/test/embedded_test_server/embedded_test_server.h"
37 #include "net/test/embedded_test_server/http_request.h" 37 #include "net/test/embedded_test_server/http_request.h"
38 #include "net/test/embedded_test_server/http_response.h" 38 #include "net/test/embedded_test_server/http_response.h"
39 #include "net/test/python_utils.h" 39 #include "net/test/python_utils.h"
40 #include "net/url_request/url_request_context.h" 40 #include "net/url_request/url_request_context.h"
41 #include "net/url_request/url_request_context_getter.h" 41 #include "net/url_request/url_request_context_getter.h"
42 #include "testing/gtest/include/gtest/gtest.h" 42 #include "testing/gtest/include/gtest/gtest.h"
43 #include "ui/base/resource/resource_bundle.h" 43 #include "ui/base/resource/resource_bundle.h"
44 #include "ui/compositor/test/draw_waiter_for_test.h" 44 #include "ui/compositor/test/draw_waiter_for_test.h"
45 #include "ui/events/gesture_detection/gesture_configuration.h" 45 #include "ui/events/gesture_detection/gesture_configuration.h"
46 #include "ui/events/keycodes/dom/dom_code.h"
46 #include "ui/events/keycodes/dom/keycode_converter.h" 47 #include "ui/events/keycodes/dom/keycode_converter.h"
47 #include "ui/resources/grit/webui_resources.h" 48 #include "ui/resources/grit/webui_resources.h"
48 49
49 #if defined(USE_AURA) 50 #if defined(USE_AURA)
50 #include "ui/aura/test/window_event_dispatcher_test_api.h" 51 #include "ui/aura/test/window_event_dispatcher_test_api.h"
51 #include "ui/aura/window.h" 52 #include "ui/aura/window.h"
52 #include "ui/aura/window_event_dispatcher.h" 53 #include "ui/aura/window_event_dispatcher.h"
53 #include "ui/aura/window_tree_host.h" 54 #include "ui/aura/window_tree_host.h"
54 #endif // USE_AURA 55 #endif // USE_AURA
55 56
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 web_contents, key_code, NULL, control, shift, alt, command); 439 web_contents, key_code, NULL, control, shift, alt, command);
439 } 440 }
440 441
441 void SimulateKeyPressWithCode(WebContents* web_contents, 442 void SimulateKeyPressWithCode(WebContents* web_contents,
442 ui::KeyboardCode key_code, 443 ui::KeyboardCode key_code,
443 const char* code, 444 const char* code,
444 bool control, 445 bool control,
445 bool shift, 446 bool shift,
446 bool alt, 447 bool alt,
447 bool command) { 448 bool command) {
448 int native_key_code = ui::KeycodeConverter::CodeToNativeKeycode(code); 449 int native_key_code = ui::KeycodeConverter::DomCodeToNativeKeycode(
450 ui::KeycodeConverter::CodeStringToDomCode(code));
449 451
450 int modifiers = 0; 452 int modifiers = 0;
451 453
452 // The order of these key down events shouldn't matter for our simulation. 454 // The order of these key down events shouldn't matter for our simulation.
453 // For our simulation we can use either the left keys or the right keys. 455 // For our simulation we can use either the left keys or the right keys.
454 if (control) { 456 if (control) {
455 modifiers |= blink::WebInputEvent::ControlKey; 457 modifiers |= blink::WebInputEvent::ControlKey;
456 InjectRawKeyEvent(web_contents, 458 InjectRawKeyEvent(
457 blink::WebInputEvent::RawKeyDown, 459 web_contents, blink::WebInputEvent::RawKeyDown, ui::VKEY_CONTROL,
458 ui::VKEY_CONTROL, 460 ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::CONTROL_LEFT),
459 ui::KeycodeConverter::CodeToNativeKeycode("ControlLeft"), 461 modifiers);
460 modifiers);
461 } 462 }
462 463
463 if (shift) { 464 if (shift) {
464 modifiers |= blink::WebInputEvent::ShiftKey; 465 modifiers |= blink::WebInputEvent::ShiftKey;
465 InjectRawKeyEvent(web_contents, 466 InjectRawKeyEvent(
466 blink::WebInputEvent::RawKeyDown, 467 web_contents, blink::WebInputEvent::RawKeyDown, ui::VKEY_SHIFT,
467 ui::VKEY_SHIFT, 468 ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::SHIFT_LEFT),
468 ui::KeycodeConverter::CodeToNativeKeycode("ShiftLeft"), 469 modifiers);
469 modifiers);
470 } 470 }
471 471
472 if (alt) { 472 if (alt) {
473 modifiers |= blink::WebInputEvent::AltKey; 473 modifiers |= blink::WebInputEvent::AltKey;
474 InjectRawKeyEvent(web_contents, 474 InjectRawKeyEvent(
475 blink::WebInputEvent::RawKeyDown, 475 web_contents, blink::WebInputEvent::RawKeyDown, ui::VKEY_MENU,
476 ui::VKEY_MENU, 476 ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::ALT_LEFT),
477 ui::KeycodeConverter::CodeToNativeKeycode("AltLeft"), 477 modifiers);
478 modifiers);
479 } 478 }
480 479
481 if (command) { 480 if (command) {
482 modifiers |= blink::WebInputEvent::MetaKey; 481 modifiers |= blink::WebInputEvent::MetaKey;
483 InjectRawKeyEvent(web_contents, 482 InjectRawKeyEvent(
484 blink::WebInputEvent::RawKeyDown, 483 web_contents, blink::WebInputEvent::RawKeyDown, ui::VKEY_COMMAND,
485 ui::VKEY_COMMAND, 484 ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::OS_LEFT),
486 ui::KeycodeConverter::CodeToNativeKeycode("OSLeft"), 485 modifiers);
487 modifiers);
488 } 486 }
487 InjectRawKeyEvent(web_contents, blink::WebInputEvent::RawKeyDown, key_code,
488 native_key_code, modifiers);
489 489
490 InjectRawKeyEvent( 490 InjectRawKeyEvent(web_contents, blink::WebInputEvent::Char, key_code,
491 web_contents, 491 native_key_code, modifiers);
492 blink::WebInputEvent::RawKeyDown,
493 key_code,
494 native_key_code,
495 modifiers);
496 492
497 InjectRawKeyEvent( 493 InjectRawKeyEvent(web_contents, blink::WebInputEvent::KeyUp, key_code,
498 web_contents, 494 native_key_code, modifiers);
499 blink::WebInputEvent::Char,
500 key_code,
501 native_key_code,
502 modifiers);
503
504 InjectRawKeyEvent(
505 web_contents,
506 blink::WebInputEvent::KeyUp,
507 key_code,
508 native_key_code,
509 modifiers);
510 495
511 // The order of these key releases shouldn't matter for our simulation. 496 // The order of these key releases shouldn't matter for our simulation.
512 if (control) { 497 if (control) {
513 modifiers &= ~blink::WebInputEvent::ControlKey; 498 modifiers &= ~blink::WebInputEvent::ControlKey;
514 InjectRawKeyEvent(web_contents, 499 InjectRawKeyEvent(
515 blink::WebInputEvent::KeyUp, 500 web_contents, blink::WebInputEvent::KeyUp, ui::VKEY_CONTROL,
516 ui::VKEY_CONTROL, 501 ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::CONTROL_LEFT),
517 ui::KeycodeConverter::CodeToNativeKeycode("ControlLeft"), 502 modifiers);
518 modifiers);
519 } 503 }
520 504
521 if (shift) { 505 if (shift) {
522 modifiers &= ~blink::WebInputEvent::ShiftKey; 506 modifiers &= ~blink::WebInputEvent::ShiftKey;
523 InjectRawKeyEvent(web_contents, 507 InjectRawKeyEvent(
524 blink::WebInputEvent::KeyUp, 508 web_contents, blink::WebInputEvent::KeyUp, ui::VKEY_SHIFT,
525 ui::VKEY_SHIFT, 509 ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::SHIFT_LEFT),
526 ui::KeycodeConverter::CodeToNativeKeycode("ShiftLeft"), 510 modifiers);
527 modifiers);
528 } 511 }
529 512
530 if (alt) { 513 if (alt) {
531 modifiers &= ~blink::WebInputEvent::AltKey; 514 modifiers &= ~blink::WebInputEvent::AltKey;
532 InjectRawKeyEvent(web_contents, 515 InjectRawKeyEvent(
533 blink::WebInputEvent::KeyUp, 516 web_contents, blink::WebInputEvent::KeyUp, ui::VKEY_MENU,
534 ui::VKEY_MENU, 517 ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::ALT_LEFT),
535 ui::KeycodeConverter::CodeToNativeKeycode("AltLeft"), 518 modifiers);
536 modifiers);
537 } 519 }
538 520
539 if (command) { 521 if (command) {
540 modifiers &= ~blink::WebInputEvent::MetaKey; 522 modifiers &= ~blink::WebInputEvent::MetaKey;
541 InjectRawKeyEvent(web_contents, 523 InjectRawKeyEvent(
542 blink::WebInputEvent::KeyUp, 524 web_contents, blink::WebInputEvent::KeyUp, ui::VKEY_COMMAND,
543 ui::VKEY_COMMAND, 525 ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::OS_LEFT),
544 ui::KeycodeConverter::CodeToNativeKeycode("OSLeft"), 526 modifiers);
545 modifiers);
546 } 527 }
547 528
548 ASSERT_EQ(modifiers, 0); 529 ASSERT_EQ(modifiers, 0);
549 } 530 }
550 531
551 namespace internal { 532 namespace internal {
552 533
553 ToRenderFrameHost::ToRenderFrameHost(WebContents* web_contents) 534 ToRenderFrameHost::ToRenderFrameHost(WebContents* web_contents)
554 : render_frame_host_(web_contents->GetMainFrame()) { 535 : render_frame_host_(web_contents->GetMainFrame()) {
555 } 536 }
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 953
973 bool WebContentsAddedObserver::RenderViewCreatedCalled() { 954 bool WebContentsAddedObserver::RenderViewCreatedCalled() {
974 if (child_observer_) { 955 if (child_observer_) {
975 return child_observer_->render_view_created_called_ && 956 return child_observer_->render_view_created_called_ &&
976 child_observer_->main_frame_created_called_; 957 child_observer_->main_frame_created_called_;
977 } 958 }
978 return false; 959 return false;
979 } 960 }
980 961
981 } // namespace content 962 } // namespace content
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/pepper/event_conversion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698