From b3d800b765279e004158f880b097817c81576d84 Mon Sep 17 00:00:00 2001 From: "robert.bradford" Date: Wed, 18 Feb 2015 10:56:10 -0800 Subject: [PATCH] Add time_stamp parameter to MouseEvent constructor In order to allow the use of accurate kernel timestamps in the events from Ozone it is necessary to add a parameter to the constructor for MouseEvent. This CL was partially generated from using a clang tool with some manual changes for files not included in my build and to add header files as necessary. This change fills in all users of the newly added time_stamp parameter with a call into ui::EventTimeForNow() which was the original behaviour used by the constructor. BUG=450341 TEST=Build on all try bots and all unit tests pass. Review URL: https://codereview.chromium.org/934653002 Cr-Commit-Position: refs/heads/master@{#316869} --- ash/autoclick/autoclick_controller.cc | 11 +- ash/autoclick/autoclick_unittest.cc | 11 +- .../mouse_cursor_event_filter_unittest.cc | 9 +- .../drag_drop_controller_unittest.cc | 26 +-- ash/drag_drop/drag_drop_tracker.cc | 11 +- ash/drag_drop/drag_drop_tracker_unittest.cc | 40 ++-- ash/shelf/shelf_tooltip_manager_unittest.cc | 9 +- ash/shelf/shelf_view.cc | 7 +- ash/shelf/shelf_view_unittest.cc | 53 +++-- ash/shelf/shelf_widget_unittest.cc | 4 +- ash/sticky_keys/sticky_keys_unittest.cc | 9 +- .../screen_tray_item_unittest.cc | 9 +- ...mmersive_fullscreen_controller_unittest.cc | 4 +- ash/wm/overview/window_selector_unittest.cc | 5 +- ash/wm/window_manager_unittest.cc | 53 ++--- .../multi_window_resize_controller.cc | 4 +- .../workspace_event_handler_unittest.cc | 5 +- ash/wm/workspace_controller_unittest.cc | 12 +- .../events/event_rewriter_unittest.cc | 61 ++---- .../shaped_app_window_targeter_unittest.cc | 73 +++---- .../autofill_popup_base_view_browsertest.cc | 6 +- ...word_generation_popup_view_tester_views.cc | 7 +- .../desktop_media_picker_views_unittest.cc | 6 +- .../bookmark_override_browsertest.cc | 13 +- .../link_disambiguation_popup.cc | 3 +- .../location_bar/star_view_browsertest.cc | 13 +- .../omnibox/omnibox_view_views_browsertest.cc | 5 +- .../manage_passwords_icon_view_browsertest.cc | 5 +- .../profile_chooser_view_browsertest.cc | 7 +- .../one_click_signin_bubble_view_unittest.cc | 16 +- .../views/toolbar/reload_button_unittest.cc | 19 +- .../input/synthetic_gesture_target_aura.cc | 8 +- .../render_widget_host_view_aura_unittest.cc | 6 +- .../aura/window_slider_unittest.cc | 17 +- .../views/app_list_main_view_unittest.cc | 23 +-- ui/app_list/views/app_list_view_unittest.cc | 17 +- ui/app_list/views/apps_grid_view_unittest.cc | 16 +- ui/app_list/views/speech_view_unittest.cc | 31 +-- ui/aura/remote_window_tree_host_win.cc | 9 +- ui/aura/test/ui_controls_factory_ozone.cc | 4 +- ui/aura/window_event_dispatcher.cc | 15 +- ui/aura/window_event_dispatcher_unittest.cc | 195 +++++++++--------- ui/aura/window_targeter_unittest.cc | 19 +- ui/aura/window_unittest.cc | 4 +- .../user_activity_detector_unittest.cc | 11 +- ui/chromeos/touch_exploration_controller.cc | 4 +- .../touch_exploration_controller_unittest.cc | 6 +- ui/events/event.cc | 12 +- ui/events/event.h | 3 +- ui/events/event_dispatcher_unittest.cc | 28 +-- ui/events/event_processor_unittest.cc | 37 ++-- ui/events/event_unittest.cc | 43 ++-- ui/events/ozone/evdev/event_factory_evdev.cc | 5 +- ui/events/test/event_generator.cc | 19 +- ui/keyboard/keyboard_controller_unittest.cc | 13 +- .../message_popup_collection_unittest.cc | 7 +- .../views/notification_view_unittest.cc | 29 +-- .../views/notifier_settings_view.cc | 7 +- ui/views/accessibility/ax_view_obj_wrapper.cc | 7 +- .../bubble/bubble_window_targeter_unittest.cc | 10 +- ui/views/controls/button/custom_button.cc | 22 +- .../controls/button/custom_button_unittest.cc | 13 +- ui/views/controls/button/radio_button.cc | 4 +- .../controls/combobox/combobox_unittest.cc | 15 +- ui/views/controls/menu/menu_controller.cc | 23 +-- .../native/native_view_host_aura_unittest.cc | 3 +- .../scrollbar/base_scroll_bar_button.cc | 6 +- .../controls/single_split_view_unittest.cc | 25 +-- .../controls/table/table_view_unittest.cc | 16 +- .../controls/textfield/textfield_unittest.cc | 83 +++++--- ui/views/controls/webview/webview_unittest.cc | 19 +- ...ouch_selection_controller_impl_unittest.cc | 7 +- ui/views/view_unittest.cc | 40 ++-- ui/views/widget/root_view.cc | 8 +- ui/views/widget/widget.cc | 6 +- ui/views/widget/widget_interactive_uitest.cc | 49 ++--- ui/views/widget/widget_unittest.cc | 45 ++-- ui/wm/core/capture_controller_unittest.cc | 3 +- ui/wm/core/compound_event_filter_unittest.cc | 14 +- 79 files changed, 770 insertions(+), 752 deletions(-) diff --git a/ash/autoclick/autoclick_controller.cc b/ash/autoclick/autoclick_controller.cc index fff3cde2cef71c..39d1b020d6db22 100644 --- a/ash/autoclick/autoclick_controller.cc +++ b/ash/autoclick/autoclick_controller.cc @@ -13,6 +13,7 @@ #include "ui/events/event_constants.h" #include "ui/events/event_handler.h" #include "ui/events/event_processor.h" +#include "ui/events/event_utils.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/vector2d.h" #include "ui/wm/core/coordinate_conversion.h" @@ -190,14 +191,12 @@ void AutoclickControllerImpl::DoAutoclick() { aura::WindowTreeHost* host = root_window->GetHost(); host->ConvertPointToHost(&click_location); - ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, - click_location, - click_location, + ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, click_location, + click_location, ui::EventTimeForNow(), mouse_event_flags_ | ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); - ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, - click_location, - click_location, + ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, click_location, + click_location, ui::EventTimeForNow(), mouse_event_flags_ | ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); diff --git a/ash/autoclick/autoclick_unittest.cc b/ash/autoclick/autoclick_unittest.cc index 8768c0c953e014..ff66e04fc1518a 100644 --- a/ash/autoclick/autoclick_unittest.cc +++ b/ash/autoclick/autoclick_unittest.cc @@ -11,6 +11,7 @@ #include "ui/events/event.h" #include "ui/events/event_constants.h" #include "ui/events/event_handler.h" +#include "ui/events/event_utils.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/test/event_generator.h" @@ -33,12 +34,10 @@ class MouseEventCapturer : public ui::EventHandler { ui::EventType type = event->type(); if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_PRESSED || type == ui::ET_MOUSE_RELEASED) { - events_.push_back(ui::MouseEvent( - event->type(), - event->location(), - event->root_location(), - event->flags(), - event->changed_button_flags())); + events_.push_back(ui::MouseEvent(event->type(), event->location(), + event->root_location(), + ui::EventTimeForNow(), event->flags(), + event->changed_button_flags())); // Stop event propagation so we don't click on random stuff that // might break test assumptions. event->StopPropagation(); diff --git a/ash/display/mouse_cursor_event_filter_unittest.cc b/ash/display/mouse_cursor_event_filter_unittest.cc index 3b4f9ee83a4247..ef302fc91279e3 100644 --- a/ash/display/mouse_cursor_event_filter_unittest.cc +++ b/ash/display/mouse_cursor_event_filter_unittest.cc @@ -11,6 +11,7 @@ #include "ash/display/display_manager.h" #include "ui/aura/env.h" #include "ui/aura/window_event_dispatcher.h" +#include "ui/events/event_utils.h" #include "ui/gfx/display.h" #include "ui/gfx/screen.h" @@ -39,16 +40,16 @@ class MouseCursorEventFilterTest : public test::AshTestBase { aura::Window* target_root, gfx::Point point_in_screen) { gfx::Point location = drag_source_root->bounds().CenterPoint(); - ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, location, - location, 0, 0); + ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, location, location, + ui::EventTimeForNow(), 0, 0); ui::Event::DispatcherApi(&pressed).set_target(drag_source_root); event_filter()->OnMouseEvent(&pressed); bool is_warped = event_filter()->WarpMouseCursorIfNecessaryForTest( target_root, point_in_screen); event_filter()->reset_was_mouse_warped_for_test(); - ui::MouseEvent released(ui::ET_MOUSE_RELEASED, location, - location, 0, 0); + ui::MouseEvent released(ui::ET_MOUSE_RELEASED, location, location, + ui::EventTimeForNow(), 0, 0); ui::Event::DispatcherApi(&released).set_target(drag_source_root); event_filter()->OnMouseEvent(&released); return is_warped; diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc index 537b4527352dcb..6ee3a59a76ccd5 100644 --- a/ash/drag_drop/drag_drop_controller_unittest.cc +++ b/ash/drag_drop/drag_drop_controller_unittest.cc @@ -722,7 +722,7 @@ TEST_F(DragDropControllerTest, SyntheticEventsDuringDragDrop) { // The DragDropController should simply ignore these events. gfx::Point mouse_move_location = drag_view->bounds().CenterPoint(); ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, mouse_move_location, - mouse_move_location, 0, 0); + mouse_move_location, ui::EventTimeForNow(), 0, 0); ui::EventDispatchDetails details = Shell::GetPrimaryRootWindow()-> GetHost()->event_processor()->OnEventFromSource(&mouse_move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -1006,18 +1006,14 @@ TEST_F(DragDropControllerTest, DragCancelAcrossDisplays) { GetDragImageWindow()->AddObserver(&observer); { - ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, - gfx::Point(200, 0), - gfx::Point(200, 0), - ui::EF_NONE, + ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), + gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); drag_drop_controller_->DragUpdate(window, e); } { - ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, - gfx::Point(600, 0), - gfx::Point(600, 0), - ui::EF_NONE, + ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), + gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); drag_drop_controller_->DragUpdate(window, e); } @@ -1043,18 +1039,14 @@ TEST_F(DragDropControllerTest, DragCancelAcrossDisplays) { GetDragImageWindow()->AddObserver(&observer); { - ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, - gfx::Point(600, 0), - gfx::Point(600, 0), - ui::EF_NONE, + ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), + gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); drag_drop_controller_->DragUpdate(window, e); } { - ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, - gfx::Point(200, 0), - gfx::Point(200, 0), - ui::EF_NONE, + ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), + gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); drag_drop_controller_->DragUpdate(window, e); } diff --git a/ash/drag_drop/drag_drop_tracker.cc b/ash/drag_drop/drag_drop_tracker.cc index d851098c36c020..497151437281f0 100644 --- a/ash/drag_drop/drag_drop_tracker.cc +++ b/ash/drag_drop/drag_drop_tracker.cc @@ -11,6 +11,7 @@ #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/events/event.h" +#include "ui/events/event_utils.h" #include "ui/gfx/screen.h" #include "ui/wm/core/coordinate_conversion.h" #include "ui/wm/public/activation_delegate.h" @@ -91,12 +92,10 @@ ui::LocatedEvent* DragDropTracker::ConvertEvent( capture_window_->GetRootWindow(), ash::wm::GetRootWindowAt(location_in_screen), &target_root_location); - return new ui::MouseEvent(event.type(), - target_location, - target_root_location, - event.flags(), - static_cast(event). - changed_button_flags()); + return new ui::MouseEvent( + event.type(), target_location, target_root_location, + ui::EventTimeForNow(), event.flags(), + static_cast(event).changed_button_flags()); } } // namespace ash diff --git a/ash/drag_drop/drag_drop_tracker_unittest.cc b/ash/drag_drop/drag_drop_tracker_unittest.cc index 0e6d7f2a2ccf33..0e4bfa1ec42199 100644 --- a/ash/drag_drop/drag_drop_tracker_unittest.cc +++ b/ash/drag_drop/drag_drop_tracker_unittest.cc @@ -11,6 +11,7 @@ #include "ui/aura/test/test_windows.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" +#include "ui/events/event_utils.h" namespace ash { namespace test { @@ -30,11 +31,8 @@ class DragDropTrackerTest : public test::AshTestBase { static aura::Window* GetTarget(const gfx::Point& location) { scoped_ptr tracker( new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); - ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, - location, - location, - ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, location, location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); aura::Window* target = tracker->GetTarget(e); return target; } @@ -132,11 +130,9 @@ TEST_F(DragDropTrackerTest, ConvertEvent) { // Start tracking from the RootWindow0 and converts the mouse event into // |window0|'s coodinates. - ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, - gfx::Point(50, 50), - gfx::Point(50, 50), - ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, gfx::Point(50, 50), + gfx::Point(50, 50), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); scoped_ptr converted00(ConvertEvent(window0.get(), original00)); EXPECT_EQ(original00.type(), converted00->type()); @@ -146,11 +142,9 @@ TEST_F(DragDropTrackerTest, ConvertEvent) { // Start tracking from the RootWindow0 and converts the mouse event into // |window1|'s coodinates. - ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, - gfx::Point(350, 150), - gfx::Point(350, 150), - ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, gfx::Point(350, 150), + gfx::Point(350, 150), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); scoped_ptr converted01(ConvertEvent(window1.get(), original01)); EXPECT_EQ(original01.type(), converted01->type()); @@ -163,11 +157,9 @@ TEST_F(DragDropTrackerTest, ConvertEvent) { // Start tracking from the RootWindow1 and converts the mouse event into // |window0|'s coodinates. - ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, - gfx::Point(-150, 50), - gfx::Point(-150, 50), - ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, gfx::Point(-150, 50), + gfx::Point(-150, 50), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); scoped_ptr converted10(ConvertEvent(window0.get(), original10)); EXPECT_EQ(original10.type(), converted10->type()); @@ -177,11 +169,9 @@ TEST_F(DragDropTrackerTest, ConvertEvent) { // Start tracking from the RootWindow1 and converts the mouse event into // |window1|'s coodinates. - ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, - gfx::Point(150, 150), - gfx::Point(150, 150), - ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, gfx::Point(150, 150), + gfx::Point(150, 150), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); scoped_ptr converted11(ConvertEvent(window1.get(), original11)); EXPECT_EQ(original11.type(), converted11->type()); diff --git a/ash/shelf/shelf_tooltip_manager_unittest.cc b/ash/shelf/shelf_tooltip_manager_unittest.cc index d13d290752355e..6ebb063ec48221 100644 --- a/ash/shelf/shelf_tooltip_manager_unittest.cc +++ b/ash/shelf/shelf_tooltip_manager_unittest.cc @@ -18,6 +18,7 @@ #include "ui/events/event.h" #include "ui/events/event_constants.h" #include "ui/events/event_handler.h" +#include "ui/events/event_utils.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/test/events_test_utils.h" #include "ui/views/widget/widget.h" @@ -231,8 +232,8 @@ TEST_F(ShelfTooltipManagerTest, HideForMouseMoveEvent) { // Shouldn't hide if the mouse is in the tooltip. ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, tooltip_rect.CenterPoint(), - tooltip_rect.CenterPoint(), ui::EF_NONE, - ui::EF_NONE); + tooltip_rect.CenterPoint(), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); ui::LocatedEventTestApi test_api(&mouse_event); SetEventTarget(root_window, &mouse_event); @@ -261,8 +262,8 @@ TEST_F(ShelfTooltipManagerTest, HideForMouseClickEvent) { // Should hide if the mouse is pressed in the tooltip. ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, tooltip_rect.CenterPoint(), - tooltip_rect.CenterPoint(), ui::EF_NONE, - ui::EF_NONE); + tooltip_rect.CenterPoint(), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); SetEventTarget(root_window, &mouse_event); event_handler->OnMouseEvent(&mouse_event); diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc index c9cee3dff028ad..40eafe58518ae4 100644 --- a/ash/shelf/shelf_view.cc +++ b/ash/shelf/shelf_view.cc @@ -43,6 +43,7 @@ #include "ui/compositor/layer.h" #include "ui/compositor/layer_animator.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h" +#include "ui/events/event_utils.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/point.h" #include "ui/views/animation/bounds_animator.h" @@ -621,7 +622,8 @@ bool ShelfView::StartDrag(const std::string& app_id, gfx::Point point_in_root = location_in_screen_coordinates; ::wm::ConvertPointFromScreen( ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); - ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, 0, 0); + ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, + ui::EventTimeForNow(), 0, 0); PointerPressedOnButton(drag_and_drop_view, ShelfButtonHost::DRAG_AND_DROP, event); @@ -643,7 +645,8 @@ bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { gfx::Point point_in_root = location_in_screen_coordinates; ::wm::ConvertPointFromScreen( ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); - ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, 0, 0); + ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, + ui::EventTimeForNow(), 0, 0); PointerDraggedOnButton(drag_and_drop_view, ShelfButtonHost::DRAG_AND_DROP, event); diff --git a/ash/shelf/shelf_view_unittest.cc b/ash/shelf/shelf_view_unittest.cc index c09acb445dd850..d18d12717776b0 100644 --- a/ash/shelf/shelf_view_unittest.cc +++ b/ash/shelf/shelf_view_unittest.cc @@ -40,6 +40,7 @@ #include "ui/compositor/layer.h" #include "ui/events/event.h" #include "ui/events/event_constants.h" +#include "ui/events/event_utils.h" #include "ui/events/test/event_generator.h" #include "ui/views/view_model.h" #include "ui/views/widget/widget.h" @@ -422,9 +423,9 @@ class ShelfViewTest : public AshTestBase { int button_index) { ShelfButtonHost* button_host = shelf_view_; ShelfButton* button = test_api_->GetButton(button_index); - ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, - gfx::Point(), - button->GetBoundsInScreen().origin(), 0, 0); + ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, gfx::Point(), + button->GetBoundsInScreen().origin(), + ui::EventTimeForNow(), 0, 0); button_host->PointerPressedOnButton(button, pointer, click_event); return button; } @@ -434,11 +435,9 @@ class ShelfViewTest : public AshTestBase { ShelfButtonHost* button_host = shelf_view_; ShelfButton* button = SimulateButtonPressed(ShelfButtonHost::MOUSE, button_index); - ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, - gfx::Point(), + ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, gfx::Point(), button->GetBoundsInScreen().origin(), - 0, - 0); + ui::EventTimeForNow(), 0, 0); test_api_->ButtonPressed(button, release_event); button_host->PointerReleasedOnButton(button, ShelfButtonHost::MOUSE, false); } @@ -448,10 +447,9 @@ class ShelfViewTest : public AshTestBase { ShelfButtonHost* button_host = shelf_view_; ShelfButton* button = SimulateButtonPressed(ShelfButtonHost::MOUSE, button_index); - ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, - gfx::Point(), + ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, gfx::Point(), button->GetBoundsInScreen().origin(), - ui::EF_IS_DOUBLE_CLICK, + ui::EventTimeForNow(), ui::EF_IS_DOUBLE_CLICK, 0); test_api_->ButtonPressed(button, release_event); button_host->PointerReleasedOnButton(button, ShelfButtonHost::MOUSE, false); @@ -465,10 +463,10 @@ class ShelfViewTest : public AshTestBase { // Drag. views::View* destination = test_api_->GetButton(destination_index); - ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, - gfx::Point(destination->x() - button->x(), + ui::MouseEvent drag_event( + ui::ET_MOUSE_DRAGGED, gfx::Point(destination->x() - button->x(), destination->y() - button->y()), - destination->GetBoundsInScreen().origin(), 0, 0); + destination->GetBoundsInScreen().origin(), ui::EventTimeForNow(), 0, 0); button_host->PointerDraggedOnButton(button, pointer, drag_event); return button; } @@ -1111,28 +1109,27 @@ TEST_F(ShelfViewTest, ClickAndMoveSlightly) { gfx::Point press_location_in_screen = button->GetBoundsInScreen().origin() + press_offset; - ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, - press_location, - press_location_in_screen, + ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, press_location, + press_location_in_screen, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); button->OnMousePressed(click_event); - ui::MouseEvent drag_event1(ui::ET_MOUSE_DRAGGED, - press_location + gfx::Vector2d(0, 1), - press_location_in_screen + gfx::Vector2d(0, 1), - ui::EF_LEFT_MOUSE_BUTTON, 0); + ui::MouseEvent drag_event1( + ui::ET_MOUSE_DRAGGED, press_location + gfx::Vector2d(0, 1), + press_location_in_screen + gfx::Vector2d(0, 1), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, 0); button->OnMouseDragged(drag_event1); - ui::MouseEvent drag_event2(ui::ET_MOUSE_DRAGGED, - press_location + gfx::Vector2d(-1, 0), - press_location_in_screen + gfx::Vector2d(-1, 0), - ui::EF_LEFT_MOUSE_BUTTON, 0); + ui::MouseEvent drag_event2( + ui::ET_MOUSE_DRAGGED, press_location + gfx::Vector2d(-1, 0), + press_location_in_screen + gfx::Vector2d(-1, 0), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, 0); button->OnMouseDragged(drag_event2); - ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, - press_location + gfx::Vector2d(-1, 0), - press_location_in_screen + gfx::Vector2d(-1, 0), - ui::EF_LEFT_MOUSE_BUTTON, 0); + ui::MouseEvent release_event( + ui::ET_MOUSE_RELEASED, press_location + gfx::Vector2d(-1, 0), + press_location_in_screen + gfx::Vector2d(-1, 0), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, 0); button->OnMouseReleased(release_event); EXPECT_TRUE(selection_tracker->WasSelected()); diff --git a/ash/shelf/shelf_widget_unittest.cc b/ash/shelf/shelf_widget_unittest.cc index 770bd7e2cbe969..bbd6b4c1e32e43 100644 --- a/ash/shelf/shelf_widget_unittest.cc +++ b/ash/shelf/shelf_widget_unittest.cc @@ -209,7 +209,7 @@ TEST_F(ShelfWidgetTest, ShelfEdgeOverlappingWindowHitTestMouse) { // shelf). gfx::Point event_location(20, shelf_bounds.y() + 1); ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); EXPECT_EQ(widget->GetNativeWindow(), target); } @@ -232,7 +232,7 @@ TEST_F(ShelfWidgetTest, ShelfEdgeOverlappingWindowHitTestMouse) { // window-target should find the shelf as the target. gfx::Point event_location(20, shelf_bounds.y() + 1); ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); EXPECT_EQ(shelf_widget->GetNativeWindow(), target); } diff --git a/ash/sticky_keys/sticky_keys_unittest.cc b/ash/sticky_keys/sticky_keys_unittest.cc index 16bdd20da3c8da..e00c9dc1a8d30e 100644 --- a/ash/sticky_keys/sticky_keys_unittest.cc +++ b/ash/sticky_keys/sticky_keys_unittest.cc @@ -17,6 +17,7 @@ #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" #include "ui/events/event_source.h" +#include "ui/events/event_utils.h" #include "ui/events/test/events_test_utils_x11.h" namespace ash { @@ -126,11 +127,9 @@ class StickyKeysTest : public test::AshTestBase { // Creates a synthesized MouseEvent that is not backed by a native event. ui::MouseEvent* GenerateSynthesizedMouseEventAt(ui::EventType event_type, const gfx::Point& location) { - ui::MouseEvent* event = new ui::MouseEvent(event_type, - location, - location, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent* event = new ui::MouseEvent( + event_type, location, location, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); ui::Event::DispatcherApi dispatcher(event); dispatcher.set_target(target_); return event; diff --git a/ash/system/chromeos/screen_security/screen_tray_item_unittest.cc b/ash/system/chromeos/screen_security/screen_tray_item_unittest.cc index 9c68d0b851466b..63d63470fe803c 100644 --- a/ash/system/chromeos/screen_security/screen_tray_item_unittest.cc +++ b/ash/system/chromeos/screen_security/screen_tray_item_unittest.cc @@ -12,6 +12,7 @@ #include "base/callback.h" #include "base/strings/utf_string_conversions.h" #include "ui/events/event.h" +#include "ui/events/event_utils.h" #include "ui/gfx/geometry/point.h" #include "ui/message_center/message_center.h" #include "ui/views/view.h" @@ -35,11 +36,9 @@ SystemTrayNotifier* GetSystemTrayNotifier() { void ClickViewCenter(views::View* view) { gfx::Point click_location_in_local = gfx::Point(view->width() / 2, view->height() / 2); - view->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, - click_location_in_local, - click_location_in_local, - ui::EF_NONE, - ui::EF_NONE)); + view->OnMousePressed(ui::MouseEvent( + ui::ET_MOUSE_PRESSED, click_location_in_local, click_location_in_local, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE)); } class ScreenTrayItemTest : public ash::test::AshTestBase { diff --git a/ash/wm/immersive_fullscreen_controller_unittest.cc b/ash/wm/immersive_fullscreen_controller_unittest.cc index 7195429f4c4c2f..3cae3173902bbb 100644 --- a/ash/wm/immersive_fullscreen_controller_unittest.cc +++ b/ash/wm/immersive_fullscreen_controller_unittest.cc @@ -356,8 +356,8 @@ TEST_F(ImmersiveFullscreenControllerTest, OnMouseEvent) { top_container_bounds_in_screen.y()); // Mouse wheel event does nothing. - ui::MouseEvent wheel( - ui::ET_MOUSEWHEEL, top_edge_pos, top_edge_pos, ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent wheel(ui::ET_MOUSEWHEEL, top_edge_pos, top_edge_pos, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); event_generator.Dispatch(&wheel); EXPECT_FALSE(top_edge_hover_timer_running()); diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc index a663b5c5203c8d..1c83f25627d503 100644 --- a/ash/wm/overview/window_selector_unittest.cc +++ b/ash/wm/overview/window_selector_unittest.cc @@ -45,6 +45,7 @@ #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h" +#include "ui/events/event_utils.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/geometry/point_conversions.h" #include "ui/gfx/geometry/rect_conversions.h" @@ -434,7 +435,7 @@ TEST_F(WindowSelectorTest, WindowDoesNotReceiveEvents) { gfx::Point point1(window_bounds.x() + 10, window_bounds.y() + 10); ui::MouseEvent event1(ui::ET_MOUSE_PRESSED, point1, point1, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); ui::EventTarget* root_target = root_window; ui::EventTargeter* targeter = root_target->GetEventTargeter(); @@ -450,7 +451,7 @@ TEST_F(WindowSelectorTest, WindowDoesNotReceiveEvents) { gfx::RectF bounds = GetTransformedBoundsInRootWindow(window.get()); gfx::Point point2(bounds.x() + 10, bounds.y() + 10); ui::MouseEvent event2(ui::ET_MOUSE_PRESSED, point2, point2, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); // Now the transparent window should be intercepting this event. EXPECT_NE(window, static_cast( diff --git a/ash/wm/window_manager_unittest.cc b/ash/wm/window_manager_unittest.cc index 61aaaf22611fd7..2d777c773a3a70 100644 --- a/ash/wm/window_manager_unittest.cc +++ b/ash/wm/window_manager_unittest.cc @@ -513,7 +513,8 @@ TEST_F(WindowManagerTest, MouseEventCursors) { { // Resize edges and corners show proper cursors. window_delegate.set_hittest_code(HTBOTTOM); - ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); + ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, + ui::EventTimeForNow(), 0, 0); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(ui::kCursorSouthResize, host->last_cursor().native_type()); @@ -521,7 +522,8 @@ TEST_F(WindowManagerTest, MouseEventCursors) { { window_delegate.set_hittest_code(HTBOTTOMLEFT); - ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); + ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, + ui::EventTimeForNow(), 0, 0); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(ui::kCursorSouthWestResize, host->last_cursor().native_type()); @@ -529,7 +531,8 @@ TEST_F(WindowManagerTest, MouseEventCursors) { { window_delegate.set_hittest_code(HTBOTTOMRIGHT); - ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); + ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, + ui::EventTimeForNow(), 0, 0); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(ui::kCursorSouthEastResize, host->last_cursor().native_type()); @@ -537,7 +540,8 @@ TEST_F(WindowManagerTest, MouseEventCursors) { { window_delegate.set_hittest_code(HTLEFT); - ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); + ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, + ui::EventTimeForNow(), 0, 0); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(ui::kCursorWestResize, host->last_cursor().native_type()); @@ -545,7 +549,8 @@ TEST_F(WindowManagerTest, MouseEventCursors) { { window_delegate.set_hittest_code(HTRIGHT); - ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); + ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, + ui::EventTimeForNow(), 0, 0); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(ui::kCursorEastResize, host->last_cursor().native_type()); @@ -553,7 +558,8 @@ TEST_F(WindowManagerTest, MouseEventCursors) { { window_delegate.set_hittest_code(HTTOP); - ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); + ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, + ui::EventTimeForNow(), 0, 0); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(ui::kCursorNorthResize, host->last_cursor().native_type()); @@ -561,7 +567,8 @@ TEST_F(WindowManagerTest, MouseEventCursors) { { window_delegate.set_hittest_code(HTTOPLEFT); - ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); + ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, + ui::EventTimeForNow(), 0, 0); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(ui::kCursorNorthWestResize, host->last_cursor().native_type()); @@ -569,7 +576,8 @@ TEST_F(WindowManagerTest, MouseEventCursors) { { window_delegate.set_hittest_code(HTTOPRIGHT); - ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0, 0); + ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, + ui::EventTimeForNow(), 0, 0); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move2); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(ui::kCursorNorthEastResize, host->last_cursor().native_type()); @@ -578,7 +586,8 @@ TEST_F(WindowManagerTest, MouseEventCursors) { { // Client area uses null cursor. window_delegate.set_hittest_code(HTCLIENT); - ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0, 0); + ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, + ui::EventTimeForNow(), 0, 0); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move1); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(ui::kCursorNull, host->last_cursor().native_type()); @@ -612,29 +621,23 @@ TEST_F(WindowManagerTest, MAYBE_TransformActivate) { gfx::Point miss_point(5, 5); transform.TransformPoint(&miss_point); - ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, - miss_point, - miss_point, - ui::EF_LEFT_MOUSE_BUTTON, + ui::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, miss_point, miss_point, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&mouseev1); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); - ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, - miss_point, - miss_point, - ui::EF_LEFT_MOUSE_BUTTON, + ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, miss_point, miss_point, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); details = dispatcher->OnEventFromSource(&mouseup); ASSERT_FALSE(details.dispatcher_destroyed); gfx::Point hit_point(5, 15); transform.TransformPoint(&hit_point); - ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, - hit_point, - hit_point, - ui::EF_LEFT_MOUSE_BUTTON, + ui::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, hit_point, hit_point, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); details = dispatcher->OnEventFromSource(&mouseev2); ASSERT_FALSE(details.dispatcher_destroyed); @@ -672,8 +675,8 @@ TEST_F(WindowManagerTest, AdditionalFilters) { ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor(); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event); ASSERT_FALSE(details.dispatcher_destroyed); - ui::MouseEvent mouse_pressed( - ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); + ui::MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), + gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); details = dispatcher->OnEventFromSource(&mouse_pressed); ASSERT_FALSE(details.dispatcher_destroyed); @@ -693,8 +696,8 @@ TEST_F(WindowManagerTest, AdditionalFilters) { // Dispatches events. details = dispatcher->OnEventFromSource(&key_event); ASSERT_FALSE(details.dispatcher_destroyed); - ui::MouseEvent mouse_released( - ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); + ui::MouseEvent mouse_released(ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), + gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); details = dispatcher->OnEventFromSource(&mouse_released); ASSERT_FALSE(details.dispatcher_destroyed); diff --git a/ash/wm/workspace/multi_window_resize_controller.cc b/ash/wm/workspace/multi_window_resize_controller.cc index 1b8b2cf711c12d..067275b59bc64e 100644 --- a/ash/wm/workspace/multi_window_resize_controller.cc +++ b/ash/wm/workspace/multi_window_resize_controller.cc @@ -18,6 +18,7 @@ #include "ui/base/hit_test.h" #include "ui/base/resource/resource_bundle.h" #include "ui/events/event_targeter.h" +#include "ui/events/event_utils.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image.h" #include "ui/gfx/screen.h" @@ -549,7 +550,8 @@ bool MultiWindowResizeController::IsOverWindows( aura::Window* root = windows_.window1->GetRootWindow(); ::wm::ConvertPointFromScreen(root, &location_in_root); ui::MouseEvent test_event(ui::ET_MOUSE_MOVED, location_in_root, - location_in_root, ui::EF_NONE, ui::EF_NONE); + location_in_root, ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); ui::EventTarget* event_handler = static_cast(root) ->GetEventTargeter() ->FindTargetForEvent(root, &test_event); diff --git a/ash/wm/workspace/workspace_event_handler_unittest.cc b/ash/wm/workspace/workspace_event_handler_unittest.cc index dde0be8fd6b95c..42f7f517e7f2a8 100644 --- a/ash/wm/workspace/workspace_event_handler_unittest.cc +++ b/ash/wm/workspace/workspace_event_handler_unittest.cc @@ -18,6 +18,7 @@ #include "ui/aura/window_tree_host.h" #include "ui/base/hit_test.h" #include "ui/events/event_processor.h" +#include "ui/events/event_utils.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/screen.h" #include "ui/wm/core/window_util.h" @@ -37,10 +38,10 @@ void ClickButtonWithFlags(ui::test::EventGenerator* generator, int flags) { gfx::Point location = generator->current_location(); ui::MouseEvent press(ui::ET_MOUSE_PRESSED, location, location, - button | flags, button); + ui::EventTimeForNow(), button | flags, button); generator->Dispatch(&press); ui::MouseEvent release(ui::ET_MOUSE_RELEASED, location, location, - button | flags, button); + ui::EventTimeForNow(), button | flags, button); generator->Dispatch(&release); } diff --git a/ash/wm/workspace_controller_unittest.cc b/ash/wm/workspace_controller_unittest.cc index df1de84d561721..640785fb485c3a 100644 --- a/ash/wm/workspace_controller_unittest.cc +++ b/ash/wm/workspace_controller_unittest.cc @@ -1478,8 +1478,8 @@ TEST_F(WorkspaceControllerTest, WindowEdgeHitTest) { for (int i = 0; i < kNumPoints; ++i) { SCOPED_TRACE(points[i].direction); const gfx::Point& location = points[i].location; - ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, location, location, ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, location, location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); EXPECT_EQ(expected_target, target); @@ -1519,8 +1519,8 @@ TEST_F(WorkspaceControllerTest, WindowEdgeMouseHitTestPanel) { for (int i = 0; i < kNumPoints; ++i) { SCOPED_TRACE(points[i].direction); const gfx::Point& location = points[i].location; - ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, location, location, ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, location, location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); if (points[i].is_target_hit) EXPECT_EQ(window.get(), target); @@ -1596,8 +1596,8 @@ TEST_F(WorkspaceControllerTest, WindowEdgeHitTestDocked) { for (int i = 0; i < kNumPoints; ++i) { SCOPED_TRACE(points[i].direction); const gfx::Point& location = points[i].location; - ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, location, location, ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, location, location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); if (points[i].is_target_hit) EXPECT_EQ(window.get(), target); diff --git a/chrome/browser/chromeos/events/event_rewriter_unittest.cc b/chrome/browser/chromeos/events/event_rewriter_unittest.cc index aed81d1781b2a7..2467cc482a9eae 100644 --- a/chrome/browser/chromeos/events/event_rewriter_unittest.cc +++ b/chrome/browser/chromeos/events/event_rewriter_unittest.cc @@ -29,6 +29,7 @@ #include "ui/base/ime/chromeos/fake_ime_keyboard.h" #include "ui/events/event.h" #include "ui/events/event_rewriter.h" +#include "ui/events/event_utils.h" #include "ui/events/test/events_test_utils.h" #include "ui/events/test/test_event_processor.h" @@ -1984,10 +1985,8 @@ TEST_F(EventRewriterTest, DontRewriteIfNotRewritten) { // Test Alt + Left click. { - ui::MouseEvent press(ui::ET_MOUSE_PRESSED, - gfx::Point(), - gfx::Point(), - kLeftAndAltFlag, + ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), kLeftAndAltFlag, ui::EF_LEFT_MOUSE_BUTTON); ui::EventTestApi test_press(&press); test_press.set_source_device_id(10); @@ -2002,10 +2001,8 @@ TEST_F(EventRewriterTest, DontRewriteIfNotRewritten) { EXPECT_EQ(ui::EF_RIGHT_MOUSE_BUTTON, result->changed_button_flags()); } { - ui::MouseEvent release(ui::ET_MOUSE_RELEASED, - gfx::Point(), - gfx::Point(), - kLeftAndAltFlag, + ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), kLeftAndAltFlag, ui::EF_LEFT_MOUSE_BUTTON); ui::EventTestApi test_release(&release); test_release.set_source_device_id(10); @@ -2049,10 +2046,8 @@ TEST_F(EventRewriterTest, DontRewriteIfNotRewritten) { // No ALT in frst click. { - ui::MouseEvent press(ui::ET_MOUSE_PRESSED, - gfx::Point(), - gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON, + ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); ui::EventTestApi test_press(&press); test_press.set_source_device_id(10); @@ -2063,10 +2058,8 @@ TEST_F(EventRewriterTest, DontRewriteIfNotRewritten) { EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON, result->changed_button_flags()); } { - ui::MouseEvent release(ui::ET_MOUSE_RELEASED, - gfx::Point(), - gfx::Point(), - kLeftAndAltFlag, + ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), kLeftAndAltFlag, ui::EF_LEFT_MOUSE_BUTTON); ui::EventTestApi test_release(&release); test_release.set_source_device_id(10); @@ -2104,10 +2097,8 @@ TEST_F(EventRewriterTest, DontRewriteIfNotRewritten) { // ALT on different device. { - ui::MouseEvent press(ui::ET_MOUSE_PRESSED, - gfx::Point(), - gfx::Point(), - kLeftAndAltFlag, + ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), kLeftAndAltFlag, ui::EF_LEFT_MOUSE_BUTTON); ui::EventTestApi test_press(&press); test_press.set_source_device_id(11); @@ -2119,10 +2110,8 @@ TEST_F(EventRewriterTest, DontRewriteIfNotRewritten) { EXPECT_EQ(ui::EF_RIGHT_MOUSE_BUTTON, result->changed_button_flags()); } { - ui::MouseEvent release(ui::ET_MOUSE_RELEASED, - gfx::Point(), - gfx::Point(), - kLeftAndAltFlag, + ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), kLeftAndAltFlag, ui::EF_LEFT_MOUSE_BUTTON); ui::EventTestApi test_release(&release); test_release.set_source_device_id(10); @@ -2133,10 +2122,8 @@ TEST_F(EventRewriterTest, DontRewriteIfNotRewritten) { EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON, result->changed_button_flags()); } { - ui::MouseEvent release(ui::ET_MOUSE_RELEASED, - gfx::Point(), - gfx::Point(), - kLeftAndAltFlag, + ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), kLeftAndAltFlag, ui::EF_LEFT_MOUSE_BUTTON); ui::EventTestApi test_release(&release); test_release.set_source_device_id(11); @@ -2230,10 +2217,8 @@ TEST_F(EventRewriterAshTest, MouseEventDispatchImpl) { // Test mouse press event is correctly modified. gfx::Point location(0, 0); - ui::MouseEvent press(ui::ET_MOUSE_PRESSED, - location, - location, - ui::EF_LEFT_MOUSE_BUTTON, + ui::MouseEvent press(ui::ET_MOUSE_PRESSED, location, location, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); ui::EventDispatchDetails details = Send(&press); ASSERT_FALSE(details.dispatcher_destroyed); @@ -2244,10 +2229,8 @@ TEST_F(EventRewriterAshTest, MouseEventDispatchImpl) { // Test mouse release event is correctly modified and modifier release // event is sent. The mouse event should have the correct DIP location. - ui::MouseEvent release(ui::ET_MOUSE_RELEASED, - location, - location, - ui::EF_LEFT_MOUSE_BUTTON, + ui::MouseEvent release(ui::ET_MOUSE_RELEASED, location, location, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); details = Send(&release); ASSERT_FALSE(details.dispatcher_destroyed); @@ -2268,10 +2251,8 @@ TEST_F(EventRewriterAshTest, MouseWheelEventDispatchImpl) { SendActivateStickyKeyPattern(ui::VKEY_CONTROL); PopEvents(&events); gfx::Point location(0, 0); - ui::MouseEvent mev(ui::ET_MOUSEWHEEL, - location, - location, - ui::EF_LEFT_MOUSE_BUTTON, + ui::MouseEvent mev(ui::ET_MOUSEWHEEL, location, location, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); ui::MouseWheelEvent positive(mev, 0, ui::MouseWheelEvent::kWheelDelta); ui::EventDispatchDetails details = Send(&positive); diff --git a/chrome/browser/ui/views/apps/shaped_app_window_targeter_unittest.cc b/chrome/browser/ui/views/apps/shaped_app_window_targeter_unittest.cc index ef7d0cf7f98e36..4aa75e2afa172f 100644 --- a/chrome/browser/ui/views/apps/shaped_app_window_targeter_unittest.cc +++ b/chrome/browser/ui/views/apps/shaped_app_window_targeter_unittest.cc @@ -9,6 +9,7 @@ #include "ui/aura/test/aura_test_base.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" +#include "ui/events/event_utils.h" #include "ui/views/controls/webview/webview.h" #include "ui/wm/core/default_activation_client.h" #include "ui/wm/core/easy_resize_window_targeter.h" @@ -62,9 +63,9 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestBasic) { { // Without any custom shapes, the event should be targeted correctly to the // window. - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(40, 40), gfx::Point(40, 40), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(40, 40), + gfx::Point(40, 40), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -77,9 +78,9 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestBasic) { { // With an empty custom shape, all events within the window should fall // through to the root window. - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(40, 40), gfx::Point(40, 40), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(40, 40), + gfx::Point(40, 40), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -102,18 +103,18 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestBasic) { { // With the custom shape, the events that don't fall within the custom shape // will go through to the root window. - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(40, 40), gfx::Point(40, 40), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(40, 40), + gfx::Point(40, 40), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(root_window(), move.target()); // But events within the shape will still reach the window. - ui::MouseEvent move2(ui::ET_MOUSE_MOVED, - gfx::Point(80, 80), gfx::Point(80, 80), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move2(ui::ET_MOUSE_MOVED, gfx::Point(80, 80), + gfx::Point(80, 80), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); details = event_processor()->OnEventFromSource(&move2); ASSERT_FALSE(details.dispatcher_destroyed); EXPECT_EQ(window, move2.target()); @@ -132,9 +133,9 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestOnlyForShapedWindow) { { // Without any custom shapes, an event within the window bounds should be // targeted correctly to the window. - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(40, 40), gfx::Point(40, 40), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(40, 40), + gfx::Point(40, 40), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -144,9 +145,9 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestOnlyForShapedWindow) { // Without any custom shapes, an event that falls just outside the window // bounds should also be targeted correctly to the window, because of the // targeter installed on the root-window. - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(10, 10), gfx::Point(10, 10), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), + gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -160,9 +161,9 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestOnlyForShapedWindow) { { // With the custom shape, the events that don't fall within the custom shape // will go through to the root window. - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(10, 10), gfx::Point(10, 10), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), + gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -173,9 +174,9 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestOnlyForShapedWindow) { // app window for events just outside its bounds. app_window()->UpdateShape(scoped_ptr()); { - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(10, 10), gfx::Point(10, 10), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), + gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -190,9 +191,9 @@ TEST_F(ShapedAppWindowTargeterTest, ResizeInsetsWithinBounds) { { // An event in the center of the window should always have // |window| as its target. - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(80, 80), gfx::Point(80, 80), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(80, 80), + gfx::Point(80, 80), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -202,9 +203,9 @@ TEST_F(ShapedAppWindowTargeterTest, ResizeInsetsWithinBounds) { // Without an EasyResizeTargeter on the container, an event // inside the window and within 5px of an edge should have // |window| as its target. - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(32, 37), gfx::Point(32, 37), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(32, 37), + gfx::Point(32, 37), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -231,9 +232,9 @@ TEST_F(ShapedAppWindowTargeterTest, ResizeInsetsWithinBounds) { // RenderWidgetHostViewAura, we cannot differentiate the two cases. Fix // the test environment so that the test can assert that non-border events // bubble down to a child of |window|. - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(80, 80), gfx::Point(80, 80), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(80, 80), + gfx::Point(80, 80), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -243,9 +244,9 @@ TEST_F(ShapedAppWindowTargeterTest, ResizeInsetsWithinBounds) { // With an EasyResizeTargeter on the container, an event // inside the window and within 5px of an edge should have // |window| as its target. - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(32, 37), gfx::Point(32, 37), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(32, 37), + gfx::Point(32, 37), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); ui::EventDispatchDetails details = event_processor()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); diff --git a/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc b/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc index 0dc95c715e632a..01931d30bec8fb 100644 --- a/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc +++ b/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc @@ -122,10 +122,8 @@ IN_PROC_BROWSER_TEST_F(AutofillPopupBaseViewTest, DoubleClickTest) { ShowView(); - ui::MouseEvent mouse_down(ui::ET_MOUSE_PRESSED, - gfx::Point(0, 0), - gfx::Point(0, 0), - 0, 0); + ui::MouseEvent mouse_down(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), + gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); EXPECT_TRUE(static_cast(view_)->OnMousePressed(mouse_down)); // Ignore double clicks. diff --git a/chrome/browser/ui/views/autofill/password_generation_popup_view_tester_views.cc b/chrome/browser/ui/views/autofill/password_generation_popup_view_tester_views.cc index dded3a7d2d1389..6e4e644d1c628d 100644 --- a/chrome/browser/ui/views/autofill/password_generation_popup_view_tester_views.cc +++ b/chrome/browser/ui/views/autofill/password_generation_popup_view_tester_views.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/views/autofill/password_generation_popup_view_tester_views.h" #include "chrome/browser/ui/views/autofill/password_generation_popup_view_views.h" +#include "ui/events/event_utils.h" namespace autofill { @@ -24,10 +25,8 @@ PasswordGenerationPopupViewTesterViews:: void PasswordGenerationPopupViewTesterViews::SimulateMouseMovementAt( const gfx::Point& point) { - ui::MouseEvent mouse_down(ui::ET_MOUSE_MOVED, - point, - gfx::Point(0, 0), - 0, 0); + ui::MouseEvent mouse_down(ui::ET_MOUSE_MOVED, point, gfx::Point(0, 0), + ui::EventTimeForNow(), 0, 0); static_cast(view_)->OnMouseMoved(mouse_down); } diff --git a/chrome/browser/ui/views/desktop_media_picker_views_unittest.cc b/chrome/browser/ui/views/desktop_media_picker_views_unittest.cc index 24f80ca59dd90b..0e2e3f179bf9f1 100644 --- a/chrome/browser/ui/views/desktop_media_picker_views_unittest.cc +++ b/chrome/browser/ui/views/desktop_media_picker_views_unittest.cc @@ -13,6 +13,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/aura/window.h" #include "ui/compositor/test/context_factories_for_test.h" +#include "ui/events/event_utils.h" #include "ui/views/test/views_test_helper.h" #include "ui/views/widget/widget.h" #include "ui/views/window/dialog_delegate.h" @@ -108,9 +109,8 @@ TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnDoubleClick) { media_list_->AddSource(kFakeId); - ui::MouseEvent double_click(ui::ET_MOUSE_PRESSED, - gfx::Point(), - gfx::Point(), + ui::MouseEvent double_click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_IS_DOUBLE_CLICK, ui::EF_LEFT_MOUSE_BUTTON); diff --git a/chrome/browser/ui/views/extensions/bookmark_override_browsertest.cc b/chrome/browser/ui/views/extensions/bookmark_override_browsertest.cc index 12a0505acea799..c61b1e513d147f 100644 --- a/chrome/browser/ui/views/extensions/bookmark_override_browsertest.cc +++ b/chrome/browser/ui/views/extensions/bookmark_override_browsertest.cc @@ -15,6 +15,7 @@ #include "chrome/test/base/ui_test_utils.h" #include "extensions/common/manifest_constants.h" #include "extensions/test/result_catcher.h" +#include "ui/events/event_utils.h" typedef ExtensionApiTest BookmarkOverrideTest; @@ -49,12 +50,12 @@ IN_PROC_BROWSER_TEST_F(BookmarkOverrideTest, DISABLED_NonOverrideStarClick) { views::View* star_view = browser_view->GetToolbarView()->location_bar()->star_view(); - ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); - ui::MouseEvent released_event(ui::ET_MOUSE_RELEASED, gfx::Point(), - gfx::Point(), ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent pressed_event( + ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent released_event( + ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); // Verify that clicking once shows the bookmark bubble. EXPECT_FALSE(BookmarkBubbleView::IsShowing()); diff --git a/chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup.cc b/chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup.cc index 296ce5cac68023..fa038d58ddd628 100644 --- a/chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup.cc +++ b/chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup.cc @@ -93,7 +93,8 @@ void LinkDisambiguationPopup::ZoomBubbleView::OnMouseEvent( (event->location().x() / scale_) + target_rect_.x(), (event->location().y() / scale_) + target_rect_.y()); ui::MouseEvent xform_event(event->type(), xform_location, xform_location, - event->flags(), event->changed_button_flags()); + ui::EventTimeForNow(), event->flags(), + event->changed_button_flags()); mouse_cb_.Run(&xform_event); event->SetHandled(); diff --git a/chrome/browser/ui/views/location_bar/star_view_browsertest.cc b/chrome/browser/ui/views/location_bar/star_view_browsertest.cc index 8dece781b97d95..717562bae76ea2 100644 --- a/chrome/browser/ui/views/location_bar/star_view_browsertest.cc +++ b/chrome/browser/ui/views/location_bar/star_view_browsertest.cc @@ -18,6 +18,7 @@ #include "content/public/test/browser_test_utils.h" #include "content/public/test/test_utils.h" #include "ui/base/ui_base_switches.h" +#include "ui/events/event_utils.h" #if defined(OS_WIN) #include "ui/aura/window.h" @@ -41,12 +42,12 @@ IN_PROC_BROWSER_TEST_F(StarViewTest, MAYBE_HideOnSecondClick) { views::View* star_view = browser_view->GetToolbarView()->location_bar()->star_view(); - ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); - ui::MouseEvent released_event(ui::ET_MOUSE_RELEASED, gfx::Point(), - gfx::Point(), ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent pressed_event( + ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent released_event( + ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); // Verify that clicking once shows the bookmark bubble. EXPECT_FALSE(BookmarkBubbleView::IsShowing()); diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc index 52aaaef63e994a..92d894a2547c30 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc @@ -326,13 +326,14 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, CloseOmniboxPopupOnTextDrag) { // Simulate a mouse click before dragging the mouse. gfx::Point point(omnibox_view_views->x(), omnibox_view_views->y()); ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); omnibox_view_views->OnMousePressed(pressed); EXPECT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); // Simulate a mouse drag of the omnibox text, and the omnibox should close. ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, point, point, - ui::EF_LEFT_MOUSE_BUTTON, 0); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); omnibox_view_views->OnMouseDragged(dragged); EXPECT_FALSE(omnibox_view->model()->popup_model()->IsOpen()); diff --git a/chrome/browser/ui/views/passwords/manage_passwords_icon_view_browsertest.cc b/chrome/browser/ui/views/passwords/manage_passwords_icon_view_browsertest.cc index ce76ca8b5fe823..1c26bac68f9c85 100644 --- a/chrome/browser/ui/views/passwords/manage_passwords_icon_view_browsertest.cc +++ b/chrome/browser/ui/views/passwords/manage_passwords_icon_view_browsertest.cc @@ -16,6 +16,7 @@ #include "content/public/test/test_utils.h" #include "grit/theme_resources.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/events/event_utils.h" class ManagePasswordsIconViewTest : public ManagePasswordsTest { public: @@ -84,8 +85,8 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsIconViewTest, CloseOnClick) { SetupPendingPassword(); EXPECT_TRUE(view()->visible()); EXPECT_TRUE(view()->active()); - ui::MouseEvent mouse_down(ui::ET_MOUSE_PRESSED, - gfx::Point(10, 10), gfx::Point(900, 60), + ui::MouseEvent mouse_down(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), + gfx::Point(900, 60), ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); view()->OnMousePressed(mouse_down); // Wait for the command execution to close the bubble. diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc b/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc index fb51c7806f0e75..a15935822ed0a2 100644 --- a/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc +++ b/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc @@ -27,6 +27,7 @@ #include "components/signin/core/common/profile_management_switches.h" #include "content/public/test/test_utils.h" #include "extensions/browser/extension_registry.h" +#include "ui/events/event_utils.h" // ChromeOS and mobile platforms don't have a ProfileChooserView. #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) @@ -97,7 +98,8 @@ class ProfileChooserViewExtensionsTest : public ExtensionBrowserTest { ProfileChooserView::close_on_deactivate_for_testing_ = false; - ui::MouseEvent e(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent e(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); button->NotifyClick(e); base::MessageLoop::current()->RunUntilIdle(); EXPECT_TRUE(ProfileChooserView::IsShowing()); @@ -113,7 +115,8 @@ class ProfileChooserViewExtensionsTest : public ExtensionBrowserTest { } void ClickProfileChooserViewLockButton() { - ui::MouseEvent e(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent e(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); ProfileChooserView::profile_bubble_->ButtonPressed( ProfileChooserView::profile_bubble_->lock_button_, e); } diff --git a/chrome/browser/ui/views/sync/one_click_signin_bubble_view_unittest.cc b/chrome/browser/ui/views/sync/one_click_signin_bubble_view_unittest.cc index 4fa479d285d804..346697842072de 100644 --- a/chrome/browser/ui/views/sync/one_click_signin_bubble_view_unittest.cc +++ b/chrome/browser/ui/views/sync/one_click_signin_bubble_view_unittest.cc @@ -9,6 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" #include "content/public/test/test_utils.h" +#include "ui/events/event_utils.h" #include "ui/views/controls/button/label_button.h" #include "ui/views/test/views_test_base.h" #include "ui/views/widget/widget.h" @@ -146,9 +147,8 @@ TEST_F(OneClickSigninBubbleViewTest, BubbleOkButton) { // Simulate pressing the OK button. Set the message loop in the bubble // view so that it can be quit once the bubble is hidden. views::ButtonListener* listener = view; - const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, - gfx::Point(), gfx::Point(), - 0, 0); + const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); listener->ButtonPressed(view->ok_button_, event); // View should no longer be showing. The message loop will exit once the @@ -164,9 +164,8 @@ TEST_F(OneClickSigninBubbleViewTest, DialogOkButton) { // Simulate pressing the OK button. Set the message loop in the bubble // view so that it can be quit once the bubble is hidden. views::ButtonListener* listener = view; - const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, - gfx::Point(), gfx::Point(), - 0, 0); + const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); listener->ButtonPressed(view->ok_button_, event); // View should no longer be showing and sync should start @@ -184,9 +183,8 @@ TEST_F(OneClickSigninBubbleViewTest, DialogUndoButton) { // Simulate pressing the undo button. Set the message loop in the bubble // view so that it can be quit once the bubble is hidden. views::ButtonListener* listener = view; - const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, - gfx::Point(), gfx::Point(), - 0, 0); + const ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); listener->ButtonPressed(view->undo_button_, event); // View should no longer be showing. The message loop will exit once the diff --git a/chrome/browser/ui/views/toolbar/reload_button_unittest.cc b/chrome/browser/ui/views/toolbar/reload_button_unittest.cc index 3355ea659f978d..87579af18f913b 100644 --- a/chrome/browser/ui/views/toolbar/reload_button_unittest.cc +++ b/chrome/browser/ui/views/toolbar/reload_button_unittest.cc @@ -5,6 +5,7 @@ #include "base/message_loop/message_loop.h" #include "chrome/browser/ui/views/toolbar/reload_button.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/events/event_utils.h" class ReloadButtonTest : public testing::Test { public: @@ -57,7 +58,8 @@ TEST_F(ReloadButtonTest, Basic) { false); // Press the button. This should start the double-click timer. - ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); reload_.ButtonPressed(&reload_, e); CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, true, false); @@ -76,7 +78,8 @@ TEST_F(ReloadButtonTest, Basic) { TEST_F(ReloadButtonTest, DoubleClickTimer) { // Start by pressing the button. - ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); reload_.ButtonPressed(&reload_, e); // Try to press the button again. This should do nothing because the timer is @@ -102,7 +105,8 @@ TEST_F(ReloadButtonTest, DoubleClickTimer) { TEST_F(ReloadButtonTest, DisableOnHover) { // Change to stop and hover. - ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); reload_.ButtonPressed(&reload_, e); reload_.ChangeMode(ReloadButton::MODE_STOP, false); set_mouse_hovered(true); @@ -115,7 +119,8 @@ TEST_F(ReloadButtonTest, DisableOnHover) { // Un-hover the button, which should allow it to reset. set_mouse_hovered(false); - ui::MouseEvent e2(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent e2(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); reload_.OnMouseExited(e2); CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, false, false); @@ -123,7 +128,8 @@ TEST_F(ReloadButtonTest, DisableOnHover) { TEST_F(ReloadButtonTest, ResetOnClick) { // Change to stop and hover. - ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); reload_.ButtonPressed(&reload_, e); reload_.ChangeMode(ReloadButton::MODE_STOP, false); set_mouse_hovered(true); @@ -137,7 +143,8 @@ TEST_F(ReloadButtonTest, ResetOnClick) { TEST_F(ReloadButtonTest, ResetOnTimer) { // Change to stop, hover, and change back to reload. - ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent e(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); reload_.ButtonPressed(&reload_, e); reload_.ChangeMode(ReloadButton::MODE_STOP, false); set_mouse_hovered(true); diff --git a/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc b/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc index a7626d440d484c..ba187b0053491d 100644 --- a/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc +++ b/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc @@ -10,6 +10,7 @@ #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" #include "ui/events/event_processor.h" +#include "ui/events/event_utils.h" #include "ui/events/gesture_detection/gesture_configuration.h" using blink::WebTouchEvent; @@ -47,8 +48,8 @@ void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( const blink::WebMouseWheelEvent& web_wheel, const ui::LatencyInfo&) { gfx::Point location(web_wheel.x, web_wheel.y); - ui::MouseEvent mouse_event( - ui::ET_MOUSEWHEEL, location, location, ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent mouse_event(ui::ET_MOUSEWHEEL, location, location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); ui::MouseWheelEvent wheel_event( mouse_event, web_wheel.deltaX, web_wheel.deltaY); @@ -117,7 +118,8 @@ void SyntheticGestureTargetAura::DispatchWebMouseEventToPlatform( gfx::Point location(web_mouse.x, web_mouse.y); ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type); int flags = WebMouseEventButtonToFlags(web_mouse.button); - ui::MouseEvent mouse_event(event_type, location, location, flags, flags); + ui::MouseEvent mouse_event(event_type, location, location, + ui::EventTimeForNow(), flags, flags); aura::Window* window = GetWindow(); mouse_event.ConvertLocationToTarget(window, window->GetRootWindow()); diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc index d643e4f2f3b3de..3a171dbbe51f5e 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc @@ -971,9 +971,9 @@ TEST_F(RenderWidgetHostViewAuraTest, FinishCompositionByMouse) { sink_->ClearMessages(); // Simulates the mouse press. - ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, - gfx::Point(), gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON, 0); + ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + 0); view_->OnMouseEvent(&mouse_event); EXPECT_FALSE(view_->has_composition_text_); diff --git a/content/browser/web_contents/aura/window_slider_unittest.cc b/content/browser/web_contents/aura/window_slider_unittest.cc index a1988d4990b1af..390a00244bee02 100644 --- a/content/browser/web_contents/aura/window_slider_unittest.cc +++ b/content/browser/web_contents/aura/window_slider_unittest.cc @@ -290,12 +290,10 @@ TEST_F(WindowSliderTest, WindowSlideIsCancelledOnEvent) { WindowSliderDelegateTest slider_delegate; ui::Event* events[] = { - new ui::MouseEvent(ui::ET_MOUSE_MOVED, - gfx::Point(55, 10), - gfx::Point(55, 10), - 0, 0), - new ui::KeyEvent('a', ui::VKEY_A, ui::EF_NONE), - NULL + new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(55, 10), + gfx::Point(55, 10), ui::EventTimeForNow(), 0, 0), + new ui::KeyEvent('a', ui::VKEY_A, ui::EF_NONE), + nullptr }; new WindowSlider(&slider_delegate, root_window(), window.get()); @@ -338,10 +336,9 @@ TEST_F(WindowSliderTest, WindowSlideInterruptedThenContinues) { WindowSlider* slider = new WindowSlider(&slider_delegate, root_window(), window.get()); - ui::MouseEvent interrupt_event(ui::ET_MOUSE_MOVED, - gfx::Point(55, 10), - gfx::Point(55, 10), - 0, 0); + ui::MouseEvent interrupt_event(ui::ET_MOUSE_MOVED, gfx::Point(55, 10), + gfx::Point(55, 10), ui::EventTimeForNow(), 0, + 0); ui::test::EventGenerator generator(root_window()); diff --git a/ui/app_list/views/app_list_main_view_unittest.cc b/ui/app_list/views/app_list_main_view_unittest.cc index 23f90796233210..accc731b76c4ab 100644 --- a/ui/app_list/views/app_list_main_view_unittest.cc +++ b/ui/app_list/views/app_list_main_view_unittest.cc @@ -19,6 +19,7 @@ #include "ui/app_list/views/contents_view.h" #include "ui/app_list/views/search_box_view.h" #include "ui/app_list/views/test/apps_grid_view_test_api.h" +#include "ui/events/event_utils.h" #include "ui/events/test/event_generator.h" #include "ui/views/test/views_test_base.h" #include "ui/views/view_model.h" @@ -127,16 +128,12 @@ class AppListMainViewTest : public views::ViewsTestBase { void SimulateClick(views::View* view) { gfx::Point center = view->GetLocalBounds().CenterPoint(); - view->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, - center, - center, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); - view->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED, - center, - center, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); + view->OnMousePressed(ui::MouseEvent( + ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); + view->OnMouseReleased(ui::MouseEvent( + ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); } // |point| is in |grid_view|'s coordinates. @@ -148,7 +145,8 @@ class AppListMainViewTest : public views::ViewsTestBase { gfx::Point translated = gfx::PointAtOffsetFromOrigin(point - view->bounds().origin()); - ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, translated, point, 0, 0); + ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, translated, point, + ui::EventTimeForNow(), 0, 0); grid_view->InitiateDrag(view, pointer, pressed_event); return view; } @@ -161,7 +159,8 @@ class AppListMainViewTest : public views::ViewsTestBase { DCHECK(drag_view); gfx::Point translated = gfx::PointAtOffsetFromOrigin(point - drag_view->bounds().origin()); - ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated, point, 0, 0); + ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated, point, + ui::EventTimeForNow(), 0, 0); grid_view->UpdateDragFromItem(pointer, drag_event); } diff --git a/ui/app_list/views/app_list_view_unittest.cc b/ui/app_list/views/app_list_view_unittest.cc index 5e30e66907346c..81dc2cf4154555 100644 --- a/ui/app_list/views/app_list_view_unittest.cc +++ b/ui/app_list/views/app_list_view_unittest.cc @@ -30,6 +30,7 @@ #include "ui/app_list/views/start_page_view.h" #include "ui/app_list/views/test/apps_grid_view_test_api.h" #include "ui/app_list/views/tile_item_view.h" +#include "ui/events/event_utils.h" #include "ui/views/controls/textfield/textfield.h" #include "ui/views/test/views_test_base.h" #include "ui/views/views_delegate.h" @@ -60,16 +61,12 @@ size_t GetVisibleViews(const std::vector& tiles) { void SimulateClick(views::View* view) { gfx::Point center = view->GetLocalBounds().CenterPoint(); - view->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, - center, - center, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); - view->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED, - center, - center, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); + view->OnMousePressed(ui::MouseEvent( + ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); + view->OnMouseReleased(ui::MouseEvent( + ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); } // Choose a set that is 3 regular app list pages and 2 landscape app list pages. diff --git a/ui/app_list/views/apps_grid_view_unittest.cc b/ui/app_list/views/apps_grid_view_unittest.cc index 076f4f2252d27f..4dd2471442d244 100644 --- a/ui/app_list/views/apps_grid_view_unittest.cc +++ b/ui/app_list/views/apps_grid_view_unittest.cc @@ -24,6 +24,7 @@ #include "ui/app_list/views/app_list_item_view.h" #include "ui/app_list/views/apps_grid_view_folder_delegate.h" #include "ui/app_list/views/test/apps_grid_view_test_api.h" +#include "ui/events/event_utils.h" #include "ui/views/test/views_test_base.h" namespace app_list { @@ -154,12 +155,12 @@ class AppsGridViewTest : public views::ViewsTestBase { gfx::Point translated_to = gfx::PointAtOffsetFromOrigin( to - view->bounds().origin()); - ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, - translated_from, from, 0, 0); + ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, translated_from, from, + ui::EventTimeForNow(), 0, 0); apps_grid_view_->InitiateDrag(view, pointer, pressed_event); - ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, - translated_to, to, 0, 0); + ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated_to, to, + ui::EventTimeForNow(), 0, 0); apps_grid_view_->UpdateDragFromItem(pointer, drag_event); return view; } @@ -305,8 +306,8 @@ TEST_F(AppsGridViewTest, MouseDragWithFolderDisabled) { EXPECT_FALSE(apps_grid_view_->has_dragged_view()); // Even though cancelled, mouse move events can still arrive via the item // view. Ensure that behaves sanely, and doesn't start a new drag. - ui::MouseEvent drag_event( - ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1), gfx::Point(2, 2), 0, 0); + ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1), + gfx::Point(2, 2), ui::EventTimeForNow(), 0, 0); apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, drag_event); EXPECT_FALSE(apps_grid_view_->has_dragged_view()); @@ -450,7 +451,8 @@ TEST_F(AppsGridViewTest, MouseDragMaxItemsInFolderWithMovement) { to = GetItemTileRectAt(0, 1).CenterPoint(); gfx::Point translated_to = gfx::PointAtOffsetFromOrigin(to - dragged_view->bounds().origin()); - ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated_to, to, 0, 0); + ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated_to, to, + ui::EventTimeForNow(), 0, 0); apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, drag_event); apps_grid_view_->EndDrag(false); diff --git a/ui/app_list/views/speech_view_unittest.cc b/ui/app_list/views/speech_view_unittest.cc index 319eca66bd9ed0..de190fb92d0752 100644 --- a/ui/app_list/views/speech_view_unittest.cc +++ b/ui/app_list/views/speech_view_unittest.cc @@ -5,6 +5,7 @@ #include "ui/app_list/views/speech_view.h" #include "ui/app_list/test/app_list_test_view_delegate.h" +#include "ui/events/event_utils.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/test/widget_test.h" @@ -56,16 +57,12 @@ TEST_F(SpeechViewTest, ClickMicButton) { gfx::Rect screen_bounds(view()->mic_button()->GetBoundsInScreen()); // Simulate a mouse click in the center of the MicButton. - ui::MouseEvent press(ui::ET_MOUSE_PRESSED, - screen_bounds.CenterPoint(), - screen_bounds.CenterPoint(), - ui::EF_LEFT_MOUSE_BUTTON, - 0); - ui::MouseEvent release(ui::ET_MOUSE_RELEASED, - screen_bounds.CenterPoint(), - screen_bounds.CenterPoint(), - ui::EF_LEFT_MOUSE_BUTTON, - 0); + ui::MouseEvent press(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(), + screen_bounds.CenterPoint(), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, 0); + ui::MouseEvent release(ui::ET_MOUSE_RELEASED, screen_bounds.CenterPoint(), + screen_bounds.CenterPoint(), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, 0); widget()->OnMouseEvent(&press); widget()->OnMouseEvent(&release); EXPECT_EQ(1, GetToggleSpeechRecognitionCountAndReset()); @@ -75,16 +72,10 @@ TEST_F(SpeechViewTest, ClickMicButton) { // circular hit-test mask). gfx::Point bottom_right(screen_bounds.right() - 1, screen_bounds.bottom() - 2); - press = ui::MouseEvent(ui::ET_MOUSE_PRESSED, - bottom_right, - bottom_right, - ui::EF_LEFT_MOUSE_BUTTON, - 0); - release = ui::MouseEvent(ui::ET_MOUSE_RELEASED, - bottom_right, - bottom_right, - ui::EF_LEFT_MOUSE_BUTTON, - 0); + press = ui::MouseEvent(ui::ET_MOUSE_PRESSED, bottom_right, bottom_right, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); + release = ui::MouseEvent(ui::ET_MOUSE_RELEASED, bottom_right, bottom_right, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); widget()->OnMouseEvent(&press); widget()->OnMouseEvent(&release); EXPECT_EQ(0, GetToggleSpeechRecognitionCountAndReset()); diff --git a/ui/aura/remote_window_tree_host_win.cc b/ui/aura/remote_window_tree_host_win.cc index 3b34357305319f..c44234ce86e621 100644 --- a/ui/aura/remote_window_tree_host_win.cc +++ b/ui/aura/remote_window_tree_host_win.cc @@ -311,16 +311,17 @@ void RemoteWindowTreeHostWin::OnMouseMoved(int32 x, int32 y, int32 flags) { return; gfx::Point location = PointFromNativeEvent(x, y); - ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, flags, 0); + ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, + ui::EventTimeForNow(), flags, 0); SendEventToProcessor(&event); } void RemoteWindowTreeHostWin::OnMouseButton( const MetroViewerHostMsg_MouseButtonParams& params) { gfx::Point location = PointFromNativeEvent(params.x, params.y); - ui::MouseEvent mouse_event(params.event_type, location, location, - static_cast(params.flags), - static_cast(params.changed_button)); + ui::MouseEvent mouse_event( + params.event_type, location, location, ui::EventTimeForNow(), + static_cast(params.flags), static_cast(params.changed_button)); SetEventFlags(params.flags | key_event_flags()); if (params.event_type == ui::ET_MOUSEWHEEL) { diff --git a/ui/aura/test/ui_controls_factory_ozone.cc b/ui/aura/test/ui_controls_factory_ozone.cc index 2a256624616b31..a928275da3e72e 100644 --- a/ui/aura/test/ui_controls_factory_ozone.cc +++ b/ui/aura/test/ui_controls_factory_ozone.cc @@ -10,6 +10,7 @@ #include "ui/aura/test/ui_controls_factory_aura.h" #include "ui/aura/window_tree_host.h" #include "ui/base/test/ui_controls_aura.h" +#include "ui/events/event_utils.h" #include "ui/events/test/events_test_utils.h" namespace aura { @@ -217,7 +218,8 @@ class UIControlsOzone : public ui_controls::UIControlsAura { const gfx::PointF& host_location, int flags, int changed_button_flags) { - ui::MouseEvent mouse_event(type, host_location, host_location, flags, + ui::MouseEvent mouse_event(type, host_location, host_location, + ui::EventTimeForNow(), flags, changed_button_flags); // This hack is necessary to set the repeat count for clicks. diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc index d0401efa395834..d5cfc6b928ace2 100644 --- a/ui/aura/window_event_dispatcher.cc +++ b/ui/aura/window_event_dispatcher.cc @@ -22,6 +22,7 @@ #include "ui/base/hit_test.h" #include "ui/compositor/dip_util.h" #include "ui/events/event.h" +#include "ui/events/event_utils.h" #include "ui/events/gestures/gesture_recognizer.h" #include "ui/events/gestures/gesture_types.h" @@ -152,8 +153,8 @@ void WindowEventDispatcher::DispatchGestureEvent(ui::GestureEvent* event) { DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( Window* window, const gfx::Point& point) { - ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); return DispatchMouseEnterOrExit(window, event, ui::ET_MOUSE_EXITED); } @@ -370,7 +371,7 @@ void WindowEventDispatcher::UpdateCapture(Window* old_capture, old_capture->delegate()) { // Send a capture changed event with bogus location data. ui::MouseEvent event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(), - gfx::Point(), 0, 0); + gfx::Point(), ui::EventTimeForNow(), 0, 0); DispatchDetails details = DispatchEvent(old_capture, &event); if (details.dispatcher_destroyed) @@ -726,11 +727,9 @@ ui::EventDispatchDetails WindowEventDispatcher::SynthesizeMouseMoveEvent() { return details; gfx::Point host_mouse_location = root_mouse_location; host_->ConvertPointToHost(&host_mouse_location); - ui::MouseEvent event(ui::ET_MOUSE_MOVED, - host_mouse_location, - host_mouse_location, - ui::EF_IS_SYNTHESIZED, - 0); + ui::MouseEvent event(ui::ET_MOUSE_MOVED, host_mouse_location, + host_mouse_location, ui::EventTimeForNow(), + ui::EF_IS_SYNTHESIZED, 0); return OnEventFromSource(&event); } diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc index cfc08c2cc06b10..6fc8d8f5d3d326 100644 --- a/ui/aura/window_event_dispatcher_unittest.cc +++ b/ui/aura/window_event_dispatcher_unittest.cc @@ -117,9 +117,9 @@ TEST_F(WindowEventDispatcherTest, OnHostMouseEvent) { // Send a mouse event to window1. gfx::Point point(101, 201); - ui::MouseEvent event1( - ui::ET_MOUSE_PRESSED, point, point, ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, point, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); DispatchEventUsingWindowDispatcher(&event1); // Event was tested for non-client area for the target window. @@ -140,9 +140,9 @@ TEST_F(WindowEventDispatcherTest, RepostEvent) { // Test RepostEvent in RootWindow. It only works for Mouse Press. EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); gfx::Point point(10, 10); - ui::MouseEvent event( - ui::ET_MOUSE_PRESSED, point, point, ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent event(ui::ET_MOUSE_PRESSED, point, point, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); host()->dispatcher()->RepostEvent(event); RunAllPendingInMessageLoop(); EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); @@ -158,19 +158,14 @@ TEST_F(WindowEventDispatcherTest, MouseButtonState) { // Press the left button. event.reset(new ui::MouseEvent( - ui::ET_MOUSE_PRESSED, - location, - location, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); + ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); DispatchEventUsingWindowDispatcher(event.get()); EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); // Additionally press the right. event.reset(new ui::MouseEvent( - ui::ET_MOUSE_PRESSED, - location, - location, + ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); DispatchEventUsingWindowDispatcher(event.get()); @@ -178,31 +173,22 @@ TEST_F(WindowEventDispatcherTest, MouseButtonState) { // Release the left button. event.reset(new ui::MouseEvent( - ui::ET_MOUSE_RELEASED, - location, - location, - ui::EF_RIGHT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); + ui::ET_MOUSE_RELEASED, location, location, ui::EventTimeForNow(), + ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); DispatchEventUsingWindowDispatcher(event.get()); EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); // Release the right button. We should ignore the Shift-is-down flag. - event.reset(new ui::MouseEvent( - ui::ET_MOUSE_RELEASED, - location, - location, - ui::EF_SHIFT_DOWN, - ui::EF_RIGHT_MOUSE_BUTTON)); + event.reset(new ui::MouseEvent(ui::ET_MOUSE_RELEASED, location, location, + ui::EventTimeForNow(), ui::EF_SHIFT_DOWN, + ui::EF_RIGHT_MOUSE_BUTTON)); DispatchEventUsingWindowDispatcher(event.get()); EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); // Press the middle button. event.reset(new ui::MouseEvent( - ui::ET_MOUSE_PRESSED, - location, - location, - ui::EF_MIDDLE_MOUSE_BUTTON, - ui::EF_MIDDLE_MOUSE_BUTTON)); + ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(), + ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_MIDDLE_MOUSE_BUTTON)); DispatchEventUsingWindowDispatcher(event.get()); EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); } @@ -212,7 +198,8 @@ TEST_F(WindowEventDispatcherTest, TranslatedEvent) { gfx::Rect(50, 50, 100, 100), root_window())); gfx::Point origin(100, 100); - ui::MouseEvent root(ui::ET_MOUSE_PRESSED, origin, origin, 0, 0); + ui::MouseEvent root(ui::ET_MOUSE_PRESSED, origin, origin, + ui::EventTimeForNow(), 0, 0); EXPECT_EQ("100,100", root.location().ToString()); EXPECT_EQ("100,100", root.root_location().ToString()); @@ -638,7 +625,7 @@ TEST_F(WindowEventDispatcherTest, MAYBE(RepostTargetsCaptureWindow)) { window->AddPreTargetHandler(&recorder); window->SetCapture(); const ui::MouseEvent press_event( - ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); host()->dispatcher()->RepostEvent(press_event); RunAllPendingInMessageLoop(); // Necessitated by RepostEvent(). @@ -656,7 +643,8 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); ui::MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0), - gfx::Point(0, 0), 0, 0); + gfx::Point(0, 0), ui::EventTimeForNow(), 0, + 0); DispatchEventUsingWindowDispatcher(&mouse_move_event); // Discard MOUSE_ENTER. recorder.Reset(); @@ -665,14 +653,16 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { // Check that we don't immediately dispatch the MOUSE_DRAGGED event. ui::MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), - gfx::Point(0, 0), 0, 0); + gfx::Point(0, 0), ui::EventTimeForNow(), 0, + 0); DispatchEventUsingWindowDispatcher(&mouse_dragged_event); EXPECT_TRUE(recorder.events().empty()); // Check that we do dispatch the held MOUSE_DRAGGED event before another type // of event. ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), - gfx::Point(0, 0), 0, 0); + gfx::Point(0, 0), ui::EventTimeForNow(), 0, + 0); DispatchEventUsingWindowDispatcher(&mouse_pressed_event); EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED", EventTypesToString(recorder.events())); @@ -681,15 +671,18 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { // Check that we coalesce held MOUSE_DRAGGED events. Note that here (and // elsewhere in this test) we re-define each event prior to dispatch so that // it has the correct state (phase, handled, target, etc.). - mouse_dragged_event = ui::MouseEvent( - ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); + mouse_dragged_event = + ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0), + ui::EventTimeForNow(), 0, 0); ui::MouseEvent mouse_dragged_event2(ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10), - gfx::Point(10, 10), 0, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), + 0, 0); DispatchEventUsingWindowDispatcher(&mouse_dragged_event); DispatchEventUsingWindowDispatcher(&mouse_dragged_event2); EXPECT_TRUE(recorder.events().empty()); - mouse_pressed_event = ui::MouseEvent( - ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); + mouse_pressed_event = + ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), + ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&mouse_pressed_event); EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED", EventTypesToString(recorder.events())); @@ -697,8 +690,9 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { // Check that on ReleasePointerMoves, held events are not dispatched // immediately, but posted instead. - mouse_dragged_event = ui::MouseEvent( - ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); + mouse_dragged_event = + ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0), + ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&mouse_dragged_event); host()->dispatcher()->ReleasePointerMoves(); EXPECT_TRUE(recorder.events().empty()); @@ -709,12 +703,14 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { // However if another message comes in before the dispatch of the posted // event, check that the posted event is dispatched before this new event. host()->dispatcher()->HoldPointerMoves(); - mouse_dragged_event = ui::MouseEvent( - ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); + mouse_dragged_event = + ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0), + ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&mouse_dragged_event); host()->dispatcher()->ReleasePointerMoves(); - mouse_pressed_event = ui::MouseEvent( - ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); + mouse_pressed_event = + ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), + ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&mouse_pressed_event); EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED", EventTypesToString(recorder.events())); @@ -725,12 +721,14 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { // Check that if the other message is another MOUSE_DRAGGED, we still coalesce // them. host()->dispatcher()->HoldPointerMoves(); - mouse_dragged_event = ui::MouseEvent( - ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); + mouse_dragged_event = + ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0), + ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&mouse_dragged_event); host()->dispatcher()->ReleasePointerMoves(); - mouse_dragged_event2 = ui::MouseEvent( - ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10), gfx::Point(10, 10), 0, 0); + mouse_dragged_event2 = + ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10), + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&mouse_dragged_event2); EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(recorder.events())); recorder.Reset(); @@ -739,12 +737,15 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { // Check that synthetic mouse move event has a right location when issued // while holding pointer moves. - mouse_dragged_event = ui::MouseEvent( - ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0), 0, 0); - mouse_dragged_event2 = ui::MouseEvent( - ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10), gfx::Point(10, 10), 0, 0); + mouse_dragged_event = + ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0), + ui::EventTimeForNow(), 0, 0); + mouse_dragged_event2 = + ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10), + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); ui::MouseEvent mouse_dragged_event3(ui::ET_MOUSE_DRAGGED, gfx::Point(28, 28), - gfx::Point(28, 28), 0, 0); + gfx::Point(28, 28), ui::EventTimeForNow(), + 0, 0); host()->dispatcher()->HoldPointerMoves(); DispatchEventUsingWindowDispatcher(&mouse_dragged_event); DispatchEventUsingWindowDispatcher(&mouse_dragged_event2); @@ -834,8 +835,8 @@ TEST_F(WindowEventDispatcherTest, MouseEventWithoutTargetWindow) { window_second->AddPreTargetHandler(&recorder_second); const gfx::Point event_location(22, 33); - ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 0, - 0); + ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, + ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&mouse); EXPECT_TRUE(recorder_first.events().empty()); @@ -973,14 +974,15 @@ TEST_F(WindowEventDispatcherTest, DispatchSyntheticMouseEvents) { // Dispatch a non-synthetic mouse event when mouse events are enabled. ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), - gfx::Point(10, 10), 0, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&mouse1); EXPECT_FALSE(recorder.events().empty()); recorder.Reset(); // Dispatch a synthetic mouse event when mouse events are enabled. ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), - gfx::Point(10, 10), ui::EF_IS_SYNTHESIZED, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), + ui::EF_IS_SYNTHESIZED, 0); DispatchEventUsingWindowDispatcher(&mouse2); EXPECT_FALSE(recorder.events().empty()); recorder.Reset(); @@ -1003,8 +1005,8 @@ TEST_F(WindowEventDispatcherTest, DoNotSynthesizeWhileButtonDown) { window->AddPreTargetHandler(&recorder); // Dispatch a non-synthetic mouse event when mouse events are enabled. ui::MouseEvent mouse1(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), - gfx::Point(10, 10), ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + gfx::Point(10, 10), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); DispatchEventUsingWindowDispatcher(&mouse1); ASSERT_EQ(1u, recorder.events().size()); EXPECT_EQ(ui::ET_MOUSE_PRESSED, recorder.events()[0]); @@ -1043,7 +1045,7 @@ TEST_F(WindowEventDispatcherTest, // Dispatch a non-synthetic mouse event to place cursor inside window bounds. ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), - gfx::Point(10, 10), 0, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&mouse); EXPECT_FALSE(recorder.events().empty()); recorder.Reset(); @@ -1097,8 +1099,8 @@ TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenCursorHidden) { // Dispatch a mouse move event into the window. gfx::Point mouse_location(gfx::Point(15, 25)); - ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, mouse_location, - mouse_location, 0, 0); + ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, mouse_location, mouse_location, + ui::EventTimeForNow(), 0, 0); EXPECT_TRUE(recorder.events().empty()); DispatchEventUsingWindowDispatcher(&mouse1); EXPECT_FALSE(recorder.events().empty()); @@ -1134,8 +1136,8 @@ TEST_F(WindowEventDispatcherTest, // Dispatch a mouse move event into the window. gfx::Point mouse_location(gfx::Point(15, 25)); - ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, mouse_location, - mouse_location, 0, 0); + ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, mouse_location, mouse_location, + ui::EventTimeForNow(), 0, 0); EXPECT_TRUE(recorder.events().empty()); DispatchEventUsingWindowDispatcher(&mouse1); EXPECT_FALSE(recorder.events().empty()); @@ -1146,7 +1148,8 @@ TEST_F(WindowEventDispatcherTest, gfx::Point mouse_exit_location(gfx::Point(150, 150)); ui::MouseEvent mouse2(ui::ET_MOUSE_EXITED, gfx::Point(150, 150), - gfx::Point(150, 150), ui::EF_IS_SYNTHESIZED, 0); + gfx::Point(150, 150), ui::EventTimeForNow(), + ui::EF_IS_SYNTHESIZED, 0); DispatchEventUsingWindowDispatcher(&mouse2); EXPECT_FALSE(recorder.events().empty()); @@ -1629,8 +1632,8 @@ class DontResetHeldEventWindowDelegate : public test::TestWindowDelegate { void OnMouseEvent(ui::MouseEvent* event) override { if ((event->flags() & ui::EF_SHIFT_DOWN) != 0 && mouse_event_count_++ == 0) { - ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, - gfx::Point(10, 10), gfx::Point(10, 10), + ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), + gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_SHIFT_DOWN, 0); root_->GetHost()->dispatcher()->RepostEvent(mouse_event); } @@ -1654,12 +1657,12 @@ TEST_F(WindowEventDispatcherTest, DontResetHeldEvent) { DontResetHeldEventWindowDelegate delegate(root_window()); scoped_ptr w1(CreateNormalWindow(1, root_window(), &delegate)); w1->SetBounds(gfx::Rect(0, 0, 40, 40)); - ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, - gfx::Point(10, 10), gfx::Point(10, 10), + ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), + gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_SHIFT_DOWN, 0); root_window()->GetHost()->dispatcher()->RepostEvent(pressed); - ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED, - gfx::Point(10, 10), gfx::Point(10, 10), 0, 0); + ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); // Dispatch an event to flush event scheduled by way of RepostEvent(). DispatchEventUsingWindowDispatcher(&pressed2); // Delegate should have seen reposted event (identified by way of @@ -1715,8 +1718,8 @@ TEST_F(WindowEventDispatcherTest, DeleteHostFromHeldMouseEvent) { // Owned by |h2|. Window* w1 = CreateNormalWindow(1, h2->window(), &delegate); w1->SetBounds(gfx::Rect(0, 0, 40, 40)); - ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, - gfx::Point(10, 10), gfx::Point(10, 10), + ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), + gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_SHIFT_DOWN, 0); h2->dispatcher()->RepostEvent(pressed); // RunAllPendingInMessageLoop() to make sure the |pressed| is run. @@ -1919,11 +1922,9 @@ class WindowEventDispatcherTestWithMessageLoop // Start a nested message-loop, post an event to be dispatched, and then // terminate the message-loop. When the message-loop unwinds and gets back, // the reposted event should not have fired. - scoped_ptr mouse(new ui::MouseEvent(ui::ET_MOUSE_PRESSED, - gfx::Point(10, 10), - gfx::Point(10, 10), - ui::EF_NONE, - ui::EF_NONE)); + scoped_ptr mouse(new ui::MouseEvent( + ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10), + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE)); message_loop()->PostTask( FROM_HERE, base::Bind(&WindowEventDispatcherTestWithMessageLoop::RepostEventHelper, @@ -2008,18 +2009,18 @@ TEST_F(WindowEventDispatcherTestInHighDPI, EventLocationTransform) { child->AddPreTargetHandler(&handler_child); { - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(30, 30), gfx::Point(30, 30), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(30, 30), + gfx::Point(30, 30), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); DispatchEventUsingWindowDispatcher(&move); EXPECT_EQ(0, handler_child.num_mouse_events()); EXPECT_EQ(1, handler_root.num_mouse_events()); } { - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - gfx::Point(50, 50), gfx::Point(50, 50), - ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), + gfx::Point(50, 50), ui::EventTimeForNow(), ui::EF_NONE, + ui::EF_NONE); DispatchEventUsingWindowDispatcher(&move); // The child receives an ENTER, and a MOVED event. EXPECT_EQ(2, handler_child.num_mouse_events()); @@ -2108,16 +2109,18 @@ TEST_F(WindowEventDispatcherTestInHighDPI, RunAllPendingInMessageLoop(); ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::Point(80, 80), - gfx::Point(80, 80), ui::EF_NONE, ui::EF_NONE); + gfx::Point(80, 80), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); const base::Closure callback_on_right_click = base::Bind( base::IgnoreResult(&WindowEventDispatcherTestInHighDPI::DispatchEvent), base::Unretained(this), base::Unretained(&mouse_move)); TriggerNestedLoopOnRightMousePress handler(callback_on_right_click); window->AddPreTargetHandler(&handler); - scoped_ptr mouse(new ui::MouseEvent( - ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10), - ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); + scoped_ptr mouse( + new ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), + gfx::Point(10, 10), ui::EventTimeForNow(), + ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); host()->dispatcher()->RepostEvent(*mouse); EXPECT_EQ(0, handler.num_mouse_events()); @@ -2157,7 +2160,7 @@ TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) { // Synthesized event should not update the mouse location. ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), - ui::EF_IS_SYNTHESIZED, 0); + ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0); generator.Dispatch(&mouseev); EXPECT_EQ("10,10", Env::GetInstance()->last_mouse_location().ToString()); @@ -2252,7 +2255,8 @@ class DispatchEventHandler : public ui::EventHandler { void OnMouseEvent(ui::MouseEvent* mouse) override { if (mouse->type() == ui::ET_MOUSE_MOVED) { ui::MouseEvent move(ui::ET_MOUSE_MOVED, target_->bounds().CenterPoint(), - target_->bounds().CenterPoint(), ui::EF_NONE, ui::EF_NONE); + target_->bounds().CenterPoint(), + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); ui::EventDispatchDetails details = target_->GetHost()->dispatcher()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -2325,7 +2329,8 @@ TEST_F(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) { // Dispatch an event to |first|. ui::MouseEvent move(ui::ET_MOUSE_MOVED, first->bounds().CenterPoint(), - first->bounds().CenterPoint(), ui::EF_NONE, ui::EF_NONE); + first->bounds().CenterPoint(), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); ui::EventDispatchDetails details = host()->dispatcher()->OnEventFromSource(&move); ASSERT_FALSE(details.dispatcher_destroyed); @@ -2422,8 +2427,8 @@ TEST_F(WindowEventDispatcherTest, EventFilterRecorder recorder_second; window_second->AddPreTargetHandler(&recorder_second); const gfx::Point event_location(25, 15); - ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, event_location, - event_location, ui::EF_LEFT_MOUSE_BUTTON, + ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, event_location, event_location, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); DispatchEventUsingWindowDispatcher(&mouse); EXPECT_TRUE(recorder_first.events().empty()); diff --git a/ui/aura/window_targeter_unittest.cc b/ui/aura/window_targeter_unittest.cc index 922b021117f8bf..02217271a16df5 100644 --- a/ui/aura/window_targeter_unittest.cc +++ b/ui/aura/window_targeter_unittest.cc @@ -8,6 +8,7 @@ #include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/test_window_delegate.h" #include "ui/aura/window.h" +#include "ui/events/event_utils.h" #include "ui/events/test/test_event_handler.h" namespace aura { @@ -66,10 +67,8 @@ TEST_F(WindowTargeterTest, Basic) { ui::test::TestEventHandler handler; one->AddPreTargetHandler(&handler); - ui::MouseEvent press(ui::ET_MOUSE_PRESSED, - gfx::Point(20, 20), - gfx::Point(20, 20), - ui::EF_NONE, + ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(20, 20), + gfx::Point(20, 20), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); DispatchEventUsingWindowDispatcher(&press); EXPECT_EQ(1, handler.num_mouse_events()); @@ -96,7 +95,7 @@ TEST_F(WindowTargeterTest, ScopedWindowTargeter) { gfx::Point event_location(60, 60); { ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(child, targeter->FindTargetForEvent(root, &mouse)); } @@ -106,13 +105,13 @@ TEST_F(WindowTargeterTest, ScopedWindowTargeter) { new StaticWindowTargeter(window.get())))); { ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root, &mouse)); } scoped_targeter.reset(); { ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(child, targeter->FindTargetForEvent(root, &mouse)); } } @@ -146,7 +145,7 @@ TEST_F(WindowTargeterTest, TargetTransformedWindow) { gfx::Point event_location(490, 50); { ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &mouse)); } @@ -159,7 +158,7 @@ TEST_F(WindowTargeterTest, TargetTransformedWindow) { GetEffectiveVisibleBoundsInRootWindow(window.get()).ToString()); { ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(root_window(), targeter->FindTargetForEvent(root_target, &mouse)); } @@ -171,7 +170,7 @@ TEST_F(WindowTargeterTest, TargetTransformedWindow) { GetEffectiveVisibleBoundsInRootWindow(window.get()).ToString()); { ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &mouse)); } } diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 9ae01ff7dec08a..fd7ed661229e85 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -1255,8 +1255,8 @@ TEST_F(WindowTest, WindowTreeHostExit) { EXPECT_FALSE(d1.exited()); d1.ResetExpectations(); - ui::MouseEvent exit_event( - ui::ET_MOUSE_EXITED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent exit_event(ui::ET_MOUSE_EXITED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&exit_event); EXPECT_FALSE(d1.entered()); EXPECT_TRUE(d1.exited()); diff --git a/ui/base/user_activity/user_activity_detector_unittest.cc b/ui/base/user_activity/user_activity_detector_unittest.cc index de763138299ada..dc4cbae20ce757 100644 --- a/ui/base/user_activity/user_activity_detector_unittest.cc +++ b/ui/base/user_activity/user_activity_detector_unittest.cc @@ -11,6 +11,7 @@ #include "ui/base/user_activity/user_activity_observer.h" #include "ui/events/event.h" #include "ui/events/event_constants.h" +#include "ui/events/event_utils.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/gfx/geometry/point.h" @@ -79,8 +80,8 @@ TEST_F(UserActivityDetectorTest, Basic) { base::TimeDelta advance_delta = base::TimeDelta::FromMilliseconds( UserActivityDetector::kNotifyIntervalMs); AdvanceTime(advance_delta); - ui::MouseEvent mouse_event( - ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); detector_->OnMouseEvent(&mouse_event); EXPECT_FALSE(mouse_event.handled()); EXPECT_EQ(now_.ToInternalValue(), @@ -181,9 +182,9 @@ TEST_F(UserActivityDetectorTest, RateLimitNotifications) { // Checks that the detector ignores synthetic mouse events. TEST_F(UserActivityDetectorTest, IgnoreSyntheticMouseEvents) { - ui::MouseEvent mouse_event( - ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED, - ui::EF_NONE); + ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, + ui::EF_NONE); detector_->OnMouseEvent(&mouse_event); EXPECT_FALSE(mouse_event.handled()); EXPECT_EQ(base::TimeTicks().ToInternalValue(), diff --git a/ui/chromeos/touch_exploration_controller.cc b/ui/chromeos/touch_exploration_controller.cc index 695142d91d4b25..00b234cf450ca1 100644 --- a/ui/chromeos/touch_exploration_controller.cc +++ b/ui/chromeos/touch_exploration_controller.cc @@ -986,8 +986,8 @@ scoped_ptr TouchExplorationController::CreateMouseMoveEvent( // event to the new ChromeVox background page via the automation api. flags |= ui::EF_COMMAND_DOWN; - return scoped_ptr( - new ui::MouseEvent(ui::ET_MOUSE_MOVED, location, location, flags, 0)); + return scoped_ptr(new ui::MouseEvent( + ui::ET_MOUSE_MOVED, location, location, ui::EventTimeForNow(), flags, 0)); } void TouchExplorationController::EnterTouchToMouseMode() { diff --git a/ui/chromeos/touch_exploration_controller_unittest.cc b/ui/chromeos/touch_exploration_controller_unittest.cc index 052b52739a9a1a..1b7faf552a078a 100644 --- a/ui/chromeos/touch_exploration_controller_unittest.cc +++ b/ui/chromeos/touch_exploration_controller_unittest.cc @@ -542,10 +542,8 @@ TEST_F(TouchExplorationTest, ActualMouseMovesUnaffected) { generator_->MoveTouch(location_end); gfx::Point location_real_mouse_move(15, 16); - ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, - location_real_mouse_move, - location_real_mouse_move, - 0, + ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, location_real_mouse_move, + location_real_mouse_move, ui::EventTimeForNow(), 0, 0); generator_->Dispatch(&mouse_move); generator_->ReleaseTouch(); diff --git a/ui/events/event.cc b/ui/events/event.cc index c26b9c97b77487..166a8bd1d18d48 100644 --- a/ui/events/event.cc +++ b/ui/events/event.cc @@ -330,9 +330,10 @@ MouseEvent::MouseEvent(const base::NativeEvent& native_event) MouseEvent::MouseEvent(EventType type, const gfx::PointF& location, const gfx::PointF& root_location, + base::TimeDelta time_stamp, int flags, int changed_button_flags) - : LocatedEvent(type, location, root_location, EventTimeForNow(), flags), + : LocatedEvent(type, location, root_location, time_stamp, flags), changed_button_flags_(changed_button_flags) { if (this->type() == ET_MOUSE_MOVED && IsAnyButton()) SetType(ET_MOUSE_DRAGGED); @@ -485,7 +486,11 @@ MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset, const gfx::PointF& root_location, int flags, int changed_button_flags) - : MouseEvent(ui::ET_MOUSEWHEEL, location, root_location, flags, + : MouseEvent(ui::ET_MOUSEWHEEL, + location, + root_location, + EventTimeForNow(), + flags, changed_button_flags), offset_(offset) { } @@ -946,13 +951,12 @@ ScrollEvent::ScrollEvent(EventType type, float x_offset_ordinal, float y_offset_ordinal, int finger_count) - : MouseEvent(type, location, location, flags, 0), + : MouseEvent(type, location, location, time_stamp, flags, 0), x_offset_(x_offset), y_offset_(y_offset), x_offset_ordinal_(x_offset_ordinal), y_offset_ordinal_(y_offset_ordinal), finger_count_(finger_count) { - set_time_stamp(time_stamp); CHECK(IsScrollEvent()); } diff --git a/ui/events/event.h b/ui/events/event.h index ac2e5b5939af2d..28a19104af9065 100644 --- a/ui/events/event.h +++ b/ui/events/event.h @@ -351,10 +351,11 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent { set_flags(flags); } - // Used for synthetic events in testing and by the gesture recognizer. + // Used for synthetic events in testing, gesture recognizer and Ozone MouseEvent(EventType type, const gfx::PointF& location, const gfx::PointF& root_location, + base::TimeDelta time_stamp, int flags, int changed_button_flags); diff --git a/ui/events/event_dispatcher_unittest.cc b/ui/events/event_dispatcher_unittest.cc index 95b45a3071d24f..0bae34e81918f4 100644 --- a/ui/events/event_dispatcher_unittest.cc +++ b/ui/events/event_dispatcher_unittest.cc @@ -247,8 +247,8 @@ TEST(EventDispatcherTest, EventDispatchOrder) { h7.set_expect_post_target(true); h8.set_expect_post_target(true); - MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), - gfx::Point(3, 4), 0, 0); + MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), gfx::Point(3, 4), + ui::EventTimeForNow(), 0, 0); Event::DispatcherApi event_mod(&mouse); dispatcher.ProcessEvent(&child, &mouse); EXPECT_FALSE(mouse.stopped_propagation()); @@ -321,8 +321,8 @@ TEST(EventDispatcherTest, EventDispatchPhase) { handler.set_expect_pre_target(true); handler.set_expect_post_target(true); - MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), - gfx::Point(3, 4), 0, 0); + MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), gfx::Point(3, 4), + ui::EventTimeForNow(), 0, 0); Event::DispatcherApi event_mod(&mouse); dispatcher.ProcessEvent(&target, &mouse); EXPECT_EQ(ER_UNHANDLED, mouse.result()); @@ -353,8 +353,8 @@ TEST(EventDispatcherTest, EventDispatcherDestroyedDuringDispatch) { // destroyed the dispatcher. h2.set_expect_pre_target(false); - MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), - gfx::Point(3, 4), 0, 0); + MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), gfx::Point(3, 4), + ui::EventTimeForNow(), 0, 0); EventDispatchDetails details = dispatcher->ProcessEvent(&target, &mouse); EXPECT_TRUE(details.dispatcher_destroyed); EXPECT_EQ(ER_CONSUMED, mouse.result()); @@ -405,8 +405,8 @@ TEST(EventDispatcherTest, EventDispatcherDestroyedDuringDispatch) { // destroyed the dispatcher. h2.set_expect_post_target(false); - MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), - gfx::Point(3, 4), 0, 0); + MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), gfx::Point(3, 4), + ui::EventTimeForNow(), 0, 0); EventDispatchDetails details = dispatcher->ProcessEvent(&target, &mouse); EXPECT_TRUE(details.dispatcher_destroyed); EXPECT_EQ(ER_CONSUMED, mouse.result()); @@ -459,8 +459,8 @@ TEST(EventDispatcherTest, EventDispatcherInvalidateTarget) { // |h3| should not receive events as the target will be invalidated. h3.set_expect_pre_target(false); - MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), gfx::Point(3, 4), 0, - 0); + MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), gfx::Point(3, 4), + ui::EventTimeForNow(), 0, 0); EventDispatchDetails details = dispatcher.ProcessEvent(&target, &mouse); EXPECT_FALSE(details.dispatcher_destroyed); EXPECT_TRUE(details.target_destroyed); @@ -502,8 +502,8 @@ TEST(EventDispatcherTest, EventHandlerDestroyedDuringDispatch) { // destroyed it. h3->set_expect_pre_target(false); - MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), gfx::Point(3, 4), 0, - 0); + MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), gfx::Point(3, 4), + ui::EventTimeForNow(), 0, 0); EventDispatchDetails details = dispatcher.ProcessEvent(&target, &mouse); EXPECT_FALSE(details.dispatcher_destroyed); EXPECT_FALSE(details.target_destroyed); @@ -560,8 +560,8 @@ TEST(EventDispatcherTest, EventHandlerAndDispatcherDestroyedDuringDispatch) { // it. h3->set_expect_pre_target(false); - MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), gfx::Point(3, 4), 0, - 0); + MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(3, 4), gfx::Point(3, 4), + ui::EventTimeForNow(), 0, 0); EventDispatchDetails details = dispatcher->ProcessEvent(&target, &mouse); EXPECT_TRUE(details.dispatcher_destroyed); EXPECT_TRUE(mouse.stopped_propagation()); diff --git a/ui/events/event_processor_unittest.cc b/ui/events/event_processor_unittest.cc index 7170aa0cd22ed1..56c205cdae24e0 100644 --- a/ui/events/event_processor_unittest.cc +++ b/ui/events/event_processor_unittest.cc @@ -7,6 +7,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/events/event.h" #include "ui/events/event_targeter.h" +#include "ui/events/event_utils.h" #include "ui/events/test/events_test_utils.h" #include "ui/events/test/test_event_handler.h" #include "ui/events/test/test_event_processor.h" @@ -52,7 +53,7 @@ TEST_F(EventProcessorTest, Basic) { root()->AddChild(child.Pass()); MouseEvent mouse(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), - EF_NONE, EF_NONE); + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&mouse); EXPECT_TRUE(root()->child_at(0)->DidReceiveEvent(ET_MOUSE_MOVED)); EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); @@ -140,8 +141,8 @@ TEST_F(EventProcessorTest, Bounds) { // Dispatch a mouse event that falls on the parent, but not on the child. When // the default event-targeter used, the event will still reach |grandchild|, // because the default targeter does not look at the bounds. - MouseEvent mouse(ET_MOUSE_MOVED, gfx::Point(1, 1), gfx::Point(1, 1), EF_NONE, - EF_NONE); + MouseEvent mouse(ET_MOUSE_MOVED, gfx::Point(1, 1), gfx::Point(1, 1), + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&mouse); EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); EXPECT_FALSE(parent_r->DidReceiveEvent(ET_MOUSE_MOVED)); @@ -152,8 +153,8 @@ TEST_F(EventProcessorTest, Bounds) { // Now install a targeter on the parent that looks at the bounds and makes // sure the event reaches the target only if the location of the event within // the bounds of the target. - MouseEvent mouse2(ET_MOUSE_MOVED, gfx::Point(1, 1), gfx::Point(1, 1), EF_NONE, - EF_NONE); + MouseEvent mouse2(ET_MOUSE_MOVED, gfx::Point(1, 1), gfx::Point(1, 1), + EventTimeForNow(), EF_NONE, EF_NONE); parent_r->SetEventTargeter(scoped_ptr( new BoundsEventTargeter())); DispatchEvent(&mouse2); @@ -164,7 +165,7 @@ TEST_F(EventProcessorTest, Bounds) { parent_r->ResetReceivedEvents(); MouseEvent second(ET_MOUSE_MOVED, gfx::Point(12, 12), gfx::Point(12, 12), - EF_NONE, EF_NONE); + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&second); EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); EXPECT_FALSE(parent_r->DidReceiveEvent(ET_MOUSE_MOVED)); @@ -238,8 +239,8 @@ TEST_F(EventProcessorTest, NestedEventProcessing) { // Dispatch a mouse event to the tree of event targets owned by the first // event processor, checking in ReDispatchEventHandler that the phase and // target information of the event is correct. - MouseEvent mouse( - ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), EF_NONE, EF_NONE); + MouseEvent mouse(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&mouse); // Verify also that |mouse| was seen by the child nodes contained in both @@ -253,8 +254,8 @@ TEST_F(EventProcessorTest, NestedEventProcessing) { // Indicate that the child of the second root should handle events, and // dispatch another mouse event to verify that it is marked as handled. second_root->child_at(0)->set_mark_events_as_handled(true); - MouseEvent mouse2( - ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), EF_NONE, EF_NONE); + MouseEvent mouse2(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&mouse2); EXPECT_TRUE(root()->child_at(0)->DidReceiveEvent(ET_MOUSE_MOVED)); EXPECT_TRUE(second_root->child_at(0)->DidReceiveEvent(ET_MOUSE_MOVED)); @@ -271,7 +272,7 @@ TEST_F(EventProcessorTest, OnEventProcessingFinished) { // Dispatch a mouse event. We expect the event to be seen by the target, // handled, and we expect OnEventProcessingFinished() to be invoked once. MouseEvent mouse(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), - EF_NONE, EF_NONE); + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&mouse); EXPECT_TRUE(root()->child_at(0)->DidReceiveEvent(ET_MOUSE_MOVED)); EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); @@ -291,8 +292,8 @@ TEST_F(EventProcessorTest, OnEventProcessingStarted) { // OnEventProcessingStarted() should be called once, and // OnEventProcessingFinished() should be called once. The event should // remain unhandled. - MouseEvent mouse( - ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), EF_NONE, EF_NONE); + MouseEvent mouse(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&mouse); EXPECT_TRUE(root()->child_at(0)->DidReceiveEvent(ET_MOUSE_MOVED)); EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); @@ -308,8 +309,8 @@ TEST_F(EventProcessorTest, OnEventProcessingStarted) { // seen by the target this time, but OnEventProcessingStarted() and // OnEventProcessingFinished() should both still be called once. processor()->set_should_processing_occur(false); - MouseEvent mouse2( - ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), EF_NONE, EF_NONE); + MouseEvent mouse2(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&mouse2); EXPECT_FALSE(root()->child_at(0)->DidReceiveEvent(ET_MOUSE_MOVED)); EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); @@ -338,7 +339,7 @@ TEST_F(EventProcessorTest, TargeterChecksOwningEventTarget) { root()->AddChild(child.Pass()); MouseEvent mouse(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), - EF_NONE, EF_NONE); + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&mouse); EXPECT_TRUE(root()->child_at(0)->DidReceiveEvent(ET_MOUSE_MOVED)); EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); @@ -349,7 +350,7 @@ TEST_F(EventProcessorTest, TargeterChecksOwningEventTarget) { root()->child_at(0)->SetEventTargeter( scoped_ptr(new IgnoreEventTargeter())); MouseEvent mouse2(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), - EF_NONE, EF_NONE); + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&mouse2); EXPECT_FALSE(root()->child_at(0)->DidReceiveEvent(ET_MOUSE_MOVED)); EXPECT_TRUE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); @@ -510,7 +511,7 @@ TEST_F(EventProcessorTest, HandlerSequence) { grandchild_r->AddPostTargetHandler(&post_grandchild); MouseEvent mouse(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10), - EF_NONE, EF_NONE); + EventTimeForNow(), EF_NONE, EF_NONE); DispatchEvent(&mouse); std::string expected[] = { "PreR", "PreC", "PreG", "G", "PostG", "PostC", diff --git a/ui/events/event_unittest.cc b/ui/events/event_unittest.cc index 7e92aa0a9696b3..1b110fe53c7a5a 100644 --- a/ui/events/event_unittest.cc +++ b/ui/events/event_unittest.cc @@ -59,7 +59,7 @@ TEST(EventTest, GetCharacter) { TEST(EventTest, ClickCount) { const gfx::Point origin(0, 0); - MouseEvent mouseev(ET_MOUSE_PRESSED, origin, origin, 0, 0); + MouseEvent mouseev(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), 0, 0); for (int i = 1; i <=3 ; ++i) { mouseev.SetClickCount(i); EXPECT_EQ(i, mouseev.GetClickCount()); @@ -68,8 +68,10 @@ TEST(EventTest, ClickCount) { TEST(EventTest, RepeatedClick) { const gfx::Point origin(0, 0); - MouseEvent mouse_ev1(ET_MOUSE_PRESSED, origin, origin, 0, 0); - MouseEvent mouse_ev2(ET_MOUSE_PRESSED, origin, origin, 0, 0); + MouseEvent mouse_ev1(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), 0, + 0); + MouseEvent mouse_ev2(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), 0, + 0); LocatedEventTestApi test_ev1(&mouse_ev1); LocatedEventTestApi test_ev2(&mouse_ev2); @@ -109,23 +111,29 @@ TEST(EventTest, DoubleClickRequiresRelease) { scoped_ptr ev; base::TimeDelta start = base::TimeDelta::FromMilliseconds(0); - ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, 0, 0)); + ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, EventTimeForNow(), + 0, 0)); ev->set_time_stamp(start); EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); - ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, 0, 0)); + ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, EventTimeForNow(), + 0, 0)); ev->set_time_stamp(start); EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); - ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin2, origin2, 0, 0)); + ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin2, origin2, EventTimeForNow(), + 0, 0)); ev->set_time_stamp(start); EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); - ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin2, origin2, 0, 0)); + ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin2, origin2, + EventTimeForNow(), 0, 0)); ev->set_time_stamp(start); EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); - ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin2, origin2, 0, 0)); + ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin2, origin2, EventTimeForNow(), + 0, 0)); ev->set_time_stamp(start); EXPECT_EQ(2, MouseEvent::GetRepeatCount(*ev)); - ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin2, origin2, 0, 0)); + ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin2, origin2, + EventTimeForNow(), 0, 0)); ev->set_time_stamp(start); EXPECT_EQ(2, MouseEvent::GetRepeatCount(*ev)); MouseEvent::ResetLastClickForTest(); @@ -138,24 +146,21 @@ TEST(EventTest, SingleClickRightLeft) { scoped_ptr ev; base::TimeDelta start = base::TimeDelta::FromMilliseconds(0); - ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin, + ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); ev->set_time_stamp(start); EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); - ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); + ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); ev->set_time_stamp(start); EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); - ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin, origin, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); + ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin, origin, EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); ev->set_time_stamp(start); EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); - ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); + ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); ev->set_time_stamp(start); EXPECT_EQ(2, MouseEvent::GetRepeatCount(*ev)); MouseEvent::ResetLastClickForTest(); diff --git a/ui/events/ozone/evdev/event_factory_evdev.cc b/ui/events/ozone/evdev/event_factory_evdev.cc index 75620ad176fe83..65bf8ade67ae2a 100644 --- a/ui/events/ozone/evdev/event_factory_evdev.cc +++ b/ui/events/ozone/evdev/event_factory_evdev.cc @@ -12,6 +12,7 @@ #include "base/trace_event/trace_event.h" #include "ui/events/devices/device_data_manager.h" #include "ui/events/devices/input_device.h" +#include "ui/events/event_utils.h" #include "ui/events/ozone/device/device_event.h" #include "ui/events/ozone/device/device_manager.h" #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" @@ -153,7 +154,7 @@ void EventFactoryEvdev::DispatchKeyEvent(const KeyEventParams& params) { void EventFactoryEvdev::DispatchMouseMoveEvent( const MouseMoveEventParams& params) { MouseEvent event(ui::ET_MOUSE_MOVED, params.location, params.location, - modifiers_.GetModifierFlags(), + EventTimeForNow(), modifiers_.GetModifierFlags(), /* changed_button_flags */ 0); event.set_source_device_id(params.device_id); DispatchUiEvent(&event); @@ -185,7 +186,7 @@ void EventFactoryEvdev::DispatchMouseButtonEvent( modifiers_.UpdateModifier(modifier, params.down); MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, - params.location, params.location, + params.location, params.location, EventTimeForNow(), modifiers_.GetModifierFlags() | flag, /* changed_button_flags */ flag); event.set_source_device_id(params.device_id); diff --git a/ui/events/test/event_generator.cc b/ui/events/test/event_generator.cc index 9142d5c0c6ed66..f743ba18408f9b 100644 --- a/ui/events/test/event_generator.cc +++ b/ui/events/test/event_generator.cc @@ -144,7 +144,8 @@ void EventGenerator::ReleaseRightButton() { void EventGenerator::MoveMouseWheel(int delta_x, int delta_y) { gfx::Point location = GetLocationInCurrentRoot(); - ui::MouseEvent mouseev(ui::ET_MOUSEWHEEL, location, location, flags_, 0); + ui::MouseEvent mouseev(ui::ET_MOUSEWHEEL, location, location, + ui::EventTimeForNow(), flags_, 0); ui::MouseWheelEvent wheelev(mouseev, delta_x, delta_y); Dispatch(&wheelev); } @@ -153,14 +154,15 @@ void EventGenerator::SendMouseExit() { gfx::Point exit_location(current_location_); delegate()->ConvertPointToTarget(current_target_, &exit_location); ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location, - flags_, 0); + ui::EventTimeForNow(), flags_, 0); Dispatch(&mouseev); } void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) { const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; - ui::MouseEvent mouseev(event_type, point_in_host, point_in_host, flags_, 0); + ui::MouseEvent mouseev(event_type, point_in_host, point_in_host, + ui::EventTimeForNow(), flags_, 0); Dispatch(&mouseev); current_location_ = point_in_host; @@ -181,7 +183,8 @@ void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen, if (!grab_) UpdateCurrentDispatcher(move_point); delegate()->ConvertPointToTarget(current_target_, &move_point); - ui::MouseEvent mouseev(event_type, move_point, move_point, flags_, 0); + ui::MouseEvent mouseev(event_type, move_point, move_point, + ui::EventTimeForNow(), flags_, 0); Dispatch(&mouseev); } current_location_ = point_in_screen; @@ -557,8 +560,8 @@ void EventGenerator::PressButton(int flag) { flags_ |= flag; grab_ = (flags_ & kAllButtonMask) != 0; gfx::Point location = GetLocationInCurrentRoot(); - ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, flags_, - flag); + ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, + ui::EventTimeForNow(), flags_, flag); Dispatch(&mouseev); } } @@ -566,8 +569,8 @@ void EventGenerator::PressButton(int flag) { void EventGenerator::ReleaseButton(int flag) { if (flags_ & flag) { gfx::Point location = GetLocationInCurrentRoot(); - ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location, - location, flags_, flag); + ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location, location, + ui::EventTimeForNow(), flags_, flag); Dispatch(&mouseev); flags_ ^= flag; } diff --git a/ui/keyboard/keyboard_controller_unittest.cc b/ui/keyboard/keyboard_controller_unittest.cc index 7cab3064b6e1c8..fd5b0878434191 100644 --- a/ui/keyboard/keyboard_controller_unittest.cc +++ b/ui/keyboard/keyboard_controller_unittest.cc @@ -26,6 +26,7 @@ #include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/compositor/test/context_factories_for_test.h" #include "ui/compositor/test/layer_animator_test_controller.h" +#include "ui/events/event_utils.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/geometry/rect.h" #include "ui/keyboard/keyboard_controller_observer.h" @@ -337,13 +338,13 @@ TEST_F(KeyboardControllerTest, EventHitTestingInContainer) { ui::EventTarget* root = root_window(); ui::EventTargeter* targeter = root->GetEventTargeter(); gfx::Point location = keyboard_window->bounds().CenterPoint(); - ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, location, location, ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, location, location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(keyboard_window, targeter->FindTargetForEvent(root, &mouse1)); location.set_y(keyboard_window->bounds().y() - 5); - ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, location, location, ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, location, location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root, &mouse2)); } @@ -369,8 +370,8 @@ TEST_F(KeyboardControllerTest, KeyboardWindowCreation) { ui::EventTargeter* targeter = root->GetEventTargeter(); gfx::Point location(root_window()->bounds().width() / 2, root_window()->bounds().height() - 10); - ui::MouseEvent mouse( - ui::ET_MOUSE_MOVED, location, location, ui::EF_NONE, ui::EF_NONE); + ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, location, location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root, &mouse)); EXPECT_FALSE(proxy()->HasKeyboardWindow()); diff --git a/ui/message_center/views/message_popup_collection_unittest.cc b/ui/message_center/views/message_popup_collection_unittest.cc index a1e5594bcc879e..466181b5725b64 100644 --- a/ui/message_center/views/message_popup_collection_unittest.cc +++ b/ui/message_center/views/message_popup_collection_unittest.cc @@ -12,6 +12,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/events/event.h" #include "ui/events/event_constants.h" +#include "ui/events/event_utils.h" #include "ui/gfx/display.h" #include "ui/gfx/geometry/rect.h" #include "ui/message_center/fake_message_center.h" @@ -368,7 +369,8 @@ TEST_F(MessagePopupCollectionTest, DetectMouseHover) { views::WidgetDelegateView* toast1 = GetToast(id1); EXPECT_TRUE(toast1 != NULL); - ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); // Test that mouse detection logic works in presence of out-of-order events. toast0->OnMouseEntered(event); @@ -403,7 +405,8 @@ TEST_F(MessagePopupCollectionTest, DetectMouseHoverWithUserClose) { views::WidgetDelegateView* toast1 = GetToast(id1); ASSERT_TRUE(toast1 != NULL); - ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); toast1->OnMouseEntered(event); static_cast(collection())->OnNotificationRemoved( id1, true); diff --git a/ui/message_center/views/notification_view_unittest.cc b/ui/message_center/views/notification_view_unittest.cc index d4c155b1166ce2..5fdc60f89f6dde 100644 --- a/ui/message_center/views/notification_view_unittest.cc +++ b/ui/message_center/views/notification_view_unittest.cc @@ -8,6 +8,7 @@ #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/events/event_utils.h" #include "ui/gfx/image/image.h" #include "ui/message_center/notification.h" #include "ui/message_center/notification_list.h" @@ -237,11 +238,8 @@ TEST_F(NotificationViewTest, UpdateButtonsStateTest) { gfx::Point cursor_location(1, 1); views::View::ConvertPointToWidget(notification_view()->action_buttons_[0], &cursor_location); - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - cursor_location, - cursor_location, - ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); widget()->OnMouseEvent(&move); EXPECT_EQ(views::CustomButton::STATE_HOVERED, @@ -255,11 +253,8 @@ TEST_F(NotificationViewTest, UpdateButtonsStateTest) { // Now construct a mouse move event 1 pixel outside the boundary of the // widget. cursor_location = gfx::Point(-1, -1); - move = ui::MouseEvent(ui::ET_MOUSE_MOVED, - cursor_location, - cursor_location, - ui::EF_NONE, - ui::EF_NONE); + move = ui::MouseEvent(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); widget()->OnMouseEvent(&move); EXPECT_EQ(views::CustomButton::STATE_NORMAL, @@ -281,11 +276,8 @@ TEST_F(NotificationViewTest, UpdateButtonCountTest) { gfx::Point cursor_location(1, 1); views::View::ConvertPointToWidget(notification_view()->action_buttons_[0], &cursor_location); - ui::MouseEvent move(ui::ET_MOUSE_MOVED, - cursor_location, - cursor_location, - ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); widget()->OnMouseEvent(&move); EXPECT_EQ(views::CustomButton::STATE_HOVERED, @@ -303,11 +295,8 @@ TEST_F(NotificationViewTest, UpdateButtonCountTest) { // Now construct a mouse move event 1 pixel outside the boundary of the // widget. cursor_location = gfx::Point(-1, -1); - move = ui::MouseEvent(ui::ET_MOUSE_MOVED, - cursor_location, - cursor_location, - ui::EF_NONE, - ui::EF_NONE); + move = ui::MouseEvent(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); widget()->OnMouseEvent(&move); EXPECT_EQ(views::CustomButton::STATE_NORMAL, diff --git a/ui/message_center/views/notifier_settings_view.cc b/ui/message_center/views/notifier_settings_view.cc index 21f3fdf42a8196..0ffc8fc699c793 100644 --- a/ui/message_center/views/notifier_settings_view.cc +++ b/ui/message_center/views/notifier_settings_view.cc @@ -14,6 +14,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/simple_menu_model.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/events/event_utils.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/size.h" @@ -371,9 +372,9 @@ void NotifierSettingsView::NotifierButton::SendLearnMorePressedForTest() { if (learn_more_ == NULL) return; gfx::Point point(110, 120); - ui::MouseEvent pressed( - ui::ET_MOUSE_PRESSED, point, point, ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); ButtonPressed(learn_more_, pressed); } diff --git a/ui/views/accessibility/ax_view_obj_wrapper.cc b/ui/views/accessibility/ax_view_obj_wrapper.cc index 38876d50a28ba0..8c9d3bcbae58cb 100644 --- a/ui/views/accessibility/ax_view_obj_wrapper.cc +++ b/ui/views/accessibility/ax_view_obj_wrapper.cc @@ -7,6 +7,7 @@ #include "base/strings/utf_string_conversions.h" #include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_view_state.h" +#include "ui/events/event_utils.h" #include "ui/views/accessibility/ax_aura_obj_cache.h" #include "ui/views/view.h" #include "ui/views/widget/widget.h" @@ -77,9 +78,9 @@ int32 AXViewObjWrapper::GetID() { void AXViewObjWrapper::DoDefault() { gfx::Rect rect = view_->GetBoundsInScreen(); gfx::Point center = rect.CenterPoint(); - view_->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, center, center, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); + view_->OnMousePressed(ui::MouseEvent( + ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); } void AXViewObjWrapper::Focus() { diff --git a/ui/views/bubble/bubble_window_targeter_unittest.cc b/ui/views/bubble/bubble_window_targeter_unittest.cc index be39081fa14436..103cc3d283199a 100644 --- a/ui/views/bubble/bubble_window_targeter_unittest.cc +++ b/ui/views/bubble/bubble_window_targeter_unittest.cc @@ -6,6 +6,7 @@ #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" +#include "ui/events/event_utils.h" #include "ui/views/bubble/bubble_border.h" #include "ui/views/bubble/bubble_delegate.h" #include "ui/views/test/views_test_base.h" @@ -93,13 +94,15 @@ TEST_F(BubbleWindowTargeterTest, HitTest) { { bubble_delegate()->set_margins(gfx::Insets()); ui::MouseEvent move1(ui::ET_MOUSE_MOVED, bubble_bounds.origin(), - bubble_bounds.origin(), ui::EF_NONE, ui::EF_NONE); + bubble_bounds.origin(), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(bubble_window, targeter->FindTargetForEvent(root, &move1)); } { bubble_delegate()->set_margins(gfx::Insets(20, 20, 20, 20)); ui::MouseEvent move1(ui::ET_MOUSE_MOVED, bubble_bounds.origin(), - bubble_bounds.origin(), ui::EF_NONE, ui::EF_NONE); + bubble_bounds.origin(), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(bubble_window, targeter->FindTargetForEvent(root, &move1)); } @@ -108,7 +111,8 @@ TEST_F(BubbleWindowTargeterTest, HitTest) { { bubble_delegate()->set_margins(gfx::Insets(20, 20, 20, 20)); ui::MouseEvent move1(ui::ET_MOUSE_MOVED, bubble_bounds.origin(), - bubble_bounds.origin(), ui::EF_NONE, ui::EF_NONE); + bubble_bounds.origin(), ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); EXPECT_NE(bubble_window, targeter->FindTargetForEvent(root, &move1)); } } diff --git a/ui/views/controls/button/custom_button.cc b/ui/views/controls/button/custom_button.cc index d9db86712a2f3c..0fa08f09be44b1 100644 --- a/ui/views/controls/button/custom_button.cc +++ b/ui/views/controls/button/custom_button.cc @@ -6,6 +6,7 @@ #include "ui/accessibility/ax_view_state.h" #include "ui/events/event.h" +#include "ui/events/event_utils.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/gfx/animation/throb_animation.h" #include "ui/gfx/screen.h" @@ -192,9 +193,8 @@ bool CustomButton::OnKeyPressed(const ui::KeyEvent& event) { } else if (event.key_code() == ui::VKEY_RETURN) { SetState(STATE_NORMAL); // TODO(beng): remove once NotifyClick takes ui::Event. - ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, - gfx::Point(), - gfx::Point(), + ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, gfx::Point(), + gfx::Point(), ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); NotifyClick(synthetic_event); @@ -210,11 +210,9 @@ bool CustomButton::OnKeyReleased(const ui::KeyEvent& event) { SetState(STATE_NORMAL); // TODO(beng): remove once NotifyClick takes ui::Event. - ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, - gfx::Point(), - gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent synthetic_event( + ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); NotifyClick(synthetic_event); return true; } @@ -251,11 +249,9 @@ void CustomButton::OnGestureEvent(ui::GestureEvent* event) { bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) { SetState(STATE_NORMAL); // TODO(beng): remove once NotifyClick takes ui::Event. - ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, - gfx::Point(), - gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent synthetic_event( + ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); NotifyClick(synthetic_event); return true; } diff --git a/ui/views/controls/button/custom_button_unittest.cc b/ui/views/controls/button/custom_button_unittest.cc index 69d71873cb8d79..70841f982baa44 100644 --- a/ui/views/controls/button/custom_button_unittest.cc +++ b/ui/views/controls/button/custom_button_unittest.cc @@ -9,6 +9,7 @@ #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/base/layout.h" +#include "ui/events/event_utils.h" #include "ui/gfx/screen.h" #include "ui/views/controls/button/checkbox.h" #include "ui/views/controls/button/image_button.h" @@ -71,14 +72,14 @@ TEST_F(CustomButtonTest, HoverStateOnVisibilityChange) { widget->SetContentsView(button); gfx::Point center(10, 10); - button->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, center, center, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); + button->OnMousePressed(ui::MouseEvent( + ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); EXPECT_EQ(CustomButton::STATE_PRESSED, button->state()); - button->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED, center, center, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)); + button->OnMouseReleased(ui::MouseEvent( + ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); EXPECT_EQ(CustomButton::STATE_HOVERED, button->state()); button->SetEnabled(false); diff --git a/ui/views/controls/button/radio_button.cc b/ui/views/controls/button/radio_button.cc index e92b06af402431..9ad665ebd7f925 100644 --- a/ui/views/controls/button/radio_button.cc +++ b/ui/views/controls/button/radio_button.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "ui/accessibility/ax_view_state.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/events/event_utils.h" #include "ui/resources/grit/ui_resources.h" #include "ui/views/widget/widget.h" @@ -123,7 +124,8 @@ bool RadioButton::IsGroupFocusTraversable() const { void RadioButton::OnFocus() { Checkbox::OnFocus(); SetChecked(true); - ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), 0, 0); + ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); LabelButton::NotifyClick(event); } diff --git a/ui/views/controls/combobox/combobox_unittest.cc b/ui/views/controls/combobox/combobox_unittest.cc index 65ca154a029c20..c81160362cdfbf 100644 --- a/ui/views/controls/combobox/combobox_unittest.cc +++ b/ui/views/controls/combobox/combobox_unittest.cc @@ -12,6 +12,7 @@ #include "ui/base/models/combobox_model.h" #include "ui/events/event.h" #include "ui/events/event_constants.h" +#include "ui/events/event_utils.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/views/controls/combobox/combobox_listener.h" #include "ui/views/controls/menu/menu_runner.h" @@ -248,15 +249,13 @@ class ComboboxTest : public ViewsTestBase { } void PerformClick(const gfx::Point& point) { - ui::MouseEvent pressed_event = ui::MouseEvent(ui::ET_MOUSE_PRESSED, point, - point, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent pressed_event = ui::MouseEvent( + ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); widget_->OnMouseEvent(&pressed_event); - ui::MouseEvent released_event = ui::MouseEvent(ui::ET_MOUSE_RELEASED, point, - point, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent released_event = ui::MouseEvent( + ui::ET_MOUSE_RELEASED, point, point, ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); widget_->OnMouseEvent(&released_event); } diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index b74ddce7d065ec..7e77b13d8e98c6 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -2212,15 +2212,14 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source, gfx::Point target_point(target_menu_loc); View::ConvertPointToTarget( target_menu, active_mouse_view, &target_point); - ui::MouseEvent mouse_entered_event(ui::ET_MOUSE_ENTERED, - target_point, target_point, - 0, 0); + ui::MouseEvent mouse_entered_event(ui::ET_MOUSE_ENTERED, target_point, + target_point, ui::EventTimeForNow(), 0, + 0); active_mouse_view->OnMouseEntered(mouse_entered_event); - ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, - target_point, target_point, - event.flags(), - event.changed_button_flags()); + ui::MouseEvent mouse_pressed_event( + ui::ET_MOUSE_PRESSED, target_point, target_point, + ui::EventTimeForNow(), event.flags(), event.changed_button_flags()); active_mouse_view->OnMousePressed(mouse_pressed_event); } } @@ -2228,10 +2227,9 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source, if (active_mouse_view) { gfx::Point target_point(target_menu_loc); View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point); - ui::MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, - target_point, target_point, - event.flags(), - event.changed_button_flags()); + ui::MouseEvent mouse_dragged_event( + ui::ET_MOUSE_DRAGGED, target_point, target_point, ui::EventTimeForNow(), + event.flags(), event.changed_button_flags()); active_mouse_view->OnMouseDragged(mouse_dragged_event); } } @@ -2247,7 +2245,8 @@ void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, &target_loc); View::ConvertPointFromScreen(active_mouse_view, &target_loc); ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, target_loc, target_loc, - event.flags(), event.changed_button_flags()); + ui::EventTimeForNow(), event.flags(), + event.changed_button_flags()); // Reset active mouse view before sending mouse released. That way if it calls // back to us, we aren't in a weird state. SetActiveMouseView(NULL); diff --git a/ui/views/controls/native/native_view_host_aura_unittest.cc b/ui/views/controls/native/native_view_host_aura_unittest.cc index 7f14bd47460b98..5f03fc86ee3771 100644 --- a/ui/views/controls/native/native_view_host_aura_unittest.cc +++ b/ui/views/controls/native/native_view_host_aura_unittest.cc @@ -9,6 +9,7 @@ #include "ui/aura/client/aura_constants.h" #include "ui/aura/window.h" #include "ui/base/cursor/cursor.h" +#include "ui/events/event_utils.h" #include "ui/views/controls/native/native_view_host.h" #include "ui/views/controls/native/native_view_host_test_base.h" #include "ui/views/view.h" @@ -147,7 +148,7 @@ TEST_F(NativeViewHostAuraTest, CursorForNativeView) { toplevel()->SetCursor(ui::kCursorHand); child()->SetCursor(ui::kCursorWait); ui::MouseEvent move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0), - gfx::Point(0, 0), 0, 0); + gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); EXPECT_EQ(ui::kCursorWait, host()->GetCursor(move_event).native_type()); diff --git a/ui/views/controls/scrollbar/base_scroll_bar_button.cc b/ui/views/controls/scrollbar/base_scroll_bar_button.cc index 0a765c42962985..54dbe7501ee010 100644 --- a/ui/views/controls/scrollbar/base_scroll_bar_button.cc +++ b/ui/views/controls/scrollbar/base_scroll_bar_button.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "ui/events/event_utils.h" #include "ui/gfx/screen.h" namespace views { @@ -38,9 +39,8 @@ void BaseScrollBarButton::RepeaterNotifyClick() { // TODO(scottmg): Native is wrong: http://crbug.com/133312 gfx::Point cursor_point = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); - ui::MouseEvent event(ui::ET_MOUSE_RELEASED, - cursor_point, cursor_point, - ui::EF_LEFT_MOUSE_BUTTON, + ui::MouseEvent event(ui::ET_MOUSE_RELEASED, cursor_point, cursor_point, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); Button::NotifyClick(event); } diff --git a/ui/views/controls/single_split_view_unittest.cc b/ui/views/controls/single_split_view_unittest.cc index e0840bb24f5fa8..f56e497bc5197d 100644 --- a/ui/views/controls/single_split_view_unittest.cc +++ b/ui/views/controls/single_split_view_unittest.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/events/event_utils.h" #include "ui/views/controls/single_split_view_listener.h" namespace { @@ -168,8 +169,8 @@ TEST(SingleSplitViewTest, MouseDrag) { split.Layout(); gfx::Point press_point(7, kInitialDividerOffset + kMouseOffset); - ui::MouseEvent mouse_pressed( - ui::ET_MOUSE_PRESSED, press_point, press_point, 0, 0); + ui::MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, press_point, press_point, + ui::EventTimeForNow(), 0, 0); ASSERT_TRUE(split.OnMousePressed(mouse_pressed)); EXPECT_EQ(kInitialDividerOffset, split.divider_offset()); EXPECT_EQ(0, listener.count()); @@ -177,8 +178,8 @@ TEST(SingleSplitViewTest, MouseDrag) { // Drag divider to the bottom. gfx::Point drag_1_point( 5, kInitialDividerOffset + kMouseOffset + kMouseMoveDelta); - ui::MouseEvent mouse_dragged_1( - ui::ET_MOUSE_DRAGGED, drag_1_point, drag_1_point, 0, 0); + ui::MouseEvent mouse_dragged_1(ui::ET_MOUSE_DRAGGED, drag_1_point, + drag_1_point, ui::EventTimeForNow(), 0, 0); ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_1)); EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta, split.divider_offset()); EXPECT_EQ(1, listener.count()); @@ -186,8 +187,8 @@ TEST(SingleSplitViewTest, MouseDrag) { // Drag divider to the top, beyond first child minimum size. gfx::Point drag_2_point( 7, kMinimumChildSize - 5); - ui::MouseEvent mouse_dragged_2( - ui::ET_MOUSE_DRAGGED, drag_2_point, drag_2_point, 0,0 ); + ui::MouseEvent mouse_dragged_2(ui::ET_MOUSE_DRAGGED, drag_2_point, + drag_2_point, ui::EventTimeForNow(), 0, 0); ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_2)); EXPECT_EQ(kMinimumChildSize, split.divider_offset()); EXPECT_EQ(2, listener.count()); @@ -195,8 +196,8 @@ TEST(SingleSplitViewTest, MouseDrag) { // Drag divider to the bottom, beyond second child minimum size. gfx::Point drag_3_point( 7, kTotalSplitSize - kMinimumChildSize + 5); - ui::MouseEvent mouse_dragged_3( - ui::ET_MOUSE_DRAGGED, drag_3_point, drag_3_point, 0, 0); + ui::MouseEvent mouse_dragged_3(ui::ET_MOUSE_DRAGGED, drag_3_point, + drag_3_point, ui::EventTimeForNow(), 0, 0); ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_3)); EXPECT_EQ(kTotalSplitSize - kMinimumChildSize - split.GetDividerSize(), split.divider_offset()); @@ -205,8 +206,8 @@ TEST(SingleSplitViewTest, MouseDrag) { // Drag divider between childs' minimum sizes. gfx::Point drag_4_point( 6, kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2); - ui::MouseEvent mouse_dragged_4( - ui::ET_MOUSE_DRAGGED, drag_4_point, drag_4_point, 0, 0); + ui::MouseEvent mouse_dragged_4(ui::ET_MOUSE_DRAGGED, drag_4_point, + drag_4_point, ui::EventTimeForNow(), 0, 0); ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_4)); EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2, split.divider_offset()); @@ -214,8 +215,8 @@ TEST(SingleSplitViewTest, MouseDrag) { gfx::Point release_point( 7, kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2); - ui::MouseEvent mouse_released( - ui::ET_MOUSE_RELEASED, release_point, release_point, 0, 0); + ui::MouseEvent mouse_released(ui::ET_MOUSE_RELEASED, release_point, + release_point, ui::EventTimeForNow(), 0, 0); split.OnMouseReleased(mouse_released); EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2, split.divider_offset()); diff --git a/ui/views/controls/table/table_view_unittest.cc b/ui/views/controls/table/table_view_unittest.cc index 1c3c40d7b14ff7..2b991b00079439 100644 --- a/ui/views/controls/table/table_view_unittest.cc +++ b/ui/views/controls/table/table_view_unittest.cc @@ -7,6 +7,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/events/event_utils.h" #include "ui/views/controls/table/table_grouper.h" #include "ui/views/controls/table/table_header.h" #include "ui/views/controls/table/table_view_observer.h" @@ -190,7 +191,7 @@ class TableViewTest : public testing::Test { void ClickOnRow(int row, int flags) { const int y = row * table_->row_height(); const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(0, y), - gfx::Point(0, y), + gfx::Point(0, y), ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON | flags, ui::EF_LEFT_MOUSE_BUTTON); table_->OnMousePressed(pressed); @@ -288,12 +289,13 @@ TEST_F(TableViewTest, Resize) { EXPECT_NE(0, x); // Drag the mouse 1 pixel to the left. const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(x, 0), - gfx::Point(x, 0), ui::EF_LEFT_MOUSE_BUTTON, + gfx::Point(x, 0), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); helper_->header()->OnMousePressed(pressed); const ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, gfx::Point(x - 1, 0), - gfx::Point(x - 1, 0), ui::EF_LEFT_MOUSE_BUTTON, - 0); + gfx::Point(x - 1, 0), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, 0); helper_->header()->OnMouseDragged(dragged); // This should shrink the first column and pull the second column in. @@ -385,12 +387,14 @@ TEST_F(TableViewTest, SortOnMouse) { EXPECT_NE(0, x); // Press and release the mouse. const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(x, 0), - gfx::Point(x, 0), ui::EF_LEFT_MOUSE_BUTTON, + gfx::Point(x, 0), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); // The header must return true, else it won't normally get the release. EXPECT_TRUE(helper_->header()->OnMousePressed(pressed)); const ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(x, 0), - gfx::Point(x, 0), ui::EF_LEFT_MOUSE_BUTTON, + gfx::Point(x, 0), ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); helper_->header()->OnMouseReleased(release); diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc index e5ddf39b7593f4..63a9f49a293d0b 100644 --- a/ui/views/controls/textfield/textfield_unittest.cc +++ b/ui/views/controls/textfield/textfield_unittest.cc @@ -21,6 +21,7 @@ #include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches_util.h" #include "ui/events/event.h" +#include "ui/events/event_utils.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/render_text.h" @@ -404,20 +405,24 @@ class TextfieldTest : public ViewsTestBase, public TextfieldController { void MouseClick(const gfx::Rect bound, int x_offset) { gfx::Point point(bound.x() + x_offset, bound.y() + bound.height() / 2); ui::MouseEvent click(ui::ET_MOUSE_PRESSED, point, point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(click); ui::MouseEvent release(ui::ET_MOUSE_RELEASED, point, point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMouseReleased(release); } // This is to avoid double/triple click. void NonClientMouseClick() { ui::MouseEvent click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_IS_NON_CLIENT, ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(click); ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_IS_NON_CLIENT, ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMouseReleased(release); @@ -834,7 +839,8 @@ TEST_F(TextfieldTest, FocusTraversalTest) { widget_->GetFocusManager()->AdvanceFocus(true); EXPECT_EQ(3, GetFocusedView()->id()); ui::MouseEvent click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(click); EXPECT_EQ(1, GetFocusedView()->id()); } @@ -866,13 +872,15 @@ TEST_F(TextfieldTest, DoubleAndTripleClickTest) { InitTextfield(); textfield_->SetText(ASCIIToUTF16("hello world")); ui::MouseEvent click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); - ui::MouseEvent double_click( - ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON | ui::EF_IS_DOUBLE_CLICK, - ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); + ui::MouseEvent double_click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), + ui::EF_LEFT_MOUSE_BUTTON | ui::EF_IS_DOUBLE_CLICK, + ui::EF_LEFT_MOUSE_BUTTON); // Test for double click. textfield_->OnMousePressed(click); @@ -901,15 +909,18 @@ TEST_F(TextfieldTest, DragToSelect) { gfx::Point start_point(kStart, 0); gfx::Point end_point(kEnd, 0); ui::MouseEvent click_a(ui::ET_MOUSE_PRESSED, start_point, start_point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); ui::MouseEvent click_b(ui::ET_MOUSE_PRESSED, end_point, end_point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); ui::MouseEvent drag_left(ui::ET_MOUSE_DRAGGED, gfx::Point(), gfx::Point(), - ui::EF_LEFT_MOUSE_BUTTON, 0); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); ui::MouseEvent drag_right(ui::ET_MOUSE_DRAGGED, end_point, end_point, - ui::EF_LEFT_MOUSE_BUTTON, 0); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); ui::MouseEvent release(ui::ET_MOUSE_RELEASED, end_point, end_point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(click_a); EXPECT_TRUE(textfield_->GetSelectedText().empty()); // Check that dragging left selects the beginning of the string. @@ -1014,7 +1025,7 @@ TEST_F(TextfieldTest, DragAndDrop_InitiateDrag) { textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_TEXT); // Ensure that textfields only initiate drag operations inside the selection. ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, kStringPoint, kStringPoint, - ui::EF_LEFT_MOUSE_BUTTON, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(press_event); EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, @@ -1044,7 +1055,8 @@ TEST_F(TextfieldTest, DragAndDrop_ToTheRight) { textfield_->SelectRange(gfx::Range(1, 5)); gfx::Point point(GetCursorPositionX(3), 0); ui::MouseEvent click_a(ui::ET_MOUSE_PRESSED, point, point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(click_a); EXPECT_TRUE(textfield_->CanStartDragForView(textfield_, click_a.location(), gfx::Point())); @@ -1097,7 +1109,8 @@ TEST_F(TextfieldTest, DragAndDrop_ToTheLeft) { textfield_->SelectRange(gfx::Range(5, 10)); gfx::Point point(GetCursorPositionX(7), 0); ui::MouseEvent click_a(ui::ET_MOUSE_PRESSED, point, point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(click_a); EXPECT_TRUE(textfield_->CanStartDragForView(textfield_, click_a.location(), gfx::Point())); @@ -1144,7 +1157,8 @@ TEST_F(TextfieldTest, DragAndDrop_Canceled) { textfield_->SelectRange(gfx::Range(6, 10)); gfx::Point point(GetCursorPositionX(8), 0); ui::MouseEvent click(ui::ET_MOUSE_PRESSED, point, point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(click); ui::OSExchangeData data; textfield_->WriteDragDataForView(NULL, click.location(), &data); @@ -1157,9 +1171,10 @@ TEST_F(TextfieldTest, DragAndDrop_Canceled) { // "Cancel" the drag, via move and release over the selection, and OnDragDone. gfx::Point drag_point(GetCursorPositionX(9), 0); ui::MouseEvent drag(ui::ET_MOUSE_DRAGGED, drag_point, drag_point, - ui::EF_LEFT_MOUSE_BUTTON, 0); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); ui::MouseEvent release(ui::ET_MOUSE_RELEASED, drag_point, drag_point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMouseDragged(drag); textfield_->OnMouseReleased(release); textfield_->OnDragDone(); @@ -1900,14 +1915,14 @@ TEST_F(TextfieldTest, KeepInitiallySelectedWord) { const gfx::Point middle(middle_cursor.x(), middle_cursor.y() + middle_cursor.height() / 2); ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, middle, middle, - ui::EF_LEFT_MOUSE_BUTTON, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(press_event); EXPECT_EQ(gfx::Range(4, 7), textfield_->GetSelectedRange()); // Drag the mouse to the beginning of the textfield. ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, beginning, beginning, - ui::EF_LEFT_MOUSE_BUTTON, 0); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); textfield_->OnMouseDragged(drag_event); EXPECT_EQ(gfx::Range(7, 0), textfield_->GetSelectedRange()); } @@ -1924,13 +1939,16 @@ TEST_F(TextfieldTest, DISABLED_SelectionClipboard) { // Text selected by the mouse should be placed on the selection clipboard. ui::MouseEvent press(ui::ET_MOUSE_PRESSED, point_1, point_1, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(press); ui::MouseEvent drag(ui::ET_MOUSE_DRAGGED, point_3, point_3, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMouseDragged(drag); ui::MouseEvent release(ui::ET_MOUSE_RELEASED, point_3, point_3, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMouseReleased(release); EXPECT_EQ(gfx::Range(1, 3), textfield_->GetSelectedRange()); EXPECT_STR_EQ("12", GetClipboardText(ui::CLIPBOARD_TYPE_SELECTION)); @@ -1944,14 +1962,16 @@ TEST_F(TextfieldTest, DISABLED_SelectionClipboard) { // Shift-click selection modifications should update the clipboard. NonClientMouseClick(); ui::MouseEvent press_2(ui::ET_MOUSE_PRESSED, point_2, point_2, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); press_2.set_flags(press_2.flags() | ui::EF_SHIFT_DOWN); #if defined(USE_X11) ui::UpdateX11EventForFlags(&press_2); #endif textfield_->OnMousePressed(press_2); ui::MouseEvent release_2(ui::ET_MOUSE_RELEASED, point_2, point_2, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMouseReleased(release_2); EXPECT_EQ(gfx::Range(0, 2), textfield_->GetSelectedRange()); EXPECT_STR_EQ("01", GetClipboardText(ui::CLIPBOARD_TYPE_SELECTION)); @@ -1977,7 +1997,8 @@ TEST_F(TextfieldTest, DISABLED_SelectionClipboard) { // Middle clicking should paste at the mouse (not cursor) location. // The cursor should be placed at the end of the pasted text. ui::MouseEvent middle(ui::ET_MOUSE_PRESSED, point_4, point_4, - ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_MIDDLE_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_MIDDLE_MOUSE_BUTTON, + ui::EF_MIDDLE_MOUSE_BUTTON); textfield_->OnMousePressed(middle); EXPECT_STR_EQ("01230123", textfield_->text()); EXPECT_EQ(gfx::Range(8, 8), textfield_->GetSelectedRange()); @@ -2014,13 +2035,15 @@ TEST_F(TextfieldTest, DISABLED_SelectionClipboard) { textfield_->SetText(ASCIIToUTF16("ab cd ef")); gfx::Point word(GetCursorPositionX(4), 0); ui::MouseEvent press_word(ui::ET_MOUSE_PRESSED, word, word, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(press_word); ui::MouseEvent release_word(ui::ET_MOUSE_RELEASED, word, word, - ui::EF_LEFT_MOUSE_BUTTON, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMouseReleased(release_word); ui::MouseEvent double_click(ui::ET_MOUSE_PRESSED, word, word, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_IS_DOUBLE_CLICK, ui::EF_LEFT_MOUSE_BUTTON); textfield_->OnMousePressed(double_click); diff --git a/ui/views/controls/webview/webview_unittest.cc b/ui/views/controls/webview/webview_unittest.cc index 79479d07fc831e..349ad3f732d4a2 100644 --- a/ui/views/controls/webview/webview_unittest.cc +++ b/ui/views/controls/webview/webview_unittest.cc @@ -13,6 +13,7 @@ #include "content/test/test_content_browser_client.h" #include "ui/aura/window.h" #include "ui/events/event.h" +#include "ui/events/event_utils.h" #include "ui/views/controls/native/native_view_host.h" #include "ui/views/test/test_views_delegate.h" #include "ui/views/test/widget_test.h" @@ -402,11 +403,10 @@ TEST_F(WebViewUnitTest, EmbeddedFullscreenDuringScreenCapture_ClickToFocus) { // Send mouse press event to WebView outside the bounds of the holder, and // confirm WebView took focus. - const ui::MouseEvent click_outside_holder(ui::ET_MOUSE_PRESSED, - gfx::Point(1, 1), - gfx::Point(), // Immaterial. - ui::EF_LEFT_MOUSE_BUTTON, - 0); + const ui::MouseEvent click_outside_holder( + ui::ET_MOUSE_PRESSED, gfx::Point(1, 1), + gfx::Point(), // Immaterial. + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); EXPECT_TRUE(static_cast(web_view())-> OnMousePressed(click_outside_holder)); EXPECT_TRUE(web_view()->HasFocus()); @@ -425,11 +425,10 @@ TEST_F(WebViewUnitTest, EmbeddedFullscreenDuringScreenCapture_ClickToFocus) { // WebContents native view to grab the focus instead. In this test // environment, the WebContents native view doesn't include the implementation // needed to grab focus, so no focus change will occur. - const ui::MouseEvent click_inside_holder(ui::ET_MOUSE_PRESSED, - web_view()->bounds().CenterPoint(), - gfx::Point(), // Immaterial. - ui::EF_LEFT_MOUSE_BUTTON, - 0); + const ui::MouseEvent click_inside_holder( + ui::ET_MOUSE_PRESSED, web_view()->bounds().CenterPoint(), + gfx::Point(), // Immaterial. + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); EXPECT_FALSE(static_cast(web_view())-> OnMousePressed(click_inside_holder)); EXPECT_FALSE(web_view()->HasFocus()); diff --git a/ui/views/touchui/touch_selection_controller_impl_unittest.cc b/ui/views/touchui/touch_selection_controller_impl_unittest.cc index 1e2254a0252bb4..3c9a9cc9929d09 100644 --- a/ui/views/touchui/touch_selection_controller_impl_unittest.cc +++ b/ui/views/touchui/touch_selection_controller_impl_unittest.cc @@ -10,6 +10,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/base/touch/touch_editing_controller.h" #include "ui/base/ui_base_switches.h" +#include "ui/events/event_utils.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/point.h" @@ -736,7 +737,7 @@ TEST_F(TouchSelectionControllerImplTest, HandlesStackAboveParent) { StartTouchEditing(); gfx::Point test_point = GetCursorHandleDragPoint(); ui::MouseEvent test_event1(ui::ET_MOUSE_MOVED, test_point, test_point, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(GetCursorHandleNativeView(), targeter->FindTargetForEvent(root, &test_event1)); EndTouchEditing(); @@ -749,14 +750,14 @@ TEST_F(TouchSelectionControllerImplTest, HandlesStackAboveParent) { // above the second window. StartTouchEditing(); ui::MouseEvent test_event2(ui::ET_MOUSE_MOVED, test_point, test_point, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(window2, targeter->FindTargetForEvent(root, &test_event2)); // Move the first window to top and check that the handle is kept above the // first window. window1->GetRootWindow()->StackChildAtTop(window1); ui::MouseEvent test_event3(ui::ET_MOUSE_MOVED, test_point, test_point, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); EXPECT_EQ(GetCursorHandleNativeView(), targeter->FindTargetForEvent(root, &test_event3)); } diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc index 2ea481c7c346f0..cc15602d3eaa43 100644 --- a/ui/views/view_unittest.cc +++ b/ui/views/view_unittest.cc @@ -17,6 +17,7 @@ #include "ui/compositor/layer_animator.h" #include "ui/compositor/test/draw_waiter_for_test.h" #include "ui/events/event.h" +#include "ui/events/event_utils.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/gfx/canvas.h" #include "ui/gfx/path.h" @@ -340,7 +341,7 @@ TEST_F(ViewTest, MouseEvent) { v2->Reset(); gfx::Point p1(110, 120); - ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, + ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); root->OnMousePressed(pressed); EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_PRESSED); @@ -353,7 +354,7 @@ TEST_F(ViewTest, MouseEvent) { v1->Reset(); v2->Reset(); gfx::Point p2(50, 40); - ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, p2, p2, + ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, p2, p2, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); root->OnMouseDragged(dragged); EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_DRAGGED); @@ -365,8 +366,8 @@ TEST_F(ViewTest, MouseEvent) { // Releasted event out of bounds. Should still go to v2 v1->Reset(); v2->Reset(); - ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0, - 0); + ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); root->OnMouseDragged(released); EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_RELEASED); EXPECT_EQ(v2->location_.x(), -100); @@ -401,7 +402,8 @@ TEST_F(ViewTest, DeleteOnPressed) { v2->delete_on_pressed_ = true; gfx::Point point(110, 120); ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); root->OnMousePressed(pressed); EXPECT_EQ(0, v1->child_count()); @@ -1056,7 +1058,7 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) { // Move the mouse in v111. gfx::Point p1(6, 6); - ui::MouseEvent move1(ui::ET_MOUSE_MOVED, p1, p1, 0, 0); + ui::MouseEvent move1(ui::ET_MOUSE_MOVED, p1, p1, ui::EventTimeForNow(), 0, 0); root_view->OnMouseMoved(move1); EXPECT_TRUE(v111->received_mouse_enter_); EXPECT_FALSE(v11->last_mouse_event_type_); @@ -1067,7 +1069,7 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) { // Now, move into v121. gfx::Point p2(65, 21); - ui::MouseEvent move2(ui::ET_MOUSE_MOVED, p2, p2, 0, 0); + ui::MouseEvent move2(ui::ET_MOUSE_MOVED, p2, p2, ui::EventTimeForNow(), 0, 0); root_view->OnMouseMoved(move2); EXPECT_TRUE(v111->received_mouse_exit_); EXPECT_TRUE(v121->received_mouse_enter_); @@ -1078,7 +1080,7 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) { // Now, move into v11. gfx::Point p3(1, 1); - ui::MouseEvent move3(ui::ET_MOUSE_MOVED, p3, p3, 0, 0); + ui::MouseEvent move3(ui::ET_MOUSE_MOVED, p3, p3, ui::EventTimeForNow(), 0, 0); root_view->OnMouseMoved(move3); EXPECT_TRUE(v121->received_mouse_exit_); EXPECT_TRUE(v11->received_mouse_enter_); @@ -1089,7 +1091,7 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) { // Move to v21. gfx::Point p4(121, 15); - ui::MouseEvent move4(ui::ET_MOUSE_MOVED, p4, p4, 0, 0); + ui::MouseEvent move4(ui::ET_MOUSE_MOVED, p4, p4, ui::EventTimeForNow(), 0, 0); root_view->OnMouseMoved(move4); EXPECT_TRUE(v21->received_mouse_enter_); EXPECT_FALSE(v2->last_mouse_event_type_); @@ -1102,7 +1104,7 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) { // Move to v1. gfx::Point p5(21, 0); - ui::MouseEvent move5(ui::ET_MOUSE_MOVED, p5, p5, 0, 0); + ui::MouseEvent move5(ui::ET_MOUSE_MOVED, p5, p5, ui::EventTimeForNow(), 0, 0); root_view->OnMouseMoved(move5); EXPECT_TRUE(v21->received_mouse_exit_); EXPECT_TRUE(v1->received_mouse_enter_); @@ -1112,7 +1114,8 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) { // Now, move into v11. gfx::Point p6(15, 15); - ui::MouseEvent mouse6(ui::ET_MOUSE_MOVED, p6, p6, 0, 0); + ui::MouseEvent mouse6(ui::ET_MOUSE_MOVED, p6, p6, ui::EventTimeForNow(), 0, + 0); root_view->OnMouseMoved(mouse6); EXPECT_TRUE(v11->received_mouse_enter_); EXPECT_FALSE(v1->last_mouse_event_type_); @@ -1124,7 +1127,8 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) { // and the mouse remains inside |v1| the whole time, it receives another ENTER // when the mouse leaves v11. gfx::Point p7(21, 0); - ui::MouseEvent mouse7(ui::ET_MOUSE_MOVED, p7, p7, 0, 0); + ui::MouseEvent mouse7(ui::ET_MOUSE_MOVED, p7, p7, ui::EventTimeForNow(), 0, + 0); root_view->OnMouseMoved(mouse7); EXPECT_TRUE(v11->received_mouse_exit_); EXPECT_FALSE(v1->received_mouse_enter_); @@ -1646,7 +1650,7 @@ TEST_F(ViewTest, TransformEvent) { v2->Reset(); gfx::Point p1(110, 210); - ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, + ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); root->OnMousePressed(pressed); EXPECT_EQ(0, v1->last_mouse_event_type_); @@ -1654,8 +1658,8 @@ TEST_F(ViewTest, TransformEvent) { EXPECT_EQ(190, v2->location_.x()); EXPECT_EQ(10, v2->location_.y()); - ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0, - 0); + ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), 0, 0); root->OnMouseReleased(released); // Now rotate |v2| inside |v1| clockwise. @@ -1671,7 +1675,7 @@ TEST_F(ViewTest, TransformEvent) { v2->Reset(); gfx::Point point2(110, 320); - ui::MouseEvent p2(ui::ET_MOUSE_PRESSED, point2, point2, + ui::MouseEvent p2(ui::ET_MOUSE_PRESSED, point2, point2, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); root->OnMousePressed(p2); EXPECT_EQ(0, v1->last_mouse_event_type_); @@ -1707,7 +1711,7 @@ TEST_F(ViewTest, TransformEvent) { v3->Reset(); gfx::Point point(112, 110); - ui::MouseEvent p3(ui::ET_MOUSE_PRESSED, point, point, + ui::MouseEvent p3(ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); root->OnMousePressed(p3); @@ -1746,7 +1750,7 @@ TEST_F(ViewTest, TransformEvent) { // |v3| now occupies (120, 120) to (144, 130) in |root|. gfx::Point point3(124, 125); - ui::MouseEvent p4(ui::ET_MOUSE_PRESSED, point3, point3, + ui::MouseEvent p4(ui::ET_MOUSE_PRESSED, point3, point3, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); root->OnMousePressed(p4); diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc index e092d737db0492..6e45f3566e465e 100644 --- a/ui/views/widget/root_view.cc +++ b/ui/views/widget/root_view.cc @@ -14,6 +14,7 @@ #include "ui/base/ui_base_switches_util.h" #include "ui/compositor/layer.h" #include "ui/events/event.h" +#include "ui/events/event_utils.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/gfx/canvas.h" #include "ui/views/drag_controller.h" @@ -454,10 +455,9 @@ void RootView::OnMouseCaptureLost() { // Synthesize a release event for UpdateCursor. if (mouse_pressed_handler_) { gfx::Point last_point(last_mouse_event_x_, last_mouse_event_y_); - ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, - last_point, last_point, - last_mouse_event_flags_, - 0); + ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, last_point, + last_point, ui::EventTimeForNow(), + last_mouse_event_flags_, 0); UpdateCursor(release_event); } // We allow the view to delete us from OnMouseCaptureLost. As such, diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index 76dc14a5ae8208..ad974649cb34ec 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -16,6 +16,7 @@ #include "ui/compositor/compositor.h" #include "ui/compositor/layer.h" #include "ui/events/event.h" +#include "ui/events/event_utils.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/screen.h" #include "ui/views/controls/menu/menu_controller.h" @@ -991,9 +992,8 @@ gfx::Rect Widget::GetWorkAreaBoundsInScreen() const { void Widget::SynthesizeMouseMoveEvent() { last_mouse_event_was_move_ = false; - ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, - last_mouse_event_position_, - last_mouse_event_position_, + ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, last_mouse_event_position_, + last_mouse_event_position_, ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0); root_view_->OnMouseMoved(mouse_event); } diff --git a/ui/views/widget/widget_interactive_uitest.cc b/ui/views/widget/widget_interactive_uitest.cc index 845360303cf4d2..9a2381bdeb06e1 100644 --- a/ui/views/widget/widget_interactive_uitest.cc +++ b/ui/views/widget/widget_interactive_uitest.cc @@ -13,6 +13,7 @@ #include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_switches.h" #include "ui/events/event_processor.h" +#include "ui/events/event_utils.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/native_widget_types.h" #include "ui/gl/gl_surface.h" @@ -334,7 +335,8 @@ TEST_F(WidgetTestInteractive, CaptureAutoReset) { // By default, mouse release removes capture. gfx::Point click_location(45, 15); ui::MouseEvent release(ui::ET_MOUSE_RELEASED, click_location, click_location, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); toplevel->OnMouseEvent(&release); EXPECT_FALSE(toplevel->HasCapture()); @@ -385,9 +387,11 @@ TEST_F(WidgetTestInteractive, ResetCaptureOnGestureEnd) { gfx::Point click_location(45, 15); ui::MouseEvent press(ui::ET_MOUSE_PRESSED, click_location, click_location, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); ui::MouseEvent release(ui::ET_MOUSE_RELEASED, click_location, click_location, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); EXPECT_TRUE(toplevel->HasCapture()); @@ -432,16 +436,15 @@ TEST_F(WidgetTestInteractive, DisableCaptureWidgetFromMousePress) { first->Show(); gfx::Point location(20, 20); - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&Widget::OnMouseEvent, - base::Unretained(second), - base::Owned(new ui::MouseEvent(ui::ET_MOUSE_RELEASED, - location, - location, - ui::EF_LEFT_MOUSE_BUTTON, - ui::EF_LEFT_MOUSE_BUTTON)))); + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&Widget::OnMouseEvent, base::Unretained(second), + base::Owned(new ui::MouseEvent( + ui::ET_MOUSE_RELEASED, location, location, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON)))); ui::MouseEvent press(ui::ET_MOUSE_PRESSED, location, location, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); first->OnMouseEvent(&press); EXPECT_FALSE(first->HasCapture()); first->Close(); @@ -472,7 +475,7 @@ TEST_F(WidgetTestInteractive, DISABLED_GrabUngrab) { // Click on child1 gfx::Point p1(45, 45); - ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, + ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); toplevel->OnMouseEvent(&pressed); @@ -480,7 +483,7 @@ TEST_F(WidgetTestInteractive, DISABLED_GrabUngrab) { EXPECT_TRUE(child1->HasCapture()); EXPECT_FALSE(child2->HasCapture()); - ui::MouseEvent released(ui::ET_MOUSE_RELEASED, p1, p1, + ui::MouseEvent released(ui::ET_MOUSE_RELEASED, p1, p1, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); toplevel->OnMouseEvent(&released); @@ -492,7 +495,7 @@ TEST_F(WidgetTestInteractive, DISABLED_GrabUngrab) { // Click on child2 gfx::Point p2(315, 45); - ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED, p2, p2, + ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED, p2, p2, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); toplevel->OnMouseEvent(&pressed2); EXPECT_TRUE(pressed2.handled()); @@ -500,7 +503,7 @@ TEST_F(WidgetTestInteractive, DISABLED_GrabUngrab) { EXPECT_TRUE(child2->HasCapture()); EXPECT_FALSE(child1->HasCapture()); - ui::MouseEvent released2(ui::ET_MOUSE_RELEASED, p2, p2, + ui::MouseEvent released2(ui::ET_MOUSE_RELEASED, p2, p2, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); toplevel->OnMouseEvent(&released2); EXPECT_FALSE(toplevel->HasCapture()); @@ -526,24 +529,24 @@ TEST_F(WidgetTestInteractive, CheckResizeControllerEvents) { // Move to an outside position. gfx::Point p1(200, 200); - ui::MouseEvent moved_out(ui::ET_MOUSE_MOVED, p1, p1, ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent moved_out(ui::ET_MOUSE_MOVED, p1, p1, ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); toplevel->OnMouseEvent(&moved_out); EXPECT_EQ(0, view->EnteredCalls()); EXPECT_EQ(0, view->ExitedCalls()); // Move onto the active view. gfx::Point p2(95, 95); - ui::MouseEvent moved_over(ui::ET_MOUSE_MOVED, p2, p2, ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent moved_over(ui::ET_MOUSE_MOVED, p2, p2, ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); toplevel->OnMouseEvent(&moved_over); EXPECT_EQ(1, view->EnteredCalls()); EXPECT_EQ(0, view->ExitedCalls()); // Move onto the outer resizing border. gfx::Point p3(102, 95); - ui::MouseEvent moved_resizer(ui::ET_MOUSE_MOVED, p3, p3, ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent moved_resizer(ui::ET_MOUSE_MOVED, p3, p3, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); toplevel->OnMouseEvent(&moved_resizer); EXPECT_EQ(0, view->EnteredCalls()); EXPECT_EQ(1, view->ExitedCalls()); @@ -1375,7 +1378,7 @@ TEST_F(WidgetCaptureTest, MouseEventDispatchedToRightWindow) { // Send a mouse event to the RootWindow associated with |widget1|. Even though // |widget2| has capture, |widget1| should still get the event. ui::MouseEvent mouse_event(ui::ET_MOUSE_EXITED, gfx::Point(), gfx::Point(), - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); ui::EventDispatchDetails details = widget1.GetNativeWindow()-> GetHost()->event_processor()->OnEventFromSource(&mouse_event); ASSERT_FALSE(details.dispatcher_destroyed); diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc index 4ad12053519e80..7c739d2b758ac6 100644 --- a/ui/views/widget/widget_unittest.cc +++ b/ui/views/widget/widget_unittest.cc @@ -1423,7 +1423,8 @@ TEST_F(WidgetTest, TestWindowVisibilityAfterHide) { void GenerateMouseEvents(Widget* widget, ui::EventType last_event_type) { const gfx::Rect screen_bounds(widget->GetWindowBoundsInScreen()); ui::MouseEvent move_event(ui::ET_MOUSE_MOVED, screen_bounds.CenterPoint(), - screen_bounds.CenterPoint(), 0, 0); + screen_bounds.CenterPoint(), ui::EventTimeForNow(), + 0, 0); ui::EventProcessor* dispatcher = WidgetTest::GetEventProcessor(widget); ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move_event); if (last_event_type == ui::ET_MOUSE_ENTERED || details.dispatcher_destroyed) @@ -1433,20 +1434,22 @@ void GenerateMouseEvents(Widget* widget, ui::EventType last_event_type) { return; ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(), - screen_bounds.CenterPoint(), 0, 0); + screen_bounds.CenterPoint(), ui::EventTimeForNow(), + 0, 0); details = dispatcher->OnEventFromSource(&press_event); if (last_event_type == ui::ET_MOUSE_PRESSED || details.dispatcher_destroyed) return; gfx::Point end_point(screen_bounds.CenterPoint()); end_point.Offset(1, 1); - ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, end_point, end_point, 0, 0); + ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, end_point, end_point, + ui::EventTimeForNow(), 0, 0); details = dispatcher->OnEventFromSource(&drag_event); if (last_event_type == ui::ET_MOUSE_DRAGGED || details.dispatcher_destroyed) return; - ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, end_point, end_point, 0, - 0); + ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, end_point, end_point, + ui::EventTimeForNow(), 0, 0); details = dispatcher->OnEventFromSource(&release_event); if (details.dispatcher_destroyed) return; @@ -1722,7 +1725,7 @@ TEST_F(WidgetTest, SynthesizeMouseMoveEvent) { gfx::Point cursor_location(5, 5); ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, - ui::EF_NONE, ui::EF_NONE); + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); widget->OnMouseEvent(&move); EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_ENTERED)); @@ -2142,7 +2145,8 @@ TEST_F(WidgetTest, MAYBE_DisableTestRootViewHandlersWhenHidden) { EXPECT_EQ(NULL, GetMousePressedHandler(root_view)); gfx::Point click_location(45, 15); ui::MouseEvent press(ui::ET_MOUSE_PRESSED, click_location, click_location, - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, + ui::EF_LEFT_MOUSE_BUTTON); widget->OnMouseEvent(&press); EXPECT_EQ(view, GetMousePressedHandler(root_view)); widget->Hide(); @@ -2152,7 +2156,8 @@ TEST_F(WidgetTest, MAYBE_DisableTestRootViewHandlersWhenHidden) { widget->Show(); EXPECT_EQ(NULL, GetMouseMoveHandler(root_view)); gfx::Point move_location(45, 15); - ui::MouseEvent move(ui::ET_MOUSE_MOVED, move_location, move_location, 0, 0); + ui::MouseEvent move(ui::ET_MOUSE_MOVED, move_location, move_location, + ui::EventTimeForNow(), 0, 0); widget->OnMouseEvent(&move); EXPECT_EQ(view, GetMouseMoveHandler(root_view)); widget->Hide(); @@ -3013,11 +3018,9 @@ TEST_F(WidgetTest, WindowMouseModalityTest) { top_level_widget.GetRootView()->AddChildView(widget_view); gfx::Point cursor_location_main(5, 5); - ui::MouseEvent move_main(ui::ET_MOUSE_MOVED, - cursor_location_main, - cursor_location_main, - ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent move_main(ui::ET_MOUSE_MOVED, cursor_location_main, + cursor_location_main, ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); ui::EventDispatchDetails details = GetEventProcessor(&top_level_widget)->OnEventFromSource(&move_main); ASSERT_FALSE(details.dispatcher_destroyed); @@ -3041,11 +3044,9 @@ TEST_F(WidgetTest, WindowMouseModalityTest) { EXPECT_TRUE(modal_dialog_widget->IsVisible()); gfx::Point cursor_location_dialog(100, 100); - ui::MouseEvent mouse_down_dialog(ui::ET_MOUSE_PRESSED, - cursor_location_dialog, - cursor_location_dialog, - ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent mouse_down_dialog( + ui::ET_MOUSE_PRESSED, cursor_location_dialog, cursor_location_dialog, + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); details = GetEventProcessor(&top_level_widget)->OnEventFromSource( &mouse_down_dialog); ASSERT_FALSE(details.dispatcher_destroyed); @@ -3054,11 +3055,9 @@ TEST_F(WidgetTest, WindowMouseModalityTest) { // Send a mouse move message to the main window. It should not be received by // the main window as the modal dialog is still active. gfx::Point cursor_location_main2(6, 6); - ui::MouseEvent mouse_down_main(ui::ET_MOUSE_MOVED, - cursor_location_main2, - cursor_location_main2, - ui::EF_NONE, - ui::EF_NONE); + ui::MouseEvent mouse_down_main(ui::ET_MOUSE_MOVED, cursor_location_main2, + cursor_location_main2, ui::EventTimeForNow(), + ui::EF_NONE, ui::EF_NONE); details = GetEventProcessor(&top_level_widget)->OnEventFromSource( &mouse_down_main); ASSERT_FALSE(details.dispatcher_destroyed); diff --git a/ui/wm/core/capture_controller_unittest.cc b/ui/wm/core/capture_controller_unittest.cc index de1a59ca80047a..c48997bbf412d8 100644 --- a/ui/wm/core/capture_controller_unittest.cc +++ b/ui/wm/core/capture_controller_unittest.cc @@ -99,7 +99,8 @@ TEST_F(CaptureControllerTest, ResetMouseEventHandlerOnCapture) { // Make a synthesized mouse down event. Ensure that the WindowEventDispatcher // will dispatch further mouse events to |w1|. ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), - gfx::Point(5, 5), 0, 0); + gfx::Point(5, 5), ui::EventTimeForNow(), 0, + 0); DispatchEventUsingWindowDispatcher(&mouse_pressed_event); EXPECT_EQ(w1.get(), host()->dispatcher()->mouse_pressed_handler()); diff --git a/ui/wm/core/compound_event_filter_unittest.cc b/ui/wm/core/compound_event_filter_unittest.cc index 453e03f3fc7e6d..4ffdd26fa44a9e 100644 --- a/ui/wm/core/compound_event_filter_unittest.cc +++ b/ui/wm/core/compound_event_filter_unittest.cc @@ -68,20 +68,20 @@ TEST_F(CompoundEventFilterTest, CursorVisibilityChange) { // Synthesized mouse event should not show the cursor. ui::MouseEvent enter(ui::ET_MOUSE_ENTERED, gfx::Point(10, 10), - gfx::Point(10, 10), 0, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); enter.set_flags(enter.flags() | ui::EF_IS_SYNTHESIZED); DispatchEventUsingWindowDispatcher(&enter); EXPECT_FALSE(cursor_client.IsCursorVisible()); ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), - gfx::Point(10, 10), 0, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); move.set_flags(enter.flags() | ui::EF_IS_SYNTHESIZED); DispatchEventUsingWindowDispatcher(&move); EXPECT_FALSE(cursor_client.IsCursorVisible()); // A real mouse event should show the cursor. ui::MouseEvent real_move(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), - gfx::Point(10, 10), 0, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&real_move); EXPECT_TRUE(cursor_client.IsCursorVisible()); @@ -99,7 +99,7 @@ TEST_F(CompoundEventFilterTest, CursorVisibilityChange) { // Mouse synthesized exit event should not show the cursor. ui::MouseEvent exit(ui::ET_MOUSE_EXITED, gfx::Point(10, 10), - gfx::Point(10, 10), 0, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); exit.set_flags(enter.flags() | ui::EF_IS_SYNTHESIZED); DispatchEventUsingWindowDispatcher(&exit); EXPECT_FALSE(cursor_client.IsCursorVisible()); @@ -123,7 +123,7 @@ TEST_F(CompoundEventFilterTest, TouchHidesCursor) { aura::test::TestCursorClient cursor_client(root_window()); ui::MouseEvent mouse0(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), - gfx::Point(10, 10), 0, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); DispatchEventUsingWindowDispatcher(&mouse0); EXPECT_TRUE(cursor_client.IsMouseEventsEnabled()); @@ -144,7 +144,7 @@ TEST_F(CompoundEventFilterTest, TouchHidesCursor) { EXPECT_FALSE(cursor_client.IsMouseEventsEnabled()); ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), - gfx::Point(10, 10), 0, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); // Move the cursor again. The cursor should be visible. DispatchEventUsingWindowDispatcher(&mouse1); EXPECT_TRUE(cursor_client.IsMouseEventsEnabled()); @@ -231,7 +231,7 @@ TEST_F(CompoundEventFilterTest, DontShowCursorOnMouseMovesFromTouch) { EXPECT_FALSE(cursor_client.IsMouseEventsEnabled()); ui::MouseEvent mouse0(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), - gfx::Point(10, 10), 0, 0); + gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); mouse0.set_flags(mouse0.flags() | ui::EF_FROM_TOUCH); DispatchEventUsingWindowDispatcher(&mouse0);