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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 503883004: Don't pass touches to gesture recognizer for async acks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 10 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/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 25 matching lines...) Expand all
36 #include "content/public/test/test_browser_context.h" 36 #include "content/public/test/test_browser_context.h"
37 #include "ipc/ipc_test_sink.h" 37 #include "ipc/ipc_test_sink.h"
38 #include "testing/gmock/include/gmock/gmock.h" 38 #include "testing/gmock/include/gmock/gmock.h"
39 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
40 #include "ui/aura/client/aura_constants.h" 40 #include "ui/aura/client/aura_constants.h"
41 #include "ui/aura/client/screen_position_client.h" 41 #include "ui/aura/client/screen_position_client.h"
42 #include "ui/aura/client/window_tree_client.h" 42 #include "ui/aura/client/window_tree_client.h"
43 #include "ui/aura/env.h" 43 #include "ui/aura/env.h"
44 #include "ui/aura/layout_manager.h" 44 #include "ui/aura/layout_manager.h"
45 #include "ui/aura/test/aura_test_helper.h" 45 #include "ui/aura/test/aura_test_helper.h"
46 #include "ui/aura/test/aura_test_utils.h"
46 #include "ui/aura/test/test_cursor_client.h" 47 #include "ui/aura/test/test_cursor_client.h"
47 #include "ui/aura/test/test_screen.h" 48 #include "ui/aura/test/test_screen.h"
48 #include "ui/aura/test/test_window_delegate.h" 49 #include "ui/aura/test/test_window_delegate.h"
49 #include "ui/aura/window.h" 50 #include "ui/aura/window.h"
50 #include "ui/aura/window_event_dispatcher.h" 51 #include "ui/aura/window_event_dispatcher.h"
51 #include "ui/aura/window_observer.h" 52 #include "ui/aura/window_observer.h"
52 #include "ui/base/ui_base_types.h" 53 #include "ui/base/ui_base_types.h"
53 #include "ui/compositor/compositor.h" 54 #include "ui/compositor/compositor.h"
54 #include "ui/compositor/layer_tree_owner.h" 55 #include "ui/compositor/layer_tree_owner.h"
55 #include "ui/compositor/test/draw_waiter_for_test.h" 56 #include "ui/compositor/test/draw_waiter_for_test.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 base::TimeTicks timestamp, 202 base::TimeTicks timestamp,
202 bool success) { 203 bool success) {
203 callback.Run(success); 204 callback.Run(success);
204 } 205 }
205 206
206 private: 207 private:
207 gfx::Size size_; 208 gfx::Size size_;
208 base::Callback<void(bool)> callback_; 209 base::Callback<void(bool)> callback_;
209 }; 210 };
210 211
212 class FakeWindowEventDispatcher : public aura::WindowEventDispatcher {
213 public:
214 FakeWindowEventDispatcher(aura::WindowTreeHost* host)
215 : WindowEventDispatcher(host),
216 processed_touch_event_count_(0) {}
217
218 void ProcessedTouchEvent(aura::Window* window,
219 ui::EventResult result) override {
220 WindowEventDispatcher::ProcessedTouchEvent(window, result);
221 processed_touch_event_count_++;
222 }
223
224 size_t processed_touch_event_count() {
225 return processed_touch_event_count_;
226 }
227
228 private:
229 size_t processed_touch_event_count_;
230 };
231
211 class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura { 232 class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura {
212 public: 233 public:
213 FakeRenderWidgetHostViewAura(RenderWidgetHost* widget, 234 FakeRenderWidgetHostViewAura(RenderWidgetHost* widget,
214 bool is_guest_view_hack) 235 bool is_guest_view_hack)
215 : RenderWidgetHostViewAura(widget, is_guest_view_hack), 236 : RenderWidgetHostViewAura(widget, is_guest_view_hack),
216 has_resize_lock_(false) {} 237 has_resize_lock_(false) {}
217 238
239 void UseFakeDispatcher() {
240 dispatcher_ = new FakeWindowEventDispatcher(window()->GetHost());
241 aura::test::SetHostDispatcher(window()->GetHost(), dispatcher_);
242 }
243
218 ~FakeRenderWidgetHostViewAura() override {} 244 ~FakeRenderWidgetHostViewAura() override {}
219 245
220 scoped_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( 246 scoped_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock(
221 bool defer_compositor_lock) override { 247 bool defer_compositor_lock) override {
222 gfx::Size desired_size = window()->bounds().size(); 248 gfx::Size desired_size = window()->bounds().size();
223 return scoped_ptr<ResizeLock>( 249 return scoped_ptr<ResizeLock>(
224 new FakeResizeLock(desired_size, defer_compositor_lock)); 250 new FakeResizeLock(desired_size, defer_compositor_lock));
225 } 251 }
226 252
227 bool DelegatedFrameCanCreateResizeLock() const override { return true; } 253 bool DelegatedFrameCanCreateResizeLock() const override { return true; }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // Never create a WebTouchEvent with 0 touch points. 304 // Never create a WebTouchEvent with 0 touch points.
279 touch_event_.reset(); 305 touch_event_.reset();
280 } 306 }
281 } 307 }
282 308
283 bool has_resize_lock_; 309 bool has_resize_lock_;
284 gfx::Size last_frame_size_; 310 gfx::Size last_frame_size_;
285 scoped_ptr<cc::CopyOutputRequest> last_copy_request_; 311 scoped_ptr<cc::CopyOutputRequest> last_copy_request_;
286 // null if there are 0 active touch points. 312 // null if there are 0 active touch points.
287 scoped_ptr<blink::WebTouchEvent> touch_event_; 313 scoped_ptr<blink::WebTouchEvent> touch_event_;
314 FakeWindowEventDispatcher* dispatcher_;
288 }; 315 };
289 316
290 // A layout manager that always resizes a child to the root window size. 317 // A layout manager that always resizes a child to the root window size.
291 class FullscreenLayoutManager : public aura::LayoutManager { 318 class FullscreenLayoutManager : public aura::LayoutManager {
292 public: 319 public:
293 explicit FullscreenLayoutManager(aura::Window* owner) : owner_(owner) {} 320 explicit FullscreenLayoutManager(aura::Window* owner) : owner_(owner) {}
294 ~FullscreenLayoutManager() override {} 321 ~FullscreenLayoutManager() override {}
295 322
296 // Overridden from aura::LayoutManager: 323 // Overridden from aura::LayoutManager:
297 void OnWindowResized() override { 324 void OnWindowResized() override {
(...skipping 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after
3158 ui::EF_CONTROL_DOWN, 0, 5, 0, 5, 2); 3185 ui::EF_CONTROL_DOWN, 0, 5, 0, 5, 2);
3159 view_->OnScrollEvent(&scroll); 3186 view_->OnScrollEvent(&scroll);
3160 3187
3161 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); 3188 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0));
3162 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); 3189 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event);
3163 // Check if the canScroll set to true when ctrl-touchpad-scroll is generated 3190 // Check if the canScroll set to true when ctrl-touchpad-scroll is generated
3164 // from scroll event. 3191 // from scroll event.
3165 EXPECT_TRUE(wheel_event->canScroll); 3192 EXPECT_TRUE(wheel_event->canScroll);
3166 } 3193 }
3167 3194
3195 // Ensures that the mapping from ui::TouchEvent to blink::WebTouchEvent doesn't
3196 // lose track of the number of acks required.
3197 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) {
3198 view_->InitAsFullscreen(parent_view_);
3199 view_->Show();
3200 view_->UseFakeDispatcher();
3201
3202 ui::TouchEvent press1(
3203 ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, ui::EventTimeForNow());
3204
3205 view_->OnTouchEvent(&press1);
3206 SendInputEventACK(blink::WebInputEvent::TouchStart,
3207 INPUT_EVENT_ACK_STATE_CONSUMED);
3208
3209 ui::TouchEvent press2(
3210 ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 1, ui::EventTimeForNow());
3211 view_->OnTouchEvent(&press2);
3212 SendInputEventACK(blink::WebInputEvent::TouchStart,
3213 INPUT_EVENT_ACK_STATE_CONSUMED);
3214
3215 EXPECT_EQ(2U, view_->dispatcher_->processed_touch_event_count());
3216 }
3217
3168 } // namespace content 3218 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698