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

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

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 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 "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "ui/events/event_utils.h" 9 #include "ui/events/event_utils.h"
10 #include "ui/views/context_menu_controller.h" 10 #include "ui/views/context_menu_controller.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 long_press1( 204 ui::GestureEvent long_press1(
205 5, 205 5, 5, 0, base::TimeTicks(),
206 5,
207 0,
208 base::TimeDelta(),
209 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 206 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
210 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1); 207 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1);
211 208
212 ui::GestureEvent end1( 209 ui::GestureEvent end1(5, 5, 0, base::TimeTicks(),
213 5, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 210 ui::GestureEventDetails(ui::ET_GESTURE_END));
214 details = root_view->OnEventFromSource(&end1); 211 details = root_view->OnEventFromSource(&end1);
215 212
216 EXPECT_FALSE(details.target_destroyed); 213 EXPECT_FALSE(details.target_destroyed);
217 EXPECT_FALSE(details.dispatcher_destroyed); 214 EXPECT_FALSE(details.dispatcher_destroyed);
218 EXPECT_EQ(0, controller.show_context_menu_calls()); 215 EXPECT_EQ(0, controller.show_context_menu_calls());
219 controller.Reset(); 216 controller.Reset();
220 217
221 // |parent_view| should show a context menu as a result of a long press on 218 // |parent_view| should show a context menu as a result of a long press on
222 // |other_child_view|. 219 // |other_child_view|.
223 ui::GestureEvent long_press2( 220 ui::GestureEvent long_press2(
224 25, 221 25, 5, 0, base::TimeTicks(),
225 5,
226 0,
227 base::TimeDelta(),
228 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 222 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
229 details = root_view->OnEventFromSource(&long_press2); 223 details = root_view->OnEventFromSource(&long_press2);
230 224
231 ui::GestureEvent end2( 225 ui::GestureEvent end2(25, 5, 0, base::TimeTicks(),
232 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 226 ui::GestureEventDetails(ui::ET_GESTURE_END));
233 details = root_view->OnEventFromSource(&end2); 227 details = root_view->OnEventFromSource(&end2);
234 228
235 EXPECT_FALSE(details.target_destroyed); 229 EXPECT_FALSE(details.target_destroyed);
236 EXPECT_FALSE(details.dispatcher_destroyed); 230 EXPECT_FALSE(details.dispatcher_destroyed);
237 EXPECT_EQ(1, controller.show_context_menu_calls()); 231 EXPECT_EQ(1, controller.show_context_menu_calls());
238 controller.Reset(); 232 controller.Reset();
239 233
240 // |parent_view| should show a context menu as a result of a long press on 234 // |parent_view| should show a context menu as a result of a long press on
241 // itself. 235 // itself.
242 ui::GestureEvent long_press3( 236 ui::GestureEvent long_press3(
243 50, 237 50, 50, 0, base::TimeTicks(),
244 50,
245 0,
246 base::TimeDelta(),
247 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 238 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
248 details = root_view->OnEventFromSource(&long_press3); 239 details = root_view->OnEventFromSource(&long_press3);
249 240
250 ui::GestureEvent end3( 241 ui::GestureEvent end3(25, 5, 0, base::TimeTicks(),
251 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 242 ui::GestureEventDetails(ui::ET_GESTURE_END));
252 details = root_view->OnEventFromSource(&end3); 243 details = root_view->OnEventFromSource(&end3);
253 244
254 EXPECT_FALSE(details.target_destroyed); 245 EXPECT_FALSE(details.target_destroyed);
255 EXPECT_FALSE(details.dispatcher_destroyed); 246 EXPECT_FALSE(details.dispatcher_destroyed);
256 EXPECT_EQ(1, controller.show_context_menu_calls()); 247 EXPECT_EQ(1, controller.show_context_menu_calls());
257 } 248 }
258 249
259 // Tests that context menus are not shown for disabled views on a long press. 250 // Tests that context menus are not shown for disabled views on a long press.
260 TEST_F(RootViewTest, ContextMenuFromLongPressOnDisabledView) { 251 TEST_F(RootViewTest, ContextMenuFromLongPressOnDisabledView) {
261 Widget widget; 252 Widget widget;
(...skipping 18 matching lines...) Expand all
280 gesture_handling_child_view->SetBoundsRect(gfx::Rect(10, 10)); 271 gesture_handling_child_view->SetBoundsRect(gfx::Rect(10, 10));
281 parent_view->AddChildView(gesture_handling_child_view); 272 parent_view->AddChildView(gesture_handling_child_view);
282 273
283 View* other_child_view = new View; 274 View* other_child_view = new View;
284 other_child_view->SetBoundsRect(gfx::Rect(20, 0, 10, 10)); 275 other_child_view->SetBoundsRect(gfx::Rect(20, 0, 10, 10));
285 parent_view->AddChildView(other_child_view); 276 parent_view->AddChildView(other_child_view);
286 277
287 // |parent_view| should not show a context menu as a result of a long press on 278 // |parent_view| should not show a context menu as a result of a long press on
288 // |gesture_handling_child_view|. 279 // |gesture_handling_child_view|.
289 ui::GestureEvent long_press1( 280 ui::GestureEvent long_press1(
290 5, 281 5, 5, 0, base::TimeTicks(),
291 5,
292 0,
293 base::TimeDelta(),
294 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 282 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
295 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1); 283 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1);
296 284
297 ui::GestureEvent end1( 285 ui::GestureEvent end1(5, 5, 0, base::TimeTicks(),
298 5, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 286 ui::GestureEventDetails(ui::ET_GESTURE_END));
299 details = root_view->OnEventFromSource(&end1); 287 details = root_view->OnEventFromSource(&end1);
300 288
301 EXPECT_FALSE(details.target_destroyed); 289 EXPECT_FALSE(details.target_destroyed);
302 EXPECT_FALSE(details.dispatcher_destroyed); 290 EXPECT_FALSE(details.dispatcher_destroyed);
303 EXPECT_EQ(0, controller.show_context_menu_calls()); 291 EXPECT_EQ(0, controller.show_context_menu_calls());
304 controller.Reset(); 292 controller.Reset();
305 293
306 // |parent_view| should not show a context menu as a result of a long press on 294 // |parent_view| should not show a context menu as a result of a long press on
307 // |other_child_view|. 295 // |other_child_view|.
308 ui::GestureEvent long_press2( 296 ui::GestureEvent long_press2(
309 25, 297 25, 5, 0, base::TimeTicks(),
310 5,
311 0,
312 base::TimeDelta(),
313 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 298 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
314 details = root_view->OnEventFromSource(&long_press2); 299 details = root_view->OnEventFromSource(&long_press2);
315 300
316 ui::GestureEvent end2( 301 ui::GestureEvent end2(25, 5, 0, base::TimeTicks(),
317 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 302 ui::GestureEventDetails(ui::ET_GESTURE_END));
318 details = root_view->OnEventFromSource(&end2); 303 details = root_view->OnEventFromSource(&end2);
319 304
320 EXPECT_FALSE(details.target_destroyed); 305 EXPECT_FALSE(details.target_destroyed);
321 EXPECT_FALSE(details.dispatcher_destroyed); 306 EXPECT_FALSE(details.dispatcher_destroyed);
322 EXPECT_EQ(0, controller.show_context_menu_calls()); 307 EXPECT_EQ(0, controller.show_context_menu_calls());
323 controller.Reset(); 308 controller.Reset();
324 309
325 // |parent_view| should not show a context menu as a result of a long press on 310 // |parent_view| should not show a context menu as a result of a long press on
326 // itself. 311 // itself.
327 ui::GestureEvent long_press3( 312 ui::GestureEvent long_press3(
328 50, 313 50, 50, 0, base::TimeTicks(),
329 50,
330 0,
331 base::TimeDelta(),
332 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 314 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
333 details = root_view->OnEventFromSource(&long_press3); 315 details = root_view->OnEventFromSource(&long_press3);
334 316
335 ui::GestureEvent end3( 317 ui::GestureEvent end3(25, 5, 0, base::TimeTicks(),
336 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 318 ui::GestureEventDetails(ui::ET_GESTURE_END));
337 details = root_view->OnEventFromSource(&end3); 319 details = root_view->OnEventFromSource(&end3);
338 320
339 EXPECT_FALSE(details.target_destroyed); 321 EXPECT_FALSE(details.target_destroyed);
340 EXPECT_FALSE(details.dispatcher_destroyed); 322 EXPECT_FALSE(details.dispatcher_destroyed);
341 EXPECT_EQ(0, controller.show_context_menu_calls()); 323 EXPECT_EQ(0, controller.show_context_menu_calls());
342 } 324 }
343 325
344 namespace { 326 namespace {
345 327
346 // View class which destroys itself when it gets an event of type 328 // View class which destroys itself when it gets an event of type
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 // mouse exit event to |subchild| and destroy the widget. This should not 533 // mouse exit event to |subchild| and destroy the widget. This should not
552 // crash when the mouse exit handler returns from |subchild|. 534 // crash when the mouse exit handler returns from |subchild|.
553 ui::MouseEvent move_event2(ui::ET_MOUSE_MOVED, gfx::Point(15, 15), 535 ui::MouseEvent move_event2(ui::ET_MOUSE_MOVED, gfx::Point(15, 15),
554 gfx::Point(15, 15), ui::EventTimeForNow(), 0, 0); 536 gfx::Point(15, 15), ui::EventTimeForNow(), 0, 0);
555 root_view->OnMouseMoved(move_event2); 537 root_view->OnMouseMoved(move_event2);
556 EXPECT_FALSE(widget_deletion_observer.IsWidgetAlive()); 538 EXPECT_FALSE(widget_deletion_observer.IsWidgetAlive());
557 } 539 }
558 540
559 } // namespace test 541 } // namespace test
560 } // namespace views 542 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/x11_move_loop_delegate.h ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698