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

Side by Side Diff: ui/aura/window_event_dispatcher_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
« no previous file with comments | « ui/aura/gestures/gesture_recognizer_unittest.cc ('k') | ui/aura/window_unittest.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 (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 "ui/aura/window_event_dispatcher.h" 5 #include "ui/aura/window_event_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 root_window()->bounds().height() + 10); 401 root_window()->bounds().height() + 10);
402 ui::TouchEvent release( 402 ui::TouchEvent release(
403 ui::ET_TOUCH_RELEASED, position, 0, ui::EventTimeForNow()); 403 ui::ET_TOUCH_RELEASED, position, 0, ui::EventTimeForNow());
404 DispatchEventUsingWindowDispatcher(&release); 404 DispatchEventUsingWindowDispatcher(&release);
405 EXPECT_EQ(2, handler.num_touch_events()); 405 EXPECT_EQ(2, handler.num_touch_events());
406 root_window()->RemovePreTargetHandler(&handler); 406 root_window()->RemovePreTargetHandler(&handler);
407 } 407 }
408 408
409 // Tests that scroll events are dispatched correctly. 409 // Tests that scroll events are dispatched correctly.
410 TEST_F(WindowEventDispatcherTest, ScrollEventDispatch) { 410 TEST_F(WindowEventDispatcherTest, ScrollEventDispatch) {
411 base::TimeDelta now = ui::EventTimeForNow(); 411 base::TimeTicks now = ui::EventTimeForNow();
412 ui::test::TestEventHandler handler; 412 ui::test::TestEventHandler handler;
413 root_window()->AddPreTargetHandler(&handler); 413 root_window()->AddPreTargetHandler(&handler);
414 414
415 test::TestWindowDelegate delegate; 415 test::TestWindowDelegate delegate;
416 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate)); 416 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate));
417 w1->SetBounds(gfx::Rect(20, 20, 40, 40)); 417 w1->SetBounds(gfx::Rect(20, 20, 40, 40));
418 418
419 // A scroll event on the root-window itself is dispatched. 419 // A scroll event on the root-window itself is dispatched.
420 ui::ScrollEvent scroll1(ui::ET_SCROLL, 420 ui::ScrollEvent scroll1(ui::ET_SCROLL,
421 gfx::Point(10, 10), 421 gfx::Point(10, 10),
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 EventFilterRecorder w2_filter; 1645 EventFilterRecorder w2_filter;
1646 w2->AddPreTargetHandler(&w2_filter); 1646 w2->AddPreTargetHandler(&w2_filter);
1647 1647
1648 // Move mouse over window 2. This should generate a mouse-exited event for 1648 // Move mouse over window 2. This should generate a mouse-exited event for
1649 // window 1 resulting in deletion of window tree host and its event 1649 // window 1 resulting in deletion of window tree host and its event
1650 // dispatcher. The event dispatching should abort since the dispatcher is 1650 // dispatcher. The event dispatching should abort since the dispatcher is
1651 // destroyed. This test passes if no crash happens. 1651 // destroyed. This test passes if no crash happens.
1652 // Here we can't use EventGenerator since it expects that the dispatcher is 1652 // Here we can't use EventGenerator since it expects that the dispatcher is
1653 // not destroyed at the end of the dispatch. 1653 // not destroyed at the end of the dispatch.
1654 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::Point(20, 20), 1654 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::Point(20, 20),
1655 gfx::Point(20, 20), base::TimeDelta(), 0, 0); 1655 gfx::Point(20, 20), base::TimeTicks(), 0, 0);
1656 ui::EventDispatchDetails details = 1656 ui::EventDispatchDetails details =
1657 host->dispatcher()->DispatchEvent(w2, &mouse_move); 1657 host->dispatcher()->DispatchEvent(w2, &mouse_move);
1658 EXPECT_TRUE(details.dispatcher_destroyed); 1658 EXPECT_TRUE(details.dispatcher_destroyed);
1659 1659
1660 // Check events received by the two windows. 1660 // Check events received by the two windows.
1661 EXPECT_EQ("MOUSE_EXITED", EventTypesToString(w1_filter.events())); 1661 EXPECT_EQ("MOUSE_EXITED", EventTypesToString(w1_filter.events()));
1662 EXPECT_EQ(std::string(), EventTypesToString(w2_filter.events())); 1662 EXPECT_EQ(std::string(), EventTypesToString(w2_filter.events()));
1663 } 1663 }
1664 1664
1665 namespace { 1665 namespace {
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 // 2x. A ET_MOUSE_EXITED event should have been sent to |w|. 2663 // 2x. A ET_MOUSE_EXITED event should have been sent to |w|.
2664 test_screen()->SetDeviceScaleFactor(2.f); 2664 test_screen()->SetDeviceScaleFactor(2.f);
2665 dispatcher->OnCursorMovedToRootLocation(gfx::Point(11, 11)); 2665 dispatcher->OnCursorMovedToRootLocation(gfx::Point(11, 11));
2666 RunAllPendingInMessageLoop(); 2666 RunAllPendingInMessageLoop();
2667 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_MOUSE_EXITED)); 2667 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_MOUSE_EXITED));
2668 2668
2669 w->RemovePreTargetHandler(&recorder); 2669 w->RemovePreTargetHandler(&recorder);
2670 } 2670 }
2671 2671
2672 } // namespace aura 2672 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/gestures/gesture_recognizer_unittest.cc ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698