OLD | NEW |
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 Loading... |
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 Loading... |
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 MockOverscrollControllerImpl : public OverscrollController, |
| 2062 public MockOverscrollController { |
| 2063 public: |
| 2064 MockOverscrollControllerImpl() |
| 2065 : content_scrolling_(false), |
| 2066 message_loop_runner_(new MessageLoopRunner) {} |
| 2067 ~MockOverscrollControllerImpl() override {} |
| 2068 |
| 2069 // OverscrollController: |
| 2070 void ReceivedEventACK(const blink::WebInputEvent& event, |
| 2071 bool processed) override { |
| 2072 // Since we're only mocking this one method of OverscrollController and its |
| 2073 // other methods are non-virtual, we'll delegate to it so that it doesn't |
| 2074 // get into an inconsistent state. |
| 2075 OverscrollController::ReceivedEventACK(event, processed); |
| 2076 |
| 2077 if (event.GetType() == blink::WebInputEvent::kGestureScrollUpdate && |
| 2078 processed) { |
| 2079 content_scrolling_ = true; |
| 2080 if (message_loop_runner_->loop_running()) |
| 2081 message_loop_runner_->Quit(); |
| 2082 } |
| 2083 } |
| 2084 |
| 2085 // MockOverscrollController: |
| 2086 void WaitForConsumedScroll() override { |
| 2087 if (!content_scrolling_) |
| 2088 message_loop_runner_->Run(); |
| 2089 } |
| 2090 |
| 2091 private: |
| 2092 bool content_scrolling_; |
| 2093 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 2094 |
| 2095 DISALLOW_COPY_AND_ASSIGN(MockOverscrollControllerImpl); |
| 2096 }; |
| 2097 } // namespace |
| 2098 |
| 2099 // static |
| 2100 MockOverscrollController* MockOverscrollController::Create( |
| 2101 RenderWidgetHostView* rwhv) { |
| 2102 std::unique_ptr<MockOverscrollControllerImpl> mock = |
| 2103 base::MakeUnique<MockOverscrollControllerImpl>(); |
| 2104 MockOverscrollController* raw_mock = mock.get(); |
| 2105 |
| 2106 RenderWidgetHostViewAura* rwhva = |
| 2107 static_cast<RenderWidgetHostViewAura*>(rwhv); |
| 2108 rwhva->SetOverscrollControllerForTesting(std::move(mock)); |
| 2109 |
| 2110 return raw_mock; |
| 2111 } |
| 2112 |
| 2113 #endif // defined(USE_AURA) |
| 2114 |
2058 } // namespace content | 2115 } // namespace content |
OLD | NEW |