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

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

Issue 1848063002: Fix page navigation being incorrectly fired on Mac OSX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 @implementation MockRenderWidgetHostViewMacDelegate 73 @implementation MockRenderWidgetHostViewMacDelegate
74 74
75 @synthesize unhandledWheelEventReceived = unhandledWheelEventReceived_; 75 @synthesize unhandledWheelEventReceived = unhandledWheelEventReceived_;
76 76
77 - (void)rendererHandledWheelEvent:(const blink::WebMouseWheelEvent&)event 77 - (void)rendererHandledWheelEvent:(const blink::WebMouseWheelEvent&)event
78 consumed:(BOOL)consumed { 78 consumed:(BOOL)consumed {
79 if (!consumed) 79 if (!consumed)
80 unhandledWheelEventReceived_ = true; 80 unhandledWheelEventReceived_ = true;
81 } 81 }
82 - (void)rendererHandledGestureScrollEvent:(const blink::WebGestureEvent&)event
83 consumed:(BOOL)consumed {
84 if (!consumed && event.type == blink::WebInputEvent::GestureScrollUpdate)
85 unhandledWheelEventReceived_ = true;
86 }
82 - (void)touchesBeganWithEvent:(NSEvent*)event {} 87 - (void)touchesBeganWithEvent:(NSEvent*)event {}
83 - (void)touchesMovedWithEvent:(NSEvent*)event {} 88 - (void)touchesMovedWithEvent:(NSEvent*)event {}
84 - (void)touchesCancelledWithEvent:(NSEvent*)event {} 89 - (void)touchesCancelledWithEvent:(NSEvent*)event {}
85 - (void)touchesEndedWithEvent:(NSEvent*)event {} 90 - (void)touchesEndedWithEvent:(NSEvent*)event {}
86 - (void)beginGestureWithEvent:(NSEvent*)event {} 91 - (void)beginGestureWithEvent:(NSEvent*)event {}
87 - (void)endGestureWithEvent:(NSEvent*)event {} 92 - (void)endGestureWithEvent:(NSEvent*)event {}
88 - (BOOL)canRubberbandLeft:(NSView*)view { 93 - (BOOL)canRubberbandLeft:(NSView*)view {
89 return true; 94 return true;
90 } 95 }
91 - (BOOL)canRubberbandRight:(NSView*)view { 96 - (BOOL)canRubberbandRight:(NSView*)view {
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 956
952 // Indicate that the wheel event was unhandled. 957 // Indicate that the wheel event was unhandled.
953 InputEventAck unhandled_ack(blink::WebInputEvent::MouseWheel, 958 InputEventAck unhandled_ack(blink::WebInputEvent::MouseWheel,
954 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 959 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
955 scoped_ptr<IPC::Message> response1( 960 scoped_ptr<IPC::Message> response1(
956 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); 961 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack));
957 host->OnMessageReceived(*response1); 962 host->OnMessageReceived(*response1);
958 ASSERT_EQ(2U, process_host->sink().message_count()); 963 ASSERT_EQ(2U, process_host->sink().message_count());
959 process_host->sink().ClearMessages(); 964 process_host->sink().ClearMessages();
960 965
966 InputEventAck unhandled_scroll_ack(blink::WebInputEvent::GestureScrollUpdate,
967 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
968 scoped_ptr<IPC::Message> scroll_response1(
969 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_scroll_ack));
970 host->OnMessageReceived(*scroll_response1);
971
961 // Check that the view delegate got an unhandled wheel event. 972 // Check that the view delegate got an unhandled wheel event.
962 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); 973 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived);
963 view_delegate.get().unhandledWheelEventReceived = NO; 974 view_delegate.get().unhandledWheelEventReceived = NO;
964 975
965 // Send another wheel event, this time for scrolling by 0 lines (empty event). 976 // Send another wheel event, this time for scrolling by 0 lines (empty event).
966 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0); 977 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0);
967 [view->cocoa_view() scrollWheel:event2]; 978 [view->cocoa_view() scrollWheel:event2];
968 ASSERT_EQ(1U, process_host->sink().message_count()); 979 ASSERT_EQ(2U, process_host->sink().message_count());
969 980
970 // Indicate that the wheel event was also unhandled. 981 // Indicate that the wheel event was also unhandled.
971 scoped_ptr<IPC::Message> response2( 982 scoped_ptr<IPC::Message> response2(
972 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); 983 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack));
973 host->OnMessageReceived(*response2); 984 host->OnMessageReceived(*response2);
974 985
986 scoped_ptr<IPC::Message> scroll_response2(
987 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_scroll_ack));
988 host->OnMessageReceived(*scroll_response2);
989
975 // Check that the view delegate ignored the empty unhandled wheel event. 990 // Check that the view delegate ignored the empty unhandled wheel event.
976 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); 991 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived);
977 992
978 // Clean up. 993 // Clean up.
979 host->ShutdownAndDestroyWidget(true); 994 host->ShutdownAndDestroyWidget(true);
980 } 995 }
981 996
982 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted 997 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted
983 // before RWH), we clean up properly and don't leak the RWHVGuest. 998 // before RWH), we clean up properly and don't leak the RWHVGuest.
984 TEST_F(RenderWidgetHostViewMacTest, GuestViewDoesNotLeak) { 999 TEST_F(RenderWidgetHostViewMacTest, GuestViewDoesNotLeak) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 EXPECT_EQ(1U, process_host_->sink().message_count()); 1230 EXPECT_EQ(1U, process_host_->sink().message_count());
1216 process_host_->sink().ClearMessages(); 1231 process_host_->sink().ClearMessages();
1217 } 1232 }
1218 1233
1219 // Clean up. 1234 // Clean up.
1220 host->ShutdownAndDestroyWidget(true); 1235 host->ShutdownAndDestroyWidget(true);
1221 } 1236 }
1222 1237
1223 1238
1224 } // namespace content 1239 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698