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

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

Issue 2815823003: Notify OverscrollController of gesture events in plugins. (Closed)
Patch Set: Add test to verify OverscrollController sees consumed scrolls. Created 3 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 #include "ui/base/test/test_clipboard.h" 86 #include "ui/base/test/test_clipboard.h"
87 #include "ui/compositor/test/draw_waiter_for_test.h" 87 #include "ui/compositor/test/draw_waiter_for_test.h"
88 #include "ui/events/base_event_utils.h" 88 #include "ui/events/base_event_utils.h"
89 #include "ui/events/gesture_detection/gesture_configuration.h" 89 #include "ui/events/gesture_detection/gesture_configuration.h"
90 #include "ui/events/keycodes/dom/dom_code.h" 90 #include "ui/events/keycodes/dom/dom_code.h"
91 #include "ui/events/keycodes/dom/keycode_converter.h" 91 #include "ui/events/keycodes/dom/keycode_converter.h"
92 #include "ui/latency/latency_info.h" 92 #include "ui/latency/latency_info.h"
93 #include "ui/resources/grit/webui_resources.h" 93 #include "ui/resources/grit/webui_resources.h"
94 94
95 #if defined(USE_AURA) 95 #if defined(USE_AURA)
96 #include "content/browser/renderer_host/overscroll_controller.h"
96 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 97 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
97 #include "ui/aura/test/window_event_dispatcher_test_api.h" 98 #include "ui/aura/test/window_event_dispatcher_test_api.h"
98 #include "ui/aura/window.h" 99 #include "ui/aura/window.h"
99 #include "ui/aura/window_event_dispatcher.h" 100 #include "ui/aura/window_event_dispatcher.h"
100 #include "ui/aura/window_tree_host.h" 101 #include "ui/aura/window_tree_host.h"
101 #include "ui/events/event.h" 102 #include "ui/events/event.h"
102 #endif // USE_AURA 103 #endif // USE_AURA
103 104
104 namespace content { 105 namespace content {
105 namespace { 106 namespace {
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 int routing_id, 2049 int routing_id,
2049 bool user_gesture, 2050 bool user_gesture,
2050 bool last_unlocked_by_target, 2051 bool last_unlocked_by_target,
2051 bool privileged) { 2052 bool privileged) {
2052 IPC::IpcSecurityTestUtil::PwnMessageReceived( 2053 IPC::IpcSecurityTestUtil::PwnMessageReceived(
2053 process->GetChannel(), 2054 process->GetChannel(),
2054 ViewHostMsg_LockMouse(routing_id, user_gesture, last_unlocked_by_target, 2055 ViewHostMsg_LockMouse(routing_id, user_gesture, last_unlocked_by_target,
2055 privileged)); 2056 privileged));
2056 } 2057 }
2057 2058
2059 #if defined(USE_AURA)
2060 namespace {
2061 class OverscrollControllerSpyImpl : public OverscrollController,
2062 public OverscrollControllerSpy {
2063 public:
2064 OverscrollControllerSpyImpl()
2065 : content_scrolling_(false),
2066 message_loop_runner_(new MessageLoopRunner) {}
2067 ~OverscrollControllerSpyImpl() override {}
2068
2069 // OverscrollController:
2070 void ReceivedEventACK(const blink::WebInputEvent& event,
2071 bool processed) override {
2072 OverscrollController::ReceivedEventACK(event, processed);
2073
2074 if (scroll_state_ == STATE_CONTENT_SCROLLING) {
2075 content_scrolling_ = true;
2076 if (message_loop_runner_->loop_running())
2077 message_loop_runner_->Quit();
2078 }
2079 }
2080
2081 // OverscrollControllerSpy:
2082 void WaitForScrollStateContentScrolling() override {
2083 if (!content_scrolling_)
2084 message_loop_runner_->Run();
2085 }
2086
2087 private:
2088 bool content_scrolling_;
2089 scoped_refptr<MessageLoopRunner> message_loop_runner_;
2090
2091 DISALLOW_COPY_AND_ASSIGN(OverscrollControllerSpyImpl);
2092 };
2093 } // namespace
2094
2095 // static
2096 OverscrollControllerSpy* OverscrollControllerSpy::Create(
2097 RenderWidgetHostView* rwhv) {
2098 std::unique_ptr<OverscrollControllerSpyImpl> spy =
2099 base::MakeUnique<OverscrollControllerSpyImpl>();
2100 OverscrollControllerSpy* spy_raw = spy.get();
2101
2102 RenderWidgetHostViewAura* rwhva =
2103 static_cast<RenderWidgetHostViewAura*>(rwhv);
2104 rwhva->SetOverscrollControllerForTesting(std::move(spy));
2105
2106 return spy_raw;
2107 }
2108
2109 #endif // defined(USE_AURA)
2110
2058 } // namespace content 2111 } // namespace content
OLDNEW
« content/public/test/browser_test_utils.h ('K') | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698