| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 scoped_refptr<content::MessageLoopRunner> message_loop_; | 369 scoped_refptr<content::MessageLoopRunner> message_loop_; |
| 370 | 370 |
| 371 DISALLOW_COPY_AND_ASSIGN(PopupCreatedObserver); | 371 DISALLOW_COPY_AND_ASSIGN(PopupCreatedObserver); |
| 372 }; | 372 }; |
| 373 | 373 |
| 374 void PopupTestHelper(const gfx::Point& padding) { | 374 void PopupTestHelper(const gfx::Point& padding) { |
| 375 PopupCreatedObserver popup_observer; | 375 PopupCreatedObserver popup_observer; |
| 376 popup_observer.Init(); | 376 popup_observer.Init(); |
| 377 // Press alt+DOWN to open popup. | 377 // Press alt+DOWN to open popup. |
| 378 bool alt = true; | 378 bool alt = true; |
| 379 content::SimulateKeyPress( | 379 content::SimulateKeyPress(guest_web_contents(), ui::DomKey::ARROW_DOWN, |
| 380 guest_web_contents(), ui::VKEY_DOWN, false, false, alt, false); | 380 ui::DomCode::ARROW_DOWN, ui::VKEY_DOWN, false, |
| 381 false, alt, false); |
| 381 popup_observer.Wait(); | 382 popup_observer.Wait(); |
| 382 | 383 |
| 383 content::RenderWidgetHost* popup_rwh = | 384 content::RenderWidgetHost* popup_rwh = |
| 384 popup_observer.last_render_widget_host(); | 385 popup_observer.last_render_widget_host(); |
| 385 gfx::Rect popup_bounds = popup_rwh->GetView()->GetViewBounds(); | 386 gfx::Rect popup_bounds = popup_rwh->GetView()->GetViewBounds(); |
| 386 | 387 |
| 387 content::RenderViewHost* embedder_rvh = | 388 content::RenderViewHost* embedder_rvh = |
| 388 GetFirstAppWindowWebContents()->GetRenderViewHost(); | 389 GetFirstAppWindowWebContents()->GetRenderViewHost(); |
| 389 gfx::Rect embedder_bounds = | 390 gfx::Rect embedder_bounds = |
| 390 embedder_rvh->GetWidget()->GetView()->GetViewBounds(); | 391 embedder_rvh->GetWidget()->GetView()->GetViewBounds(); |
| 391 gfx::Vector2d diff = popup_bounds.origin() - embedder_bounds.origin(); | 392 gfx::Vector2d diff = popup_bounds.origin() - embedder_bounds.origin(); |
| 392 LOG(INFO) << "DIFF: x = " << diff.x() << ", y = " << diff.y(); | 393 LOG(INFO) << "DIFF: x = " << diff.x() << ", y = " << diff.y(); |
| 393 | 394 |
| 394 const int left_spacing = 40 + padding.x(); // div.style.paddingLeft = 40px. | 395 const int left_spacing = 40 + padding.x(); // div.style.paddingLeft = 40px. |
| 395 // div.style.paddingTop = 60px + (input box height = 26px). | 396 // div.style.paddingTop = 60px + (input box height = 26px). |
| 396 const int top_spacing = 60 + 26 + padding.y(); | 397 const int top_spacing = 60 + 26 + padding.y(); |
| 397 | 398 |
| 398 // If the popup is placed within |threshold_px| of the expected position, | 399 // If the popup is placed within |threshold_px| of the expected position, |
| 399 // then we consider the test as a pass. | 400 // then we consider the test as a pass. |
| 400 const int threshold_px = 10; | 401 const int threshold_px = 10; |
| 401 | 402 |
| 402 EXPECT_LE(std::abs(diff.x() - left_spacing), threshold_px); | 403 EXPECT_LE(std::abs(diff.x() - left_spacing), threshold_px); |
| 403 EXPECT_LE(std::abs(diff.y() - top_spacing), threshold_px); | 404 EXPECT_LE(std::abs(diff.y() - top_spacing), threshold_px); |
| 404 | 405 |
| 405 // Close the popup. | 406 // Close the popup. |
| 406 content::SimulateKeyPress( | 407 content::SimulateKeyPress(guest_web_contents(), ui::DomKey::ESCAPE, |
| 407 guest_web_contents(), ui::VKEY_ESCAPE, false, false, false, false); | 408 ui::DomCode::ESCAPE, ui::VKEY_ESCAPE, false, |
| 409 false, false, false); |
| 408 } | 410 } |
| 409 | 411 |
| 410 void DragTestStep1() { | 412 void DragTestStep1() { |
| 411 // Move mouse to start of text. | 413 // Move mouse to start of text. |
| 412 MoveMouseInsideWindow(gfx::Point(45, 8)); | 414 MoveMouseInsideWindow(gfx::Point(45, 8)); |
| 413 MoveMouseInsideWindow(gfx::Point(45, 9)); | 415 MoveMouseInsideWindow(gfx::Point(45, 9)); |
| 414 SendMouseEvent(ui_controls::LEFT, ui_controls::DOWN); | 416 SendMouseEvent(ui_controls::LEFT, ui_controls::DOWN); |
| 415 | 417 |
| 416 MoveMouseInsideWindow(gfx::Point(74, 12)); | 418 MoveMouseInsideWindow(gfx::Point(74, 12)); |
| 417 MoveMouseInsideWindow(gfx::Point(78, 12)); | 419 MoveMouseInsideWindow(gfx::Point(78, 12)); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 &embedder_web_contents)); | 673 &embedder_web_contents)); |
| 672 done_listener->WaitUntilSatisfied(); | 674 done_listener->WaitUntilSatisfied(); |
| 673 } | 675 } |
| 674 | 676 |
| 675 { | 677 { |
| 676 ExtensionTestMessageListener listener("button1-focused", false); | 678 ExtensionTestMessageListener listener("button1-focused", false); |
| 677 listener.set_failure_message("TEST_FAILED"); | 679 listener.set_failure_message("TEST_FAILED"); |
| 678 SimulateRWHMouseClick( | 680 SimulateRWHMouseClick( |
| 679 embedder_web_contents->GetRenderViewHost()->GetWidget(), | 681 embedder_web_contents->GetRenderViewHost()->GetWidget(), |
| 680 blink::WebMouseEvent::ButtonLeft, 200, 20); | 682 blink::WebMouseEvent::ButtonLeft, 200, 20); |
| 681 content::SimulateKeyPress(embedder_web_contents, ui::VKEY_TAB, | 683 content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB, |
| 682 false, false, false, false); | 684 ui::DomCode::TAB, ui::VKEY_TAB, false, false, |
| 685 false, false); |
| 683 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 686 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 684 } | 687 } |
| 685 | 688 |
| 686 { | 689 { |
| 687 // Wait for button1 to be focused again, this means we were asked to | 690 // Wait for button1 to be focused again, this means we were asked to |
| 688 // move the focus to the next focusable element. | 691 // move the focus to the next focusable element. |
| 689 ExtensionTestMessageListener listener("button1-advance-focus", false); | 692 ExtensionTestMessageListener listener("button1-advance-focus", false); |
| 690 listener.set_failure_message("TEST_FAILED"); | 693 listener.set_failure_message("TEST_FAILED"); |
| 691 // TODO(fsamuel): A third Tab key press should not be necessary. | 694 // TODO(fsamuel): A third Tab key press should not be necessary. |
| 692 // The <webview> will take keyboard focus but it will not focus an initial | 695 // The <webview> will take keyboard focus but it will not focus an initial |
| 693 // element. The initial element is dependent upon tab direction which blink | 696 // element. The initial element is dependent upon tab direction which blink |
| 694 // does not propagate to the plugin. | 697 // does not propagate to the plugin. |
| 695 // See http://crbug.com/147644. | 698 // See http://crbug.com/147644. |
| 696 content::SimulateKeyPress(embedder_web_contents, ui::VKEY_TAB, | 699 content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB, |
| 697 false, false, false, false); | 700 ui::DomCode::TAB, ui::VKEY_TAB, false, false, |
| 698 content::SimulateKeyPress(embedder_web_contents, ui::VKEY_TAB, | 701 false, false); |
| 699 false, false, false, false); | 702 content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB, |
| 700 content::SimulateKeyPress(embedder_web_contents, ui::VKEY_TAB, | 703 ui::DomCode::TAB, ui::VKEY_TAB, false, false, |
| 701 false, false, false, false); | 704 false, false); |
| 705 content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB, |
| 706 ui::DomCode::TAB, ui::VKEY_TAB, false, false, |
| 707 false, false); |
| 702 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 708 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 703 } | 709 } |
| 704 } | 710 } |
| 705 | 711 |
| 706 // Tests that blurring <webview> also blurs the guest. | 712 // Tests that blurring <webview> also blurs the guest. |
| 707 IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_BlurEvent) { | 713 IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_BlurEvent) { |
| 708 TestHelper("testBlurEvent", "web_view/focus", NO_TEST_SERVER); | 714 TestHelper("testBlurEvent", "web_view/focus", NO_TEST_SERVER); |
| 709 } | 715 } |
| 710 | 716 |
| 711 // Tests that guests receive edit commands and respond appropriately. | 717 // Tests that guests receive edit commands and respond appropriately. |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 // this time. | 1346 // this time. |
| 1341 for (size_t i = 0; i < 4; ++i) | 1347 for (size_t i = 0; i < 4; ++i) |
| 1342 SendKeyPressToPlatformApp(ui::VKEY_TAB); | 1348 SendKeyPressToPlatformApp(ui::VKEY_TAB); |
| 1343 ExtensionTestMessageListener webview_button_not_focused_listener( | 1349 ExtensionTestMessageListener webview_button_not_focused_listener( |
| 1344 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); | 1350 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); |
| 1345 webview_button_not_focused_listener.set_failure_message( | 1351 webview_button_not_focused_listener.set_failure_message( |
| 1346 "WebViewInteractiveTest.WebViewButtonWasFocused"); | 1352 "WebViewInteractiveTest.WebViewButtonWasFocused"); |
| 1347 SendMessageToEmbedder("verify"); | 1353 SendMessageToEmbedder("verify"); |
| 1348 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); | 1354 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); |
| 1349 } | 1355 } |
| OLD | NEW |