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

Side by Side Diff: chrome/browser/apps/guest_view/web_view_browsertest.cc

Issue 1254883006: Bubble scroll events from WebView guest to embedder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Complete test. Created 5 years, 4 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 | chrome/test/data/extensions/platform_apps/web_view/scrollable_embedder_and_guest/guest.html » ('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 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 17 matching lines...) Expand all
28 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
29 #include "components/content_settings/core/browser/host_content_settings_map.h" 29 #include "components/content_settings/core/browser/host_content_settings_map.h"
30 #include "components/guest_view/browser/guest_view_manager.h" 30 #include "components/guest_view/browser/guest_view_manager.h"
31 #include "components/guest_view/browser/guest_view_manager_factory.h" 31 #include "components/guest_view/browser/guest_view_manager_factory.h"
32 #include "components/guest_view/browser/test_guest_view_manager.h" 32 #include "components/guest_view/browser/test_guest_view_manager.h"
33 #include "content/public/browser/gpu_data_manager.h" 33 #include "content/public/browser/gpu_data_manager.h"
34 #include "content/public/browser/interstitial_page.h" 34 #include "content/public/browser/interstitial_page.h"
35 #include "content/public/browser/interstitial_page_delegate.h" 35 #include "content/public/browser/interstitial_page_delegate.h"
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/render_process_host.h" 37 #include "content/public/browser/render_process_host.h"
38 #include "content/public/browser/render_widget_host_view.h"
38 #include "content/public/browser/web_contents_delegate.h" 39 #include "content/public/browser/web_contents_delegate.h"
39 #include "content/public/common/child_process_host.h" 40 #include "content/public/common/child_process_host.h"
40 #include "content/public/common/content_switches.h" 41 #include "content/public/common/content_switches.h"
41 #include "content/public/test/browser_test_utils.h" 42 #include "content/public/test/browser_test_utils.h"
42 #include "content/public/test/fake_speech_recognition_manager.h" 43 #include "content/public/test/fake_speech_recognition_manager.h"
43 #include "content/public/test/test_renderer_host.h" 44 #include "content/public/test/test_renderer_host.h"
44 #include "extensions/browser/api/declarative/rules_registry.h" 45 #include "extensions/browser/api/declarative/rules_registry.h"
45 #include "extensions/browser/api/declarative/rules_registry_service.h" 46 #include "extensions/browser/api/declarative/rules_registry_service.h"
46 #include "extensions/browser/api/declarative/test_rules_registry.h" 47 #include "extensions/browser/api/declarative/test_rules_registry.h"
47 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" 48 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h"
48 #include "extensions/browser/app_window/native_app_window.h" 49 #include "extensions/browser/app_window/native_app_window.h"
49 #include "extensions/browser/guest_view/extensions_guest_view_manager_delegate.h " 50 #include "extensions/browser/guest_view/extensions_guest_view_manager_delegate.h "
50 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 51 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
51 #include "extensions/common/extension.h" 52 #include "extensions/common/extension.h"
52 #include "extensions/common/extensions_client.h" 53 #include "extensions/common/extensions_client.h"
53 #include "extensions/test/extension_test_message_listener.h" 54 #include "extensions/test/extension_test_message_listener.h"
54 #include "media/base/media_switches.h" 55 #include "media/base/media_switches.h"
55 #include "net/test/embedded_test_server/embedded_test_server.h" 56 #include "net/test/embedded_test_server/embedded_test_server.h"
56 #include "net/test/embedded_test_server/http_request.h" 57 #include "net/test/embedded_test_server/http_request.h"
57 #include "net/test/embedded_test_server/http_response.h" 58 #include "net/test/embedded_test_server/http_response.h"
58 #include "ui/aura/window.h" 59 #include "ui/aura/window.h"
59 #include "ui/compositor/compositor.h" 60 #include "ui/compositor/compositor.h"
60 #include "ui/compositor/compositor_observer.h" 61 #include "ui/compositor/compositor_observer.h"
61 #include "ui/events/event_switches.h" 62 #include "ui/events/event_switches.h"
63 #include "ui/events/gesture_detection/gesture_provider_config_helper.h"
64 #include "ui/events/test/event_generator.h"
62 #include "ui/gfx/switches.h" 65 #include "ui/gfx/switches.h"
63 #include "ui/gl/gl_switches.h" 66 #include "ui/gl/gl_switches.h"
64 #include "ui/views/view.h" 67 #include "ui/views/view.h"
65 #include "ui/views/widget/widget.h" 68 #include "ui/views/widget/widget.h"
66 69
67 #if defined(ENABLE_PLUGINS) 70 #if defined(ENABLE_PLUGINS)
68 #include "content/public/browser/plugin_service.h" 71 #include "content/public/browser/plugin_service.h"
69 #include "content/public/common/webplugininfo.h" 72 #include "content/public/common/webplugininfo.h"
70 #include "content/public/test/ppapi_test_utils.h" 73 #include "content/public/test/ppapi_test_utils.h"
71 #endif 74 #endif
(...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 } 2501 }
2499 2502
2500 // Tests that a renderer navigation from an unattached guest that results in a 2503 // Tests that a renderer navigation from an unattached guest that results in a
2501 // server redirect works properly. 2504 // server redirect works properly.
2502 IN_PROC_BROWSER_TEST_F(WebViewTest, 2505 IN_PROC_BROWSER_TEST_F(WebViewTest,
2503 Shim_TestRendererNavigationRedirectWhileUnattached) { 2506 Shim_TestRendererNavigationRedirectWhileUnattached) {
2504 TestHelper("testRendererNavigationRedirectWhileUnattached", 2507 TestHelper("testRendererNavigationRedirectWhileUnattached",
2505 "web_view/shim", NEEDS_TEST_SERVER); 2508 "web_view/shim", NEEDS_TEST_SERVER);
2506 } 2509 }
2507 2510
2511 class WebViewTouchTest : public WebViewTest {
2512 protected:
2513 void SetUpCommandLine(base::CommandLine* command_line) override {
2514 command_line->AppendSwitchASCII(switches::kTouchEvents,
2515 switches::kTouchEventsEnabled);
2516
2517 WebViewTest::SetUpCommandLine(command_line);
2518 }
2519 };
2520
2521 namespace {
2522
2523 class ScrollWaiter {
2524 public:
2525 explicit ScrollWaiter(content::RenderWidgetHostView* host_view)
2526 : host_view_(host_view),
2527 current_offset_(host_view_->GetLastScrollOffset()) {}
2528 ~ScrollWaiter() {}
2529
2530 void WaitForScrollChange() {
2531 while (current_offset_ == host_view_->GetLastScrollOffset())
2532 base::MessageLoop::current()->RunUntilIdle();
2533 }
2534
2535 private:
2536 content::RenderWidgetHostView* host_view_;
2537 gfx::Vector2dF current_offset_;
2538 };
2539
2540 } // namespace
2541
2542 // Tests that scrolls bubble from guest to embedder.
2543 IN_PROC_BROWSER_TEST_F(WebViewTouchTest, TestGuestScrollsBubble) {
2544 LoadAppWithGuest("web_view/scrollable_embedder_and_guest");
2545
2546 content::WebContents* embedder_contents = GetEmbedderWebContents();
2547
2548 std::vector<content::WebContents*> guest_web_contents_list;
2549 GetGuestViewManager()->WaitForNumGuestsCreated(1u);
2550 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list);
2551 ASSERT_EQ(1u, guest_web_contents_list.size());
2552
2553 content::WebContents* guest_contents = guest_web_contents_list[0];
2554
2555 // Send scroll gesture to embedder & verify.
2556 content::RenderWidgetHostView* embedder_host_view =
2557 embedder_contents->GetRenderWidgetHostView();
2558 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset());
2559
2560 float touch_slop = ui::GetGestureProviderConfig(
2561 ui::GestureProviderConfigType::CURRENT_PLATFORM)
2562 .gesture_detector_config.touch_slop;
2563 float scroll_magnitude = 15.f;
2564 float gesture_distance = scroll_magnitude + touch_slop;
2565
2566 {
2567 gfx::Point embedder_scroll_start(200, 40 + gesture_distance);
2568 gfx::Point embedder_scroll_end(200, 40);
2569 gfx::Vector2dF expected_offset(0.f, scroll_magnitude);
2570
2571 ScrollWaiter waiter(embedder_host_view);
2572
2573 ui::test::EventGenerator generator(
2574 embedder_contents->GetTopLevelNativeWindow(), embedder_scroll_start);
2575 generator.GestureScrollSequence(embedder_scroll_start, embedder_scroll_end,
2576 base::TimeDelta::FromMilliseconds(100), 1);
2577 waiter.WaitForScrollChange();
2578 EXPECT_EQ(expected_offset, embedder_host_view->GetLastScrollOffset());
2579 }
2580
2581 content::RenderWidgetHostView* guest_host_view =
2582 guest_contents->GetRenderWidgetHostView();
2583 EXPECT_EQ(gfx::Vector2dF(), guest_host_view->GetLastScrollOffset());
2584
2585 // Send scroll gesture to guest and verify embedder scrolls.
2586 // Perform a scroll gesture of the same magnitude, but in the opposite
2587 // direction and centered over the GuestView this time.
2588 {
2589 gfx::Point guest_scroll_start(200, 120);
2590 gfx::Point guest_scroll_end(200, 120 + gesture_distance);
2591 ScrollWaiter waiter(embedder_host_view);
2592
2593 ui::test::EventGenerator generator(
2594 embedder_contents->GetTopLevelNativeWindow(), guest_scroll_start);
2595 generator.GestureScrollSequence(guest_scroll_start, guest_scroll_end,
2596 base::TimeDelta::FromMilliseconds(100), 1);
2597
2598 waiter.WaitForScrollChange();
2599 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset());
2600 }
2601 }
2602
2508 #if defined(USE_AURA) 2603 #if defined(USE_AURA)
2509 // TODO(wjmaclean): when WebViewTest is re-enabled on the site-isolation 2604 // TODO(wjmaclean): when WebViewTest is re-enabled on the site-isolation
2510 // bots, then re-enable this test class as well. 2605 // bots, then re-enable this test class as well.
2511 // https://crbug.com/503751 2606 // https://crbug.com/503751
2512 class WebViewFocusTest : public WebViewTest { 2607 class WebViewFocusTest : public WebViewTest {
2513 public: 2608 public:
2514 ~WebViewFocusTest() override {} 2609 ~WebViewFocusTest() override {}
2515 2610
2516 void SetUpCommandLine(base::CommandLine* command_line) override { 2611 void SetUpCommandLine(base::CommandLine* command_line) override {
2517 WebViewTest::SetUpCommandLine(command_line); 2612 WebViewTest::SetUpCommandLine(command_line);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2635 // Generate and send synthetic touch event. 2730 // Generate and send synthetic touch event.
2636 FocusWaiter waiter(aura_webview); 2731 FocusWaiter waiter(aura_webview);
2637 content::SimulateTouchPressAt(GetEmbedderWebContents(), 2732 content::SimulateTouchPressAt(GetEmbedderWebContents(),
2638 guest_rect.CenterPoint()); 2733 guest_rect.CenterPoint());
2639 2734
2640 // Wait for the TouchStart to propagate and restore focus. Test times out 2735 // Wait for the TouchStart to propagate and restore focus. Test times out
2641 // on failure. 2736 // on failure.
2642 waiter.Wait(); 2737 waiter.Wait();
2643 } 2738 }
2644 #endif 2739 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/scrollable_embedder_and_guest/guest.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698