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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac_unittest.mm

Issue 997283002: Coalesce async touch move events until the ack back from render (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Format input_message Created 5 years, 7 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_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 8
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/mac/scoped_nsautorelease_pool.h" 10 #include "base/mac/scoped_nsautorelease_pool.h"
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( 704 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl(
705 &delegate, process_host, MSG_ROUTING_NONE); 705 &delegate, process_host, MSG_ROUTING_NONE);
706 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); 706 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false);
707 707
708 // Send an initial wheel event with NSEventPhaseBegan to the view. 708 // Send an initial wheel event with NSEventPhaseBegan to the view.
709 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0); 709 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0);
710 [view->cocoa_view() scrollWheel:event1]; 710 [view->cocoa_view() scrollWheel:event1];
711 ASSERT_EQ(1U, process_host->sink().message_count()); 711 ASSERT_EQ(1U, process_host->sink().message_count());
712 712
713 // Send an ACK for the first wheel event, so that the queue will be flushed. 713 // Send an ACK for the first wheel event, so that the queue will be flushed.
714 InputHostMsg_HandleInputEvent_ACK_Params ack; 714 InputEventAck ack(blink::WebInputEvent::MouseWheel,
715 ack.type = blink::WebInputEvent::MouseWheel; 715 INPUT_EVENT_ACK_STATE_CONSUMED);
716 ack.state = INPUT_EVENT_ACK_STATE_CONSUMED;
717 scoped_ptr<IPC::Message> response( 716 scoped_ptr<IPC::Message> response(
718 new InputHostMsg_HandleInputEvent_ACK(0, ack)); 717 new InputHostMsg_HandleInputEvent_ACK(0, ack));
719 host->OnMessageReceived(*response); 718 host->OnMessageReceived(*response);
720 719
721 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the 720 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the
722 // render view receives it. 721 // render view receives it.
723 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); 722 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0);
724 [NSApp postEvent:event2 atStart:NO]; 723 [NSApp postEvent:event2 atStart:NO];
725 base::MessageLoop::current()->RunUntilIdle(); 724 base::MessageLoop::current()->RunUntilIdle();
726 ASSERT_EQ(2U, process_host->sink().message_count()); 725 ASSERT_EQ(2U, process_host->sink().message_count());
(...skipping 23 matching lines...) Expand all
750 [[MockRenderWidgetHostViewMacDelegate alloc] init]); 749 [[MockRenderWidgetHostViewMacDelegate alloc] init]);
751 view->SetDelegate(view_delegate.get()); 750 view->SetDelegate(view_delegate.get());
752 751
753 // Send an initial wheel event for scrolling by 3 lines. 752 // Send an initial wheel event for scrolling by 3 lines.
754 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3); 753 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3);
755 [view->cocoa_view() scrollWheel:event1]; 754 [view->cocoa_view() scrollWheel:event1];
756 ASSERT_EQ(1U, process_host->sink().message_count()); 755 ASSERT_EQ(1U, process_host->sink().message_count());
757 process_host->sink().ClearMessages(); 756 process_host->sink().ClearMessages();
758 757
759 // Indicate that the wheel event was unhandled. 758 // Indicate that the wheel event was unhandled.
760 InputHostMsg_HandleInputEvent_ACK_Params unhandled_ack; 759 InputEventAck unhandled_ack(blink::WebInputEvent::MouseWheel,
761 unhandled_ack.type = blink::WebInputEvent::MouseWheel; 760 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
762 unhandled_ack.state = INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
763 scoped_ptr<IPC::Message> response1( 761 scoped_ptr<IPC::Message> response1(
764 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); 762 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack));
765 host->OnMessageReceived(*response1); 763 host->OnMessageReceived(*response1);
766 764
767 // Check that the view delegate got an unhandled wheel event. 765 // Check that the view delegate got an unhandled wheel event.
768 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); 766 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived);
769 view_delegate.get().unhandledWheelEventReceived = NO; 767 view_delegate.get().unhandledWheelEventReceived = NO;
770 768
771 // Send another wheel event, this time for scrolling by 0 lines (empty event). 769 // Send another wheel event, this time for scrolling by 0 lines (empty event).
772 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0); 770 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 // the MockRenderProcessHost that is set up by the test harness which mocks 905 // the MockRenderProcessHost that is set up by the test harness which mocks
908 // out |OnMessageReceived()|. 906 // out |OnMessageReceived()|.
909 TestBrowserContext browser_context; 907 TestBrowserContext browser_context;
910 process_host_ = new MockRenderProcessHost(&browser_context); 908 process_host_ = new MockRenderProcessHost(&browser_context);
911 MockRenderWidgetHostDelegate delegate; 909 MockRenderWidgetHostDelegate delegate;
912 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( 910 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl(
913 &delegate, process_host_, MSG_ROUTING_NONE); 911 &delegate, process_host_, MSG_ROUTING_NONE);
914 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); 912 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false);
915 913
916 // We'll use this IPC message to ack events. 914 // We'll use this IPC message to ack events.
917 InputHostMsg_HandleInputEvent_ACK_Params ack; 915 InputEventAck ack(blink::WebInputEvent::GesturePinchUpdate,
918 ack.type = blink::WebInputEvent::GesturePinchUpdate; 916 INPUT_EVENT_ACK_STATE_CONSUMED);
919 ack.state = INPUT_EVENT_ACK_STATE_CONSUMED;
920 scoped_ptr<IPC::Message> response( 917 scoped_ptr<IPC::Message> response(
921 new InputHostMsg_HandleInputEvent_ACK(0, ack)); 918 new InputHostMsg_HandleInputEvent_ACK(0, ack));
922 919
923 // Do a gesture that crosses the threshold. 920 // Do a gesture that crosses the threshold.
924 { 921 {
925 NSEvent* pinchBeginEvent = 922 NSEvent* pinchBeginEvent =
926 MockGestureEvent(NSEventTypeBeginGesture, 0); 923 MockGestureEvent(NSEventTypeBeginGesture, 0);
927 NSEvent* pinchUpdateEvents[3] = { 924 NSEvent* pinchUpdateEvents[3] = {
928 MockGestureEvent(NSEventTypeMagnify, 0.25), 925 MockGestureEvent(NSEventTypeMagnify, 0.25),
929 MockGestureEvent(NSEventTypeMagnify, 0.25), 926 MockGestureEvent(NSEventTypeMagnify, 0.25),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 EXPECT_EQ(1U, process_host_->sink().message_count()); 1010 EXPECT_EQ(1U, process_host_->sink().message_count());
1014 process_host_->sink().ClearMessages(); 1011 process_host_->sink().ClearMessages();
1015 } 1012 }
1016 1013
1017 // Clean up. 1014 // Clean up.
1018 host->Shutdown(); 1015 host->Shutdown();
1019 } 1016 }
1020 1017
1021 1018
1022 } // namespace content 1019 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura_unittest.cc ('k') | content/common/input/input_event_ack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698