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

Unified Diff: ui/views/view_unittest.cc

Issue 2786693002: Add PointerDetails to ui::MouseEvent's constructors (Closed)
Patch Set: mouse event constructor Created 3 years, 9 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/views/view_unittest.cc
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index b4b2a1e12eeac66df525d12a3c283b20eebd5585..4435ca4d2e5a3836b1c86a07fbf0373efc623ec9 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -403,8 +403,10 @@ TEST_F(ViewTest, MouseEvent) {
v2->Reset();
gfx::Point p1(110, 120);
- ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent pressed(
+ ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(),
+ ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMousePressed(pressed);
EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_PRESSED);
EXPECT_EQ(v2->location_.x(), 10);
@@ -416,8 +418,10 @@ TEST_F(ViewTest, MouseEvent) {
v1->Reset();
v2->Reset();
gfx::Point p2(50, 40);
- ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, p2, p2, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, 0);
+ ui::MouseEvent dragged(
+ ui::ET_MOUSE_DRAGGED, p2, p2, ui::EventTimeForNow(),
+ ui::EF_LEFT_MOUSE_BUTTON, 0,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMouseDragged(dragged);
EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_DRAGGED);
EXPECT_EQ(v2->location_.x(), -50);
@@ -428,8 +432,9 @@ 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(),
- ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent released(
+ ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
+ 0, 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMouseDragged(released);
EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_RELEASED);
EXPECT_EQ(v2->location_.x(), -100);
@@ -463,9 +468,10 @@ TEST_F(ViewTest, DeleteOnPressed) {
v2->delete_on_pressed_ = true;
gfx::Point point(110, 120);
- ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point,
- ui::EventTimeForNow(), 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,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMousePressed(pressed);
EXPECT_EQ(0, v1->child_count());
@@ -1867,7 +1873,9 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) {
// Move the mouse in v111.
gfx::Point p1(6, 6);
- ui::MouseEvent move1(ui::ET_MOUSE_MOVED, p1, p1, ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent move1(
+ ui::ET_MOUSE_MOVED, p1, p1, ui::EventTimeForNow(), 0, 0,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root_view->OnMouseMoved(move1);
EXPECT_TRUE(v111->received_mouse_enter_);
EXPECT_FALSE(v11->last_mouse_event_type_);
@@ -1878,7 +1886,9 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) {
// Now, move into v121.
gfx::Point p2(65, 21);
- ui::MouseEvent move2(ui::ET_MOUSE_MOVED, p2, p2, ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent move2(
+ ui::ET_MOUSE_MOVED, p2, p2, ui::EventTimeForNow(), 0, 0,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root_view->OnMouseMoved(move2);
EXPECT_TRUE(v111->received_mouse_exit_);
EXPECT_TRUE(v121->received_mouse_enter_);
@@ -1889,7 +1899,9 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) {
// Now, move into v11.
gfx::Point p3(1, 1);
- ui::MouseEvent move3(ui::ET_MOUSE_MOVED, p3, p3, ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent move3(
+ ui::ET_MOUSE_MOVED, p3, p3, ui::EventTimeForNow(), 0, 0,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root_view->OnMouseMoved(move3);
EXPECT_TRUE(v121->received_mouse_exit_);
EXPECT_TRUE(v11->received_mouse_enter_);
@@ -1900,7 +1912,9 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) {
// Move to v21.
gfx::Point p4(121, 15);
- ui::MouseEvent move4(ui::ET_MOUSE_MOVED, p4, p4, ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent move4(
+ ui::ET_MOUSE_MOVED, p4, p4, ui::EventTimeForNow(), 0, 0,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root_view->OnMouseMoved(move4);
EXPECT_TRUE(v21->received_mouse_enter_);
EXPECT_FALSE(v2->last_mouse_event_type_);
@@ -1913,7 +1927,9 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) {
// Move to v1.
gfx::Point p5(21, 0);
- ui::MouseEvent move5(ui::ET_MOUSE_MOVED, p5, p5, ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent move5(
+ ui::ET_MOUSE_MOVED, p5, p5, ui::EventTimeForNow(), 0, 0,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root_view->OnMouseMoved(move5);
EXPECT_TRUE(v21->received_mouse_exit_);
EXPECT_TRUE(v1->received_mouse_enter_);
@@ -1923,8 +1939,9 @@ TEST_F(ViewTest, NotifyEnterExitOnChild) {
// Now, move into v11.
gfx::Point p6(15, 15);
- ui::MouseEvent mouse6(ui::ET_MOUSE_MOVED, p6, p6, ui::EventTimeForNow(), 0,
- 0);
+ ui::MouseEvent mouse6(
+ ui::ET_MOUSE_MOVED, p6, p6, ui::EventTimeForNow(), 0, 0,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root_view->OnMouseMoved(mouse6);
EXPECT_TRUE(v11->received_mouse_enter_);
EXPECT_FALSE(v1->last_mouse_event_type_);
@@ -1936,8 +1953,9 @@ 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, ui::EventTimeForNow(), 0,
- 0);
+ ui::MouseEvent mouse7(
+ ui::ET_MOUSE_MOVED, p7, p7, ui::EventTimeForNow(), 0, 0,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root_view->OnMouseMoved(mouse7);
EXPECT_TRUE(v11->received_mouse_exit_);
EXPECT_FALSE(v1->received_mouse_enter_);
@@ -2583,16 +2601,19 @@ TEST_F(ViewTest, TransformEvent) {
v2->Reset();
gfx::Point p1(110, 210);
- ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent pressed(
+ ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(),
+ ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMousePressed(pressed);
EXPECT_EQ(0, v1->last_mouse_event_type_);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_);
EXPECT_EQ(190, v2->location_.x());
EXPECT_EQ(10, v2->location_.y());
- ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(),
- ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent released(
+ ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
+ 0, 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMouseReleased(released);
// Now rotate |v2| inside |v1| clockwise.
@@ -2608,8 +2629,10 @@ TEST_F(ViewTest, TransformEvent) {
v2->Reset();
gfx::Point point2(110, 320);
- ui::MouseEvent p2(ui::ET_MOUSE_PRESSED, point2, point2, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent p2(
+ ui::ET_MOUSE_PRESSED, point2, point2, ui::EventTimeForNow(),
+ ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMousePressed(p2);
EXPECT_EQ(0, v1->last_mouse_event_type_);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_);
@@ -2644,8 +2667,10 @@ TEST_F(ViewTest, TransformEvent) {
v3->Reset();
gfx::Point point(112, 110);
- ui::MouseEvent p3(ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent p3(
+ ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(),
+ ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMousePressed(p3);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_);
@@ -2683,8 +2708,10 @@ 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::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent p4(
+ ui::ET_MOUSE_PRESSED, point3, point3, ui::EventTimeForNow(),
+ ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMousePressed(p4);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_);
@@ -4627,8 +4654,10 @@ TEST_F(ViewTest, ScopedTargetHandlerReceivesEvents) {
EXPECT_EQ(ui::ET_UNKNOWN, v->last_mouse_event_type_);
gfx::Point p(10, 120);
- ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p, p, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent pressed(
+ ui::ET_MOUSE_PRESSED, p, p, ui::EventTimeForNow(),
+ ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMousePressed(pressed);
// Both the View |v| and the |handler| should have received the event.
@@ -4638,8 +4667,9 @@ TEST_F(ViewTest, ScopedTargetHandlerReceivesEvents) {
// The View should continue receiving events after the |handler| is deleted.
v->Reset();
- ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(),
- ui::EventTimeForNow(), 0, 0);
+ ui::MouseEvent released(
+ ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
+ 0, 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
root->OnMouseReleased(released);
EXPECT_EQ(ui::ET_MOUSE_RELEASED, v->last_mouse_event_type_);
}

Powered by Google App Engine
This is Rietveld 408576698