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

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

Issue 19670007: Send input event's LatencyInfo back from renderer to browser when acked (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix compile error in immediate_input_router_unittest.cc Created 7 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
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 "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/mac/scoped_nsautorelease_pool.h" 8 #include "base/mac/scoped_nsautorelease_pool.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/browser_thread_impl.h" 10 #include "content/browser/browser_thread_impl.h"
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 RenderWidgetHostViewMac* view = static_cast<RenderWidgetHostViewMac*>( 704 RenderWidgetHostViewMac* view = static_cast<RenderWidgetHostViewMac*>(
705 RenderWidgetHostView::CreateViewForWidget(host)); 705 RenderWidgetHostView::CreateViewForWidget(host));
706 706
707 // Send an initial wheel event with NSEventPhaseBegan to the view. 707 // Send an initial wheel event with NSEventPhaseBegan to the view.
708 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0); 708 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0);
709 [view->cocoa_view() scrollWheel:event1]; 709 [view->cocoa_view() scrollWheel:event1];
710 ASSERT_EQ(1U, process_host->sink().message_count()); 710 ASSERT_EQ(1U, process_host->sink().message_count());
711 711
712 // Send an ACK for the first wheel event, so that the queue will be flushed. 712 // Send an ACK for the first wheel event, so that the queue will be flushed.
713 scoped_ptr<IPC::Message> response(new InputHostMsg_HandleInputEvent_ACK( 713 scoped_ptr<IPC::Message> response(new InputHostMsg_HandleInputEvent_ACK(
714 0, WebKit::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED)); 714 0, WebKit::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED,
715 ui::LatencyInfo()));
715 host->OnMessageReceived(*response); 716 host->OnMessageReceived(*response);
716 717
717 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the 718 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the
718 // render view receives it. 719 // render view receives it.
719 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); 720 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0);
720 [NSApp postEvent:event2 atStart:NO]; 721 [NSApp postEvent:event2 atStart:NO];
721 base::MessageLoop::current()->RunUntilIdle(); 722 base::MessageLoop::current()->RunUntilIdle();
722 ASSERT_EQ(2U, process_host->sink().message_count()); 723 ASSERT_EQ(2U, process_host->sink().message_count());
723 724
724 // Clean up. 725 // Clean up.
(...skipping 23 matching lines...) Expand all
748 view->SetDelegate(view_delegate.get()); 749 view->SetDelegate(view_delegate.get());
749 750
750 // Send an initial wheel event for scrolling by 3 lines. 751 // Send an initial wheel event for scrolling by 3 lines.
751 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3); 752 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3);
752 [view->cocoa_view() scrollWheel:event1]; 753 [view->cocoa_view() scrollWheel:event1];
753 ASSERT_EQ(1U, process_host->sink().message_count()); 754 ASSERT_EQ(1U, process_host->sink().message_count());
754 process_host->sink().ClearMessages(); 755 process_host->sink().ClearMessages();
755 756
756 // Indicate that the wheel event was unhandled. 757 // Indicate that the wheel event was unhandled.
757 scoped_ptr<IPC::Message> response1(new InputHostMsg_HandleInputEvent_ACK(0, 758 scoped_ptr<IPC::Message> response1(new InputHostMsg_HandleInputEvent_ACK(0,
758 WebKit::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); 759 WebKit::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED,
760 ui::LatencyInfo()));
759 host->OnMessageReceived(*response1); 761 host->OnMessageReceived(*response1);
760 762
761 // Check that the view delegate got an unhandled wheel event. 763 // Check that the view delegate got an unhandled wheel event.
762 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); 764 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived);
763 view_delegate.get().unhandledWheelEventReceived = NO; 765 view_delegate.get().unhandledWheelEventReceived = NO;
764 766
765 // Send another wheel event, this time for scrolling by 0 lines (empty event). 767 // Send another wheel event, this time for scrolling by 0 lines (empty event).
766 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0); 768 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0);
767 [view->cocoa_view() scrollWheel:event2]; 769 [view->cocoa_view() scrollWheel:event2];
768 ASSERT_EQ(1U, process_host->sink().message_count()); 770 ASSERT_EQ(1U, process_host->sink().message_count());
769 771
770 // Indicate that the wheel event was also unhandled. 772 // Indicate that the wheel event was also unhandled.
771 scoped_ptr<IPC::Message> response2(new InputHostMsg_HandleInputEvent_ACK(0, 773 scoped_ptr<IPC::Message> response2(new InputHostMsg_HandleInputEvent_ACK(0,
772 WebKit::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); 774 WebKit::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED,
775 ui::LatencyInfo()));
773 host->OnMessageReceived(*response2); 776 host->OnMessageReceived(*response2);
774 777
775 // Check that the view delegate ignored the empty unhandled wheel event. 778 // Check that the view delegate ignored the empty unhandled wheel event.
776 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); 779 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived);
777 780
778 // Clean up. 781 // Clean up.
779 host->Shutdown(); 782 host->Shutdown();
780 } 783 }
781 784
782 } // namespace content 785 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_unittest.cc ('k') | content/common/input_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698