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

Side by Side Diff: ui/views/widget/root_view_unittest.cc

Issue 404213003: [WIP] Allow scroll events to permanently change the default gesture handler in RootView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: friend test Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/views/widget/root_view.h" 5 #include "ui/views/widget/root_view.h"
6 6
7 #include "ui/views/context_menu_controller.h" 7 #include "ui/views/context_menu_controller.h"
8 #include "ui/views/test/views_test_base.h" 8 #include "ui/views/test/views_test_base.h"
9 #include "ui/views/view_targeter.h" 9 #include "ui/views/view_targeter.h"
10 #include "ui/views/widget/root_view.h" 10 #include "ui/views/widget/root_view.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 View* gesture_handling_child_view = new GestureHandlingView; 194 View* gesture_handling_child_view = new GestureHandlingView;
195 gesture_handling_child_view->SetBoundsRect(gfx::Rect(10,10)); 195 gesture_handling_child_view->SetBoundsRect(gfx::Rect(10,10));
196 parent_view->AddChildView(gesture_handling_child_view); 196 parent_view->AddChildView(gesture_handling_child_view);
197 197
198 View* other_child_view = new View; 198 View* other_child_view = new View;
199 other_child_view->SetBoundsRect(gfx::Rect(20, 0, 10,10)); 199 other_child_view->SetBoundsRect(gfx::Rect(20, 0, 10,10));
200 parent_view->AddChildView(other_child_view); 200 parent_view->AddChildView(other_child_view);
201 201
202 // |parent_view| should not show a context menu as a result of a long press on 202 // |parent_view| should not show a context menu as a result of a long press on
203 // |gesture_handling_child_view|. 203 // |gesture_handling_child_view|.
204 ui::GestureEvent begin1(5, 5, 0, base::TimeDelta(),
205 ui::GestureEventDetails(ui::ET_GESTURE_BEGIN, 0, 0));
206 ui::EventDispatchDetails details = root_view->OnEventFromSource(&begin1);
207
208 ui::GestureEvent long_press1( 204 ui::GestureEvent long_press1(
209 5, 205 5,
210 5, 206 5,
211 0, 207 0,
212 base::TimeDelta(), 208 base::TimeDelta(),
213 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); 209 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0));
214 details = root_view->OnEventFromSource(&long_press1); 210 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1);
215 211
216 ui::GestureEvent end1(5, 212 ui::GestureEvent end1(5,
217 5, 213 5,
218 0, 214 0,
219 base::TimeDelta(), 215 base::TimeDelta(),
220 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0)); 216 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
221 details = root_view->OnEventFromSource(&end1); 217 details = root_view->OnEventFromSource(&end1);
222 218
223 EXPECT_FALSE(details.target_destroyed); 219 EXPECT_FALSE(details.target_destroyed);
224 EXPECT_FALSE(details.dispatcher_destroyed); 220 EXPECT_FALSE(details.dispatcher_destroyed);
225 EXPECT_EQ(0, controller.show_context_menu_calls()); 221 EXPECT_EQ(0, controller.show_context_menu_calls());
226 222
227 // |parent_view| should show a context menu as a result of a long press on 223 // |parent_view| should show a context menu as a result of a long press on
228 // |other_child_view|. 224 // |other_child_view|.
229 ui::GestureEvent begin2(25, 5, 0, base::TimeDelta(),
230 ui::GestureEventDetails(ui::ET_GESTURE_BEGIN, 0, 0));
231 details = root_view->OnEventFromSource(&begin2);
232
233 ui::GestureEvent long_press2( 225 ui::GestureEvent long_press2(
234 25, 226 25,
235 5, 227 5,
236 0, 228 0,
237 base::TimeDelta(), 229 base::TimeDelta(),
238 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); 230 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0));
239 details = root_view->OnEventFromSource(&long_press2); 231 details = root_view->OnEventFromSource(&long_press2);
240 232
241 ui::GestureEvent end2(25, 233 ui::GestureEvent end2(25,
242 5, 234 5,
243 0, 235 0,
244 base::TimeDelta(), 236 base::TimeDelta(),
245 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0)); 237 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
246 details = root_view->OnEventFromSource(&end2); 238 details = root_view->OnEventFromSource(&end2);
247 239
248 EXPECT_FALSE(details.target_destroyed); 240 EXPECT_FALSE(details.target_destroyed);
249 EXPECT_FALSE(details.dispatcher_destroyed); 241 EXPECT_FALSE(details.dispatcher_destroyed);
250 EXPECT_EQ(1, controller.show_context_menu_calls()); 242 EXPECT_EQ(1, controller.show_context_menu_calls());
251 } 243 }
252 244
253 } // namespace test 245 } // namespace test
254 } // namespace views 246 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698