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 <queue> | 5 #include <queue> |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/process/process.h" | 9 #include "base/process/process.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 2499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2510 "web_view/shim", NEEDS_TEST_SERVER); | 2510 "web_view/shim", NEEDS_TEST_SERVER); |
2511 } | 2511 } |
2512 | 2512 |
2513 // Tests that a WebView accessible resource can actually be loaded from a | 2513 // Tests that a WebView accessible resource can actually be loaded from a |
2514 // webpage in a WebView. | 2514 // webpage in a WebView. |
2515 IN_PROC_BROWSER_TEST_F(WebViewTest, LoadWebviewAccessibleResource) { | 2515 IN_PROC_BROWSER_TEST_F(WebViewTest, LoadWebviewAccessibleResource) { |
2516 TestHelper("testLoadWebviewAccessibleResource", | 2516 TestHelper("testLoadWebviewAccessibleResource", |
2517 "web_view/load_webview_accessible_resource", NEEDS_TEST_SERVER); | 2517 "web_view/load_webview_accessible_resource", NEEDS_TEST_SERVER); |
2518 } | 2518 } |
2519 | 2519 |
2520 class WebViewTouchTest : public WebViewTest { | 2520 class WebViewGuestScrollTest : public WebViewTest, |
2521 public ::testing::WithParamInterface<bool> { | |
2522 protected: | |
2523 WebViewGuestScrollTest() {} | |
2524 ~WebViewGuestScrollTest() {} | |
2525 | |
2526 private: | |
2527 DISALLOW_COPY_AND_ASSIGN(WebViewGuestScrollTest); | |
2528 }; | |
2529 | |
2530 class WebViewGuestScrollTouchTest : public WebViewGuestScrollTest { | |
2521 protected: | 2531 protected: |
2522 void SetUpCommandLine(base::CommandLine* command_line) override { | 2532 void SetUpCommandLine(base::CommandLine* command_line) override { |
2523 command_line->AppendSwitchASCII(switches::kTouchEvents, | 2533 command_line->AppendSwitchASCII(switches::kTouchEvents, |
2524 switches::kTouchEventsEnabled); | 2534 switches::kTouchEventsEnabled); |
2525 | 2535 |
2526 WebViewTest::SetUpCommandLine(command_line); | 2536 WebViewTest::SetUpCommandLine(command_line); |
2527 } | 2537 } |
2528 }; | 2538 }; |
2529 | 2539 |
2530 namespace { | 2540 namespace { |
2531 | 2541 |
2532 class ScrollWaiter { | 2542 class ScrollWaiter { |
2533 public: | 2543 public: |
2534 explicit ScrollWaiter(content::RenderWidgetHostView* host_view) | 2544 explicit ScrollWaiter(content::RenderWidgetHostView* host_view) |
2535 : host_view_(host_view) {} | 2545 : host_view_(host_view) {} |
2536 ~ScrollWaiter() {} | 2546 ~ScrollWaiter() {} |
2537 | 2547 |
2538 void WaitForScrollChange(gfx::Vector2dF target_offset) { | 2548 void WaitForScrollChange(gfx::Vector2dF target_offset) { |
2539 while (target_offset != host_view_->GetLastScrollOffset()) | 2549 while (target_offset != host_view_->GetLastScrollOffset()) |
2540 base::MessageLoop::current()->RunUntilIdle(); | 2550 base::MessageLoop::current()->RunUntilIdle(); |
2541 } | 2551 } |
2542 | 2552 |
2543 private: | 2553 private: |
2544 content::RenderWidgetHostView* host_view_; | 2554 content::RenderWidgetHostView* host_view_; |
2545 }; | 2555 }; |
2546 | 2556 |
2547 } // namespace | 2557 } // namespace |
2548 | 2558 |
2549 // Tests that scrolls bubble from guest to embedder. | 2559 // Tests that scrolls bubble from guest to embedder. |
2550 IN_PROC_BROWSER_TEST_F(WebViewTest, TestGuestWheelScrollsBubble) { | 2560 // Create two test instances, one where theguest body is scrollable and the |
ncarter (slow)
2015/09/30 21:37:19
"theguest"
| |
2561 // other where the body is not scrollable: fast-path scrolling will generate | |
2562 // different ack results in between these two cases. | |
2563 INSTANTIATE_TEST_CASE_P(WebViewScrollBubbling, | |
2564 WebViewGuestScrollTest, | |
2565 ::testing::Bool()); | |
2566 | |
2567 IN_PROC_BROWSER_TEST_P(WebViewGuestScrollTest, TestGuestWheelScrollsBubble) { | |
2551 LoadAppWithGuest("web_view/scrollable_embedder_and_guest"); | 2568 LoadAppWithGuest("web_view/scrollable_embedder_and_guest"); |
2552 | 2569 |
2570 if (GetParam()) | |
2571 SendMessageToGuestAndWait("set_overflow_hidden", "overflow_is_hidden"); | |
2572 | |
2553 content::WebContents* embedder_contents = GetEmbedderWebContents(); | 2573 content::WebContents* embedder_contents = GetEmbedderWebContents(); |
2554 | 2574 |
2555 std::vector<content::WebContents*> guest_web_contents_list; | 2575 std::vector<content::WebContents*> guest_web_contents_list; |
2556 GetGuestViewManager()->WaitForNumGuestsCreated(1u); | 2576 GetGuestViewManager()->WaitForNumGuestsCreated(1u); |
2557 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); | 2577 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); |
2558 ASSERT_EQ(1u, guest_web_contents_list.size()); | 2578 ASSERT_EQ(1u, guest_web_contents_list.size()); |
2559 | 2579 |
2560 content::WebContents* guest_contents = guest_web_contents_list[0]; | 2580 content::WebContents* guest_contents = guest_web_contents_list[0]; |
2561 | 2581 |
2562 gfx::Rect embedder_rect = embedder_contents->GetContainerBounds(); | 2582 gfx::Rect embedder_rect = embedder_contents->GetContainerBounds(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2614 content::SimulateMouseEvent(embedder_contents, | 2634 content::SimulateMouseEvent(embedder_contents, |
2615 blink::WebInputEvent::MouseMove, | 2635 blink::WebInputEvent::MouseMove, |
2616 guest_scroll_location); | 2636 guest_scroll_location); |
2617 content::SimulateMouseWheelEvent(embedder_contents, guest_scroll_location, | 2637 content::SimulateMouseWheelEvent(embedder_contents, guest_scroll_location, |
2618 gfx::Vector2d(0, scroll_magnitude)); | 2638 gfx::Vector2d(0, scroll_magnitude)); |
2619 | 2639 |
2620 waiter.WaitForScrollChange(gfx::Vector2dF()); | 2640 waiter.WaitForScrollChange(gfx::Vector2dF()); |
2621 } | 2641 } |
2622 } | 2642 } |
2623 | 2643 |
2624 IN_PROC_BROWSER_TEST_F(WebViewTouchTest, TestGuestGestureScrollsBubble) { | 2644 INSTANTIATE_TEST_CASE_P(WebViewScrollBubbling, |
2645 WebViewGuestScrollTouchTest, | |
2646 ::testing::Bool()); | |
2647 | |
2648 IN_PROC_BROWSER_TEST_P(WebViewGuestScrollTouchTest, | |
2649 TestGuestGestureScrollsBubble) { | |
2625 // Just in case we're running ChromeOS tests, we need to make sure the | 2650 // Just in case we're running ChromeOS tests, we need to make sure the |
2626 // debounce interval is set to zero so our back-to-back gesture-scrolls don't | 2651 // debounce interval is set to zero so our back-to-back gesture-scrolls don't |
2627 // get munged together. Since the first scroll will be put on the fast | 2652 // get munged together. Since the first scroll will be put on the fast |
2628 // (compositor) path, while the second one should always be slow-path so it | 2653 // (compositor) path, while the second one should always be slow-path so it |
2629 // gets to BrowserPlugin, having them merged is definitely an error. | 2654 // gets to BrowserPlugin, having them merged is definitely an error. |
2630 ui::GestureConfiguration* gesture_config = | 2655 ui::GestureConfiguration* gesture_config = |
2631 ui::GestureConfiguration::GetInstance(); | 2656 ui::GestureConfiguration::GetInstance(); |
2632 gesture_config->set_scroll_debounce_interval_in_ms(0); | 2657 gesture_config->set_scroll_debounce_interval_in_ms(0); |
2633 | 2658 |
2634 LoadAppWithGuest("web_view/scrollable_embedder_and_guest"); | 2659 LoadAppWithGuest("web_view/scrollable_embedder_and_guest"); |
2635 | 2660 |
2661 if (GetParam()) | |
2662 SendMessageToGuestAndWait("set_overflow_hidden", "overflow_is_hidden"); | |
2663 | |
2636 content::WebContents* embedder_contents = GetEmbedderWebContents(); | 2664 content::WebContents* embedder_contents = GetEmbedderWebContents(); |
2637 | 2665 |
2638 std::vector<content::WebContents*> guest_web_contents_list; | 2666 std::vector<content::WebContents*> guest_web_contents_list; |
2639 GetGuestViewManager()->WaitForNumGuestsCreated(1u); | 2667 GetGuestViewManager()->WaitForNumGuestsCreated(1u); |
2640 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); | 2668 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); |
2641 ASSERT_EQ(1u, guest_web_contents_list.size()); | 2669 ASSERT_EQ(1u, guest_web_contents_list.size()); |
2642 | 2670 |
2643 content::WebContents* guest_contents = guest_web_contents_list[0]; | 2671 content::WebContents* guest_contents = guest_web_contents_list[0]; |
2644 | 2672 |
2645 gfx::Rect embedder_rect = embedder_contents->GetContainerBounds(); | 2673 gfx::Rect embedder_rect = embedder_contents->GetContainerBounds(); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2918 const task_management::Task* task = task_manager.tasks().back(); | 2946 const task_management::Task* task = task_manager.tasks().back(); |
2919 EXPECT_EQ(task_management::Task::GUEST, task->GetType()); | 2947 EXPECT_EQ(task_management::Task::GUEST, task->GetType()); |
2920 const base::string16 title = task->title(); | 2948 const base::string16 title = task->title(); |
2921 const base::string16 expected_prefix = GetExpectedPrefix(guest_contents); | 2949 const base::string16 expected_prefix = GetExpectedPrefix(guest_contents); |
2922 EXPECT_TRUE(base::StartsWith(title, | 2950 EXPECT_TRUE(base::StartsWith(title, |
2923 expected_prefix, | 2951 expected_prefix, |
2924 base::CompareCase::INSENSITIVE_ASCII)); | 2952 base::CompareCase::INSENSITIVE_ASCII)); |
2925 } | 2953 } |
2926 | 2954 |
2927 #endif // defined(ENABLE_TASK_MANAGER) | 2955 #endif // defined(ENABLE_TASK_MANAGER) |
OLD | NEW |