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

Unified Diff: ui/aura/window_event_dispatcher_unittest.cc

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/aura/window_event_dispatcher_unittest.cc
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc
index a48f0dda02bb2ddc5dc2237dfe46e3df73f1af90..0b7d5d53cfef12185944ef0bb0668c4a389a09eb 100644
--- a/ui/aura/window_event_dispatcher_unittest.cc
+++ b/ui/aura/window_event_dispatcher_unittest.cc
@@ -116,7 +116,7 @@ TEST_F(WindowEventDispatcherTest, OnHostMouseEvent) {
delegate2.get(), -5678, bounds2, root_window()));
// Send a mouse event to window1.
- gfx::Point point(101, 201);
+ gfx::PointF point(101.f, 201.f);
ui::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, point,
ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON);
@@ -139,7 +139,7 @@ TEST_F(WindowEventDispatcherTest, OnHostMouseEvent) {
TEST_F(WindowEventDispatcherTest, RepostEvent) {
// Test RepostEvent in RootWindow. It only works for Mouse Press.
EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown());
- gfx::Point point(10, 10);
+ gfx::PointF point(10.f, 10.f);
ui::MouseEvent event(ui::ET_MOUSE_PRESSED, point, point,
ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON);
@@ -153,7 +153,7 @@ TEST_F(WindowEventDispatcherTest, RepostEvent) {
TEST_F(WindowEventDispatcherTest, MouseButtonState) {
EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown());
- gfx::Point location;
+ gfx::PointF location;
scoped_ptr<ui::MouseEvent> event;
// Press the left button.
@@ -197,18 +197,18 @@ TEST_F(WindowEventDispatcherTest, TranslatedEvent) {
scoped_ptr<Window> w1(test::CreateTestWindowWithDelegate(NULL, 1,
gfx::Rect(50, 50, 100, 100), root_window()));
- gfx::Point origin(100, 100);
+ gfx::PointF origin(100.f, 100.f);
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());
+ EXPECT_EQ(gfx::PointF(100.f, 100.f), root.location_f());
+ EXPECT_EQ(gfx::PointF(100.f, 100.1), root.root_location_f());
ui::MouseEvent translated_event(
root, static_cast<Window*>(root_window()), w1.get(),
ui::ET_MOUSE_ENTERED, root.flags());
- EXPECT_EQ("50,50", translated_event.location().ToString());
- EXPECT_EQ("100,100", translated_event.root_location().ToString());
+ EXPECT_EQ(gfx::PointF(50.f, 50.f), translated_event.location_f());
+ EXPECT_EQ(gfx::PointF(100.f, 100.f), translated_event.root_location_f());
}
namespace {
@@ -378,16 +378,16 @@ TEST_F(WindowEventDispatcherTest, TouchEventsOutsideBounds) {
ui::test::TestEventHandler handler;
root_window()->AddPreTargetHandler(&handler);
- gfx::Point position = root_window()->bounds().origin();
- position.Offset(-10, -10);
+ auto position = gfx::PointF(root_window()->bounds().origin());
+ position.Offset(-10.f, -10.f);
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, position, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press);
EXPECT_EQ(1, handler.num_touch_events());
- position = root_window()->bounds().origin();
- position.Offset(root_window()->bounds().width() + 10,
- root_window()->bounds().height() + 10);
+ position = gfx::PointF(root_window()->bounds().origin());
+ position.Offset(root_window()->bounds().width() + 10.f,
+ root_window()->bounds().height() + 10.f);
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, position, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&release);
@@ -406,24 +406,14 @@ TEST_F(WindowEventDispatcherTest, ScrollEventDispatch) {
w1->SetBounds(gfx::Rect(20, 20, 40, 40));
// A scroll event on the root-window itself is dispatched.
- ui::ScrollEvent scroll1(ui::ET_SCROLL,
- gfx::Point(10, 10),
- now,
- 0,
- 0, -10,
- 0, -10,
- 2);
+ ui::ScrollEvent scroll1(ui::ET_SCROLL, gfx::PointF(10.f, 10.f), now, 0, 0,
+ -10, 0, -10, 2);
DispatchEventUsingWindowDispatcher(&scroll1);
EXPECT_EQ(1, handler.num_scroll_events());
// Scroll event on a window should be dispatched properly.
- ui::ScrollEvent scroll2(ui::ET_SCROLL,
- gfx::Point(25, 30),
- now,
- 0,
- -10, 0,
- -10, 0,
- 2);
+ ui::ScrollEvent scroll2(ui::ET_SCROLL, gfx::PointF(25.f, 30.f), now, 0, -10,
+ 0, -10, 0, 2);
DispatchEventUsingWindowDispatcher(&scroll2);
EXPECT_EQ(2, handler.num_scroll_events());
root_window()->RemovePreTargetHandler(&handler);
@@ -627,7 +617,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::EventTimeForNow(),
+ ui::ET_MOUSE_PRESSED, gfx::PointF(), gfx::PointF(), ui::EventTimeForNow(),
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
host()->dispatcher()->RepostEvent(press_event);
RunAllPendingInMessageLoop(); // Necessitated by RepostEvent().
@@ -644,9 +634,9 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) {
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
&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), ui::EventTimeForNow(), 0,
- 0);
+ ui::MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::PointF(0.f, 0.f),
+ gfx::PointF(0.f, 0.f), ui::EventTimeForNow(),
+ 0, 0);
DispatchEventUsingWindowDispatcher(&mouse_move_event);
// Discard MOUSE_ENTER.
recorder.Reset();
@@ -654,17 +644,17 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) {
host()->dispatcher()->HoldPointerMoves();
// 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), ui::EventTimeForNow(), 0,
- 0);
+ ui::MouseEvent mouse_dragged_event(
+ ui::ET_MOUSE_DRAGGED, gfx::PointF(0.f, 0.f), gfx::PointF(0.f, 0.f),
+ 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), ui::EventTimeForNow(), 0,
- 0);
+ ui::MouseEvent mouse_pressed_event(
+ ui::ET_MOUSE_PRESSED, gfx::PointF(0.f, 0.f), gfx::PointF(0.f, 0.f),
+ ui::EventTimeForNow(), 0, 0);
DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
EventTypesToString(recorder.events()));
@@ -674,17 +664,17 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) {
// 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),
- ui::EventTimeForNow(), 0, 0);
- ui::MouseEvent mouse_dragged_event2(ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10),
- gfx::Point(10, 10), ui::EventTimeForNow(),
- 0, 0);
+ ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::PointF(0.f, 0.f),
+ gfx::PointF(0.f, 0.f), ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent mouse_dragged_event2(
+ ui::ET_MOUSE_DRAGGED, gfx::PointF(10.f, 10.f), gfx::PointF(10.f, 10.f),
+ 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),
- ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::PointF(0.f, 0.f),
+ gfx::PointF(0.f, 0.f), ui::EventTimeForNow(), 0, 0);
DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
EventTypesToString(recorder.events()));
@@ -693,8 +683,8 @@ 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),
- ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::PointF(0.f, 0.f),
+ gfx::PointF(0.f, 0.f), ui::EventTimeForNow(), 0, 0);
DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
host()->dispatcher()->ReleasePointerMoves();
EXPECT_TRUE(recorder.events().empty());
@@ -706,13 +696,13 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) {
// 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),
- ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::PointF(0.f, 0.f),
+ gfx::PointF(0.f, 0.f), 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),
- ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::PointF(0.f, 0.f),
+ gfx::PointF(0.f, 0.f), ui::EventTimeForNow(), 0, 0);
DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
EventTypesToString(recorder.events()));
@@ -724,13 +714,13 @@ TEST_F(WindowEventDispatcherTest, MouseMovesHeld) {
// them.
host()->dispatcher()->HoldPointerMoves();
mouse_dragged_event =
- ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
- ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::PointF(0.f, 0.f),
+ gfx::PointF(0.f, 0.f), 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), ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), ui::EventTimeForNow(), 0, 0);
DispatchEventUsingWindowDispatcher(&mouse_dragged_event2);
EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(recorder.events()));
recorder.Reset();
@@ -740,14 +730,14 @@ 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),
- ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::PointF(0.f, 0.f),
+ gfx::PointF(0.f, 0.f), 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), ui::EventTimeForNow(),
- 0, 0);
+ ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent mouse_dragged_event3(
+ ui::ET_MOUSE_DRAGGED, gfx::PointF(28.f, 28.f), gfx::PointF(28.f, 28.f),
+ ui::EventTimeForNow(), 0, 0);
host()->dispatcher()->HoldPointerMoves();
DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
DispatchEventUsingWindowDispatcher(&mouse_dragged_event2);
@@ -775,7 +765,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) {
// is going to generate synthetic mouse events that are not relevant to the
// test.
ui::TouchEvent touch_pressed_event(
- ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, ui::EventTimeForNow());
+ ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f), 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&touch_pressed_event);
recorder.WaitUntilReceivedEvent(ui::ET_GESTURE_SHOW_PRESS);
recorder.Reset();
@@ -783,12 +773,12 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) {
host()->dispatcher()->HoldPointerMoves();
// Check that we don't immediately dispatch the TOUCH_MOVED event.
- ui::TouchEvent touch_moved_event(
- ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 0, ui::EventTimeForNow());
- ui::TouchEvent touch_moved_event2(
- ui::ET_TOUCH_MOVED, gfx::Point(11, 10), 0, ui::EventTimeForNow());
- ui::TouchEvent touch_moved_event3(
- ui::ET_TOUCH_MOVED, gfx::Point(12, 10), 0, ui::EventTimeForNow());
+ ui::TouchEvent touch_moved_event(ui::ET_TOUCH_MOVED, gfx::PointF(10.f, 10.f),
+ 0, ui::EventTimeForNow());
+ ui::TouchEvent touch_moved_event2(ui::ET_TOUCH_MOVED, gfx::PointF(11.f, 10.f),
+ 0, ui::EventTimeForNow());
+ ui::TouchEvent touch_moved_event3(ui::ET_TOUCH_MOVED, gfx::PointF(12.f, 10.f),
+ 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&touch_moved_event);
EXPECT_TRUE(recorder.events().empty());
@@ -806,7 +796,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) {
// If another touch event occurs then the held touch should be dispatched
// immediately before it.
ui::TouchEvent touch_released_event(
- ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), 0, ui::EventTimeForNow());
+ ui::ET_TOUCH_RELEASED, gfx::PointF(10.f, 10.f), 0, ui::EventTimeForNow());
recorder.Reset();
host()->dispatcher()->HoldPointerMoves();
DispatchEventUsingWindowDispatcher(&touch_moved_event3);
@@ -837,7 +827,7 @@ TEST_F(WindowEventDispatcherTest, MouseEventWithoutTargetWindow) {
window_second->Show();
window_second->AddPreTargetHandler(&recorder_second);
- const gfx::Point event_location(22, 33);
+ const gfx::PointF event_location(22.f, 33.f);
ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
ui::EventTimeForNow(), 0, 0);
DispatchEventUsingWindowDispatcher(&mouse);
@@ -862,7 +852,7 @@ TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenHidingWindow) {
window->AddPreTargetHandler(&recorder);
// Dispatch a mouse move event into the window.
- const gfx::Point event_location(22, 33);
+ const gfx::PointF event_location(22.f, 33.f);
ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
ui::EventTimeForNow(), 0, 0);
DispatchEventUsingWindowDispatcher(&mouse);
@@ -958,7 +948,7 @@ TEST_F(WindowEventDispatcherTest, HeldTouchMoveContributesToGesture) {
EventFilterRecorder recorder;
root_window()->AddPreTargetHandler(&recorder);
- const gfx::Point location(20, 20);
+ const gfx::PointF location(20.f, 20.f);
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, location, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press);
@@ -968,8 +958,7 @@ TEST_F(WindowEventDispatcherTest, HeldTouchMoveContributesToGesture) {
host()->dispatcher()->HoldPointerMoves();
ui::TouchEvent move(ui::ET_TOUCH_MOVED,
- location + gfx::Vector2d(100, 100),
- 0,
+ location + gfx::Vector2dF(100.f, 100.f), 0,
ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&move);
EXPECT_FALSE(recorder.HasReceivedEvent(ui::ET_TOUCH_MOVED));
@@ -1001,15 +990,15 @@ TEST_F(WindowEventDispatcherTest, DispatchSyntheticMouseEvents) {
test::TestCursorClient cursor_client(root_window());
// 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), ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), 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::EventTimeForNow(),
+ ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), ui::EventTimeForNow(),
ui::EF_IS_SYNTHESIZED, 0);
DispatchEventUsingWindowDispatcher(&mouse2);
EXPECT_FALSE(recorder.events().empty());
@@ -1032,8 +1021,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::EventTimeForNow(),
+ ui::MouseEvent mouse1(ui::ET_MOUSE_PRESSED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), ui::EventTimeForNow(),
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
DispatchEventUsingWindowDispatcher(&mouse1);
ASSERT_EQ(1u, recorder.events().size());
@@ -1072,8 +1061,8 @@ TEST_F(WindowEventDispatcherTest,
window->AddPreTargetHandler(&recorder);
// 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), ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), ui::EventTimeForNow(), 0, 0);
DispatchEventUsingWindowDispatcher(&mouse);
EXPECT_FALSE(recorder.events().empty());
recorder.Reset();
@@ -1126,7 +1115,7 @@ TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenCursorHidden) {
window->Show();
// Dispatch a mouse move event into the window.
- gfx::Point mouse_location(gfx::Point(15, 25));
+ gfx::PointF mouse_location(15., 25.f);
ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, mouse_location, mouse_location,
ui::EventTimeForNow(), 0, 0);
EXPECT_TRUE(recorder.events().empty());
@@ -1163,7 +1152,7 @@ TEST_F(WindowEventDispatcherTest,
window->Show();
// Dispatch a mouse move event into the window.
- gfx::Point mouse_location(gfx::Point(15, 25));
+ gfx::PointF mouse_location(15.f, 25.f);
ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, mouse_location, mouse_location,
ui::EventTimeForNow(), 0, 0);
EXPECT_TRUE(recorder.events().empty());
@@ -1175,8 +1164,8 @@ TEST_F(WindowEventDispatcherTest,
cursor_client.DisableMouseEvents();
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::EventTimeForNow(),
+ ui::MouseEvent mouse2(ui::ET_MOUSE_EXITED, gfx::PointF(150.f, 150.f),
+ gfx::PointF(150.f, 150.f), ui::EventTimeForNow(),
ui::EF_IS_SYNTHESIZED, 0);
DispatchEventUsingWindowDispatcher(&mouse2);
@@ -1660,8 +1649,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::EventTimeForNow(),
+ ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), ui::EventTimeForNow(),
ui::EF_SHIFT_DOWN, 0);
root_->GetHost()->dispatcher()->RepostEvent(mouse_event);
}
@@ -1685,12 +1674,12 @@ TEST_F(WindowEventDispatcherTest, DontResetHeldEvent) {
DontResetHeldEventWindowDelegate delegate(root_window());
scoped_ptr<Window> 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::EventTimeForNow(),
+ ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), 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), ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), 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
@@ -1746,8 +1735,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::EventTimeForNow(),
+ ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), ui::EventTimeForNow(),
ui::EF_SHIFT_DOWN, 0);
h2->dispatcher()->RepostEvent(pressed);
// RunAllPendingInMessageLoop() to make sure the |pressed| is run.
@@ -1764,7 +1753,7 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveTouches) {
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
&delegate, 1, gfx::Rect(0, 0, 100, 100), root_window()));
- gfx::Point position1 = root_window()->bounds().origin();
+ auto position1 = gfx::PointF(root_window()->bounds().origin());
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, position1, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press);
@@ -1789,8 +1778,8 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveGestures) {
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
&delegate, 1, gfx::Rect(0, 0, 100, 100), root_window()));
- gfx::Point position1 = root_window()->bounds().origin();
- gfx::Point position2 = root_window()->bounds().CenterPoint();
+ auto position1 = gfx::PointF(root_window()->bounds().origin());
+ auto position2 = gfx::PointF(root_window()->bounds().CenterPoint());
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, position1, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press);
@@ -1848,12 +1837,12 @@ TEST_F(WindowEventDispatcherTest, EndingEventDoesntRetarget) {
window1->AddPreTargetHandler(&recorder1);
window2->AddPreTargetHandler(&recorder2);
- gfx::Point position = window1->bounds().origin();
+ auto position = gfx::PointF(window1->bounds().origin());
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, position, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press);
- gfx::Point position2 = window1->bounds().CenterPoint();
+ auto position2 = gfx::PointF(window1->bounds().CenterPoint());
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, position2, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&move);
@@ -1951,7 +1940,7 @@ class WindowEventDispatcherTestWithMessageLoop
// terminate the message-loop. When the message-loop unwinds and gets back,
// the reposted event should not have fired.
scoped_ptr<ui::MouseEvent> mouse(new ui::MouseEvent(
- ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10),
+ ui::ET_MOUSE_PRESSED, gfx::PointF(10.f, 10.f), gfx::PointF(10.f, 10.f),
ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE));
message_loop()->PostTask(
FROM_HERE,
@@ -2037,18 +2026,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::EventTimeForNow(), ui::EF_NONE,
- ui::EF_NONE);
+ ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::PointF(30.f, 30.f),
+ gfx::PointF(30.f, 30.f), 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::EventTimeForNow(), ui::EF_NONE,
- ui::EF_NONE);
+ ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::PointF(50.f, 50.f),
+ gfx::PointF(50.f, 50.f), 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());
@@ -2137,8 +2126,8 @@ TEST_F(WindowEventDispatcherTestInHighDPI,
// Make sure the window is visible.
RunAllPendingInMessageLoop();
- ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::Point(80, 80),
- gfx::Point(80, 80), ui::EventTimeForNow(),
+ ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::PointF(80.f, 80.f),
+ gfx::PointF(80.f, 80.f), ui::EventTimeForNow(),
ui::EF_NONE, ui::EF_NONE);
const base::Closure callback_on_right_click = base::Bind(
base::IgnoreResult(&WindowEventDispatcherTestInHighDPI::DispatchEvent),
@@ -2147,8 +2136,8 @@ TEST_F(WindowEventDispatcherTestInHighDPI,
window->AddPreTargetHandler(&handler);
scoped_ptr<ui::MouseEvent> mouse(
- new ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10),
- gfx::Point(10, 10), ui::EventTimeForNow(),
+ new ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::PointF(10.f, 10.f),
+ gfx::PointF(10.f, 10.f), ui::EventTimeForNow(),
ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON));
host()->dispatcher()->RepostEvent(*mouse);
EXPECT_EQ(0, handler.num_mouse_events());
@@ -2190,7 +2179,7 @@ TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) {
Env::GetInstance()->last_mouse_location().ToString());
// Synthesized event should not update the mouse location.
- ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
+ ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::PointF(), gfx::PointF(),
ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0);
generator.Dispatch(&mouseev);
EXPECT_EQ("10,10",
@@ -2285,8 +2274,9 @@ class DispatchEventHandler : public ui::EventHandler {
// 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::MouseEvent move(ui::ET_MOUSE_MOVED,
+ gfx::PointF(target_->bounds().CenterPoint()),
+ gfx::PointF(target_->bounds().CenterPoint()),
ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
ui::EventDispatchDetails details =
target_->GetHost()->dispatcher()->OnEventFromSource(&move);
@@ -2359,9 +2349,10 @@ TEST_F(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) {
EXPECT_NE(root_window(), second_root);
// Dispatch an event to |first|.
- ui::MouseEvent move(ui::ET_MOUSE_MOVED, first->bounds().CenterPoint(),
- first->bounds().CenterPoint(), ui::EventTimeForNow(),
- ui::EF_NONE, ui::EF_NONE);
+ ui::MouseEvent move(ui::ET_MOUSE_MOVED,
+ gfx::PointF(first->bounds().CenterPoint()),
+ gfx::PointF(first->bounds().CenterPoint()),
+ ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
ui::EventDispatchDetails details =
host()->dispatcher()->OnEventFromSource(&move);
ASSERT_FALSE(details.dispatcher_destroyed);
@@ -2457,7 +2448,7 @@ TEST_F(WindowEventDispatcherTest,
window_first->AddPreTargetHandler(&recorder_first);
EventFilterRecorder recorder_second;
window_second->AddPreTargetHandler(&recorder_second);
- const gfx::Point event_location(25, 15);
+ const gfx::PointF event_location(25.f, 15.f);
ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, event_location, event_location,
ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON);
@@ -2533,7 +2524,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) {
EventFilterRecorder recorder;
root_window()->AddPreTargetHandler(&recorder);
- const gfx::Point location(20, 20);
+ const gfx::PointF location(20.f, 20.f);
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, location, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press);
@@ -2542,8 +2533,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) {
recorder.Reset();
ui::TouchEvent move(ui::ET_TOUCH_MOVED,
- location + gfx::Vector2d(100, 100),
- 0,
+ location + gfx::Vector2dF(100.f, 100.f), 0,
ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&move);
EXPECT_TRUE(recorder.LastTouchMayCauseScrolling());
@@ -2553,8 +2543,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) {
recorder.Reset();
ui::TouchEvent move2(ui::ET_TOUCH_MOVED,
- location + gfx::Vector2d(200, 200),
- 0,
+ location + gfx::Vector2dF(200.f, 200.f), 0,
ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_TRUE(recorder.LastTouchMayCauseScrolling());
@@ -2564,9 +2553,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) {
// Delay the release to avoid fling generation.
ui::TouchEvent release(
- ui::ET_TOUCH_RELEASED,
- location + gfx::Vector2dF(200, 200),
- 0,
+ ui::ET_TOUCH_RELEASED, location + gfx::Vector2dF(200.f, 200.f), 0,
ui::EventTimeForNow() + base::TimeDelta::FromSeconds(1));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_FALSE(recorder.LastTouchMayCauseScrolling());

Powered by Google App Engine
This is Rietveld 408576698