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

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

Issue 572593002: Revert of Clean up GestureEventDetails constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « ui/views/view_targeter_unittest.cc ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 long_press1( 204 ui::GestureEvent long_press1(
205 5, 205 5,
206 5, 206 5,
207 0, 207 0,
208 base::TimeDelta(), 208 base::TimeDelta(),
209 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 209 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0));
210 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1); 210 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1);
211 211
212 ui::GestureEvent end1( 212 ui::GestureEvent end1(5,
213 5, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 213 5,
214 0,
215 base::TimeDelta(),
216 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
214 details = root_view->OnEventFromSource(&end1); 217 details = root_view->OnEventFromSource(&end1);
215 218
216 EXPECT_FALSE(details.target_destroyed); 219 EXPECT_FALSE(details.target_destroyed);
217 EXPECT_FALSE(details.dispatcher_destroyed); 220 EXPECT_FALSE(details.dispatcher_destroyed);
218 EXPECT_EQ(0, controller.show_context_menu_calls()); 221 EXPECT_EQ(0, controller.show_context_menu_calls());
219 controller.Reset(); 222 controller.Reset();
220 223
221 // |parent_view| should show a context menu as a result of a long press on 224 // |parent_view| should show a context menu as a result of a long press on
222 // |other_child_view|. 225 // |other_child_view|.
223 ui::GestureEvent long_press2( 226 ui::GestureEvent long_press2(
224 25, 227 25,
225 5, 228 5,
226 0, 229 0,
227 base::TimeDelta(), 230 base::TimeDelta(),
228 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 231 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0));
229 details = root_view->OnEventFromSource(&long_press2); 232 details = root_view->OnEventFromSource(&long_press2);
230 233
231 ui::GestureEvent end2( 234 ui::GestureEvent end2(25,
232 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 235 5,
236 0,
237 base::TimeDelta(),
238 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
233 details = root_view->OnEventFromSource(&end2); 239 details = root_view->OnEventFromSource(&end2);
234 240
235 EXPECT_FALSE(details.target_destroyed); 241 EXPECT_FALSE(details.target_destroyed);
236 EXPECT_FALSE(details.dispatcher_destroyed); 242 EXPECT_FALSE(details.dispatcher_destroyed);
237 EXPECT_EQ(1, controller.show_context_menu_calls()); 243 EXPECT_EQ(1, controller.show_context_menu_calls());
238 controller.Reset(); 244 controller.Reset();
239 245
240 // |parent_view| should show a context menu as a result of a long press on 246 // |parent_view| should show a context menu as a result of a long press on
241 // itself. 247 // itself.
242 ui::GestureEvent long_press3( 248 ui::GestureEvent long_press3(
243 50, 249 50,
244 50, 250 50,
245 0, 251 0,
246 base::TimeDelta(), 252 base::TimeDelta(),
247 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 253 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0));
248 details = root_view->OnEventFromSource(&long_press3); 254 details = root_view->OnEventFromSource(&long_press3);
249 255
250 ui::GestureEvent end3( 256 ui::GestureEvent end3(25,
251 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 257 5,
258 0,
259 base::TimeDelta(),
260 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
252 details = root_view->OnEventFromSource(&end3); 261 details = root_view->OnEventFromSource(&end3);
253 262
254 EXPECT_FALSE(details.target_destroyed); 263 EXPECT_FALSE(details.target_destroyed);
255 EXPECT_FALSE(details.dispatcher_destroyed); 264 EXPECT_FALSE(details.dispatcher_destroyed);
256 EXPECT_EQ(1, controller.show_context_menu_calls()); 265 EXPECT_EQ(1, controller.show_context_menu_calls());
257 } 266 }
258 267
259 // Tests that context menus are not shown for disabled views on a long press. 268 // Tests that context menus are not shown for disabled views on a long press.
260 TEST_F(RootViewTest, ContextMenuFromLongPressOnDisabledView) { 269 TEST_F(RootViewTest, ContextMenuFromLongPressOnDisabledView) {
261 Widget widget; 270 Widget widget;
(...skipping 22 matching lines...) Expand all
284 other_child_view->SetBoundsRect(gfx::Rect(20, 0, 10, 10)); 293 other_child_view->SetBoundsRect(gfx::Rect(20, 0, 10, 10));
285 parent_view->AddChildView(other_child_view); 294 parent_view->AddChildView(other_child_view);
286 295
287 // |parent_view| should not show a context menu as a result of a long press on 296 // |parent_view| should not show a context menu as a result of a long press on
288 // |gesture_handling_child_view|. 297 // |gesture_handling_child_view|.
289 ui::GestureEvent long_press1( 298 ui::GestureEvent long_press1(
290 5, 299 5,
291 5, 300 5,
292 0, 301 0,
293 base::TimeDelta(), 302 base::TimeDelta(),
294 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 303 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0));
295 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1); 304 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1);
296 305
297 ui::GestureEvent end1( 306 ui::GestureEvent end1(5,
298 5, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 307 5,
308 0,
309 base::TimeDelta(),
310 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
299 details = root_view->OnEventFromSource(&end1); 311 details = root_view->OnEventFromSource(&end1);
300 312
301 EXPECT_FALSE(details.target_destroyed); 313 EXPECT_FALSE(details.target_destroyed);
302 EXPECT_FALSE(details.dispatcher_destroyed); 314 EXPECT_FALSE(details.dispatcher_destroyed);
303 EXPECT_EQ(0, controller.show_context_menu_calls()); 315 EXPECT_EQ(0, controller.show_context_menu_calls());
304 controller.Reset(); 316 controller.Reset();
305 317
306 // |parent_view| should not show a context menu as a result of a long press on 318 // |parent_view| should not show a context menu as a result of a long press on
307 // |other_child_view|. 319 // |other_child_view|.
308 ui::GestureEvent long_press2( 320 ui::GestureEvent long_press2(
309 25, 321 25,
310 5, 322 5,
311 0, 323 0,
312 base::TimeDelta(), 324 base::TimeDelta(),
313 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 325 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0));
314 details = root_view->OnEventFromSource(&long_press2); 326 details = root_view->OnEventFromSource(&long_press2);
315 327
316 ui::GestureEvent end2( 328 ui::GestureEvent end2(25,
317 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 329 5,
330 0,
331 base::TimeDelta(),
332 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
318 details = root_view->OnEventFromSource(&end2); 333 details = root_view->OnEventFromSource(&end2);
319 334
320 EXPECT_FALSE(details.target_destroyed); 335 EXPECT_FALSE(details.target_destroyed);
321 EXPECT_FALSE(details.dispatcher_destroyed); 336 EXPECT_FALSE(details.dispatcher_destroyed);
322 EXPECT_EQ(0, controller.show_context_menu_calls()); 337 EXPECT_EQ(0, controller.show_context_menu_calls());
323 controller.Reset(); 338 controller.Reset();
324 339
325 // |parent_view| should not show a context menu as a result of a long press on 340 // |parent_view| should not show a context menu as a result of a long press on
326 // itself. 341 // itself.
327 ui::GestureEvent long_press3( 342 ui::GestureEvent long_press3(
328 50, 343 50,
329 50, 344 50,
330 0, 345 0,
331 base::TimeDelta(), 346 base::TimeDelta(),
332 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 347 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0));
333 details = root_view->OnEventFromSource(&long_press3); 348 details = root_view->OnEventFromSource(&long_press3);
334 349
335 ui::GestureEvent end3( 350 ui::GestureEvent end3(25,
336 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 351 5,
352 0,
353 base::TimeDelta(),
354 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
337 details = root_view->OnEventFromSource(&end3); 355 details = root_view->OnEventFromSource(&end3);
338 356
339 EXPECT_FALSE(details.target_destroyed); 357 EXPECT_FALSE(details.target_destroyed);
340 EXPECT_FALSE(details.dispatcher_destroyed); 358 EXPECT_FALSE(details.dispatcher_destroyed);
341 EXPECT_EQ(0, controller.show_context_menu_calls()); 359 EXPECT_EQ(0, controller.show_context_menu_calls());
342 } 360 }
343 361
344 } // namespace test 362 } // namespace test
345 } // namespace views 363 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view_targeter_unittest.cc ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698