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

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

Issue 680413006: Re-enable Eager Gesture Recognition on Aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address sadrul's comments. Created 6 years 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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 EXPECT_TRUE(view_->touch_event_.cancelable); 984 EXPECT_TRUE(view_->touch_event_.cancelable);
985 EXPECT_EQ(0U, view_->touch_event_.touchesLength); 985 EXPECT_EQ(0U, view_->touch_event_.touchesLength);
986 986
987 // Now install some touch-event handlers and do the same steps. The touch 987 // Now install some touch-event handlers and do the same steps. The touch
988 // events should now be consumed. However, the touch-event state should be 988 // events should now be consumed. However, the touch-event state should be
989 // updated as before. 989 // updated as before.
990 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); 990 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true));
991 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); 991 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent());
992 992
993 view_->OnTouchEvent(&press); 993 view_->OnTouchEvent(&press);
994 EXPECT_TRUE(press.stopped_propagation()); 994 EXPECT_TRUE(press.synchronous_handling_disabled());
995 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); 995 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type);
996 EXPECT_TRUE(view_->touch_event_.cancelable); 996 EXPECT_TRUE(view_->touch_event_.cancelable);
997 EXPECT_EQ(1U, view_->touch_event_.touchesLength); 997 EXPECT_EQ(1U, view_->touch_event_.touchesLength);
998 EXPECT_EQ(blink::WebTouchPoint::StatePressed, 998 EXPECT_EQ(blink::WebTouchPoint::StatePressed,
999 view_->touch_event_.touches[0].state); 999 view_->touch_event_.touches[0].state);
1000 1000
1001 view_->OnTouchEvent(&move); 1001 view_->OnTouchEvent(&move);
1002 EXPECT_TRUE(move.stopped_propagation()); 1002 EXPECT_TRUE(move.synchronous_handling_disabled());
1003 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); 1003 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type);
1004 EXPECT_TRUE(view_->touch_event_.cancelable); 1004 EXPECT_TRUE(view_->touch_event_.cancelable);
1005 EXPECT_EQ(1U, view_->touch_event_.touchesLength); 1005 EXPECT_EQ(1U, view_->touch_event_.touchesLength);
1006 EXPECT_EQ(blink::WebTouchPoint::StateMoved, 1006 EXPECT_EQ(blink::WebTouchPoint::StateMoved,
1007 view_->touch_event_.touches[0].state); 1007 view_->touch_event_.touches[0].state);
1008 1008
1009 view_->OnTouchEvent(&release); 1009 view_->OnTouchEvent(&release);
1010 EXPECT_TRUE(release.stopped_propagation()); 1010 EXPECT_TRUE(release.synchronous_handling_disabled());
1011 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); 1011 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type);
1012 EXPECT_TRUE(view_->touch_event_.cancelable); 1012 EXPECT_TRUE(view_->touch_event_.cancelable);
1013 EXPECT_EQ(0U, view_->touch_event_.touchesLength); 1013 EXPECT_EQ(0U, view_->touch_event_.touchesLength);
1014 1014
1015 // Now start a touch event, and remove the event-handlers before the release. 1015 // Now start a touch event, and remove the event-handlers before the release.
1016 view_->OnTouchEvent(&press); 1016 view_->OnTouchEvent(&press);
1017 EXPECT_TRUE(press.stopped_propagation()); 1017 EXPECT_TRUE(press.synchronous_handling_disabled());
1018 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); 1018 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type);
1019 EXPECT_EQ(1U, view_->touch_event_.touchesLength); 1019 EXPECT_EQ(1U, view_->touch_event_.touchesLength);
1020 EXPECT_EQ(blink::WebTouchPoint::StatePressed, 1020 EXPECT_EQ(blink::WebTouchPoint::StatePressed,
1021 view_->touch_event_.touches[0].state); 1021 view_->touch_event_.touches[0].state);
1022 1022
1023 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); 1023 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false));
1024 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); 1024 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent());
1025 1025
1026 // Ack'ing the outstanding event should flush the pending touch queue. 1026 // Ack'ing the outstanding event should flush the pending touch queue.
1027 InputHostMsg_HandleInputEvent_ACK_Params ack; 1027 InputHostMsg_HandleInputEvent_ACK_Params ack;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 ui::TouchEvent move(ui::ET_TOUCH_MOVED, 1063 ui::TouchEvent move(ui::ET_TOUCH_MOVED,
1064 gfx::Point(20, 20), 1064 gfx::Point(20, 20),
1065 0, 1065 0,
1066 ui::EventTimeForNow()); 1066 ui::EventTimeForNow());
1067 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, 1067 ui::TouchEvent release(ui::ET_TOUCH_RELEASED,
1068 gfx::Point(20, 20), 1068 gfx::Point(20, 20),
1069 0, 1069 0,
1070 ui::EventTimeForNow()); 1070 ui::EventTimeForNow());
1071 1071
1072 view_->OnTouchEvent(&press); 1072 view_->OnTouchEvent(&press);
1073 EXPECT_TRUE(press.stopped_propagation()); 1073 EXPECT_TRUE(press.synchronous_handling_disabled());
1074 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); 1074 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type);
1075 EXPECT_EQ(1U, view_->touch_event_.touchesLength); 1075 EXPECT_EQ(1U, view_->touch_event_.touchesLength);
1076 EXPECT_EQ(blink::WebTouchPoint::StatePressed, 1076 EXPECT_EQ(blink::WebTouchPoint::StatePressed,
1077 view_->touch_event_.touches[0].state); 1077 view_->touch_event_.touches[0].state);
1078 1078
1079 view_->OnTouchEvent(&move); 1079 view_->OnTouchEvent(&move);
1080 EXPECT_TRUE(move.stopped_propagation()); 1080 EXPECT_TRUE(move.synchronous_handling_disabled());
1081 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); 1081 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type);
1082 EXPECT_EQ(1U, view_->touch_event_.touchesLength); 1082 EXPECT_EQ(1U, view_->touch_event_.touchesLength);
1083 EXPECT_EQ(blink::WebTouchPoint::StateMoved, 1083 EXPECT_EQ(blink::WebTouchPoint::StateMoved,
1084 view_->touch_event_.touches[0].state); 1084 view_->touch_event_.touches[0].state);
1085 1085
1086 // Send the same move event. Since the point hasn't moved, it won't affect the 1086 // Send the same move event. Since the point hasn't moved, it won't affect the
1087 // queue. However, the view should consume the event. 1087 // queue. However, the view should consume the event.
1088 view_->OnTouchEvent(&move); 1088 view_->OnTouchEvent(&move);
1089 EXPECT_TRUE(move.stopped_propagation()); 1089 EXPECT_TRUE(move.synchronous_handling_disabled());
1090 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); 1090 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type);
1091 EXPECT_EQ(1U, view_->touch_event_.touchesLength); 1091 EXPECT_EQ(1U, view_->touch_event_.touchesLength);
1092 EXPECT_EQ(blink::WebTouchPoint::StateMoved, 1092 EXPECT_EQ(blink::WebTouchPoint::StateMoved,
1093 view_->touch_event_.touches[0].state); 1093 view_->touch_event_.touches[0].state);
1094 1094
1095 view_->OnTouchEvent(&release); 1095 view_->OnTouchEvent(&release);
1096 EXPECT_TRUE(release.stopped_propagation()); 1096 EXPECT_TRUE(release.synchronous_handling_disabled());
1097 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); 1097 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type);
1098 EXPECT_EQ(0U, view_->touch_event_.touchesLength); 1098 EXPECT_EQ(0U, view_->touch_event_.touchesLength);
1099 } 1099 }
1100 1100
1101 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { 1101 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) {
1102 view_->InitAsChild(NULL); 1102 view_->InitAsChild(NULL);
1103 aura::client::ParentWindowWithContext( 1103 aura::client::ParentWindowWithContext(
1104 view_->GetNativeView(), 1104 view_->GetNativeView(),
1105 parent_view_->GetNativeView()->GetRootWindow(), 1105 parent_view_->GetNativeView()->GetRootWindow(),
1106 gfx::Rect()); 1106 gfx::Rect());
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
2936 EXPECT_EQ(3U, sink_->message_count()); 2936 EXPECT_EQ(3U, sink_->message_count());
2937 } 2937 }
2938 2938
2939 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted 2939 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted
2940 // before RWH), we clean up properly and don't leak the RWHVGuest. 2940 // before RWH), we clean up properly and don't leak the RWHVGuest.
2941 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { 2941 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) {
2942 TearDownEnvironment(); 2942 TearDownEnvironment();
2943 ASSERT_FALSE(guest_view_weak_.get()); 2943 ASSERT_FALSE(guest_view_weak_.get());
2944 } 2944 }
2945 2945
2946 // Tests that invalid touch events are consumed and handled
2947 // synchronously.
2948 TEST_F(RenderWidgetHostViewAuraTest,
2949 InvalidEventsHaveSyncHandlingDisabled) {
2950 view_->InitAsChild(NULL);
2951 view_->Show();
2952
2953 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true));
2954 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent());
2955
2956 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0,
2957 ui::EventTimeForNow());
2958
2959 // Construct a move with a touch id which doesn't exist.
2960 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1,
2961 ui::EventTimeForNow());
2962
2963 view_->OnTouchEvent(&press);
2964 view_->OnTouchEvent(&invalid_move);
2965 // Valid press is handled asynchronously.
2966 EXPECT_TRUE(press.synchronous_handling_disabled());
2967 // Invalid move is handled synchronously, but is consumed.
2968 EXPECT_FALSE(invalid_move.synchronous_handling_disabled());
2969 EXPECT_TRUE(invalid_move.stopped_propagation());
2970 }
2971
2946 } // namespace content 2972 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | ui/aura/gestures/gesture_recognizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698