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

Unified Diff: ui/views/view_unittest.cc

Issue 10832282: Replace views::MouseEvent with ui::MouseEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « ui/views/view.cc ('k') | ui/views/widget/native_widget_aura.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view_unittest.cc
===================================================================
--- ui/views/view_unittest.cc (revision 151406)
+++ ui/views/view_unittest.cc (working copy)
@@ -214,11 +214,11 @@
}
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
- virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
- virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE;
- virtual void OnMouseExited(const MouseEvent& event) OVERRIDE;
+ virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
+ virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE;
// Ignores GestureEvent by default.
virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE;
@@ -342,7 +342,7 @@
// MouseEvent
////////////////////////////////////////////////////////////////////////////////
-bool TestView::OnMousePressed(const MouseEvent& event) {
+bool TestView::OnMousePressed(const ui::MouseEvent& event) {
last_mouse_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
if (delete_on_pressed_)
@@ -350,22 +350,22 @@
return true;
}
-bool TestView::OnMouseDragged(const MouseEvent& event) {
+bool TestView::OnMouseDragged(const ui::MouseEvent& event) {
last_mouse_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
return true;
}
-void TestView::OnMouseReleased(const MouseEvent& event) {
+void TestView::OnMouseReleased(const ui::MouseEvent& event) {
last_mouse_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
}
-void TestView::OnMouseEntered(const MouseEvent& event) {
+void TestView::OnMouseEntered(const ui::MouseEvent& event) {
received_mouse_enter_ = true;
}
-void TestView::OnMouseExited(const MouseEvent& event) {
+void TestView::OnMouseExited(const ui::MouseEvent& event) {
received_mouse_exit_ = true;
}
@@ -389,10 +389,9 @@
v1->Reset();
v2->Reset();
- MouseEvent pressed(ui::ET_MOUSE_PRESSED,
- 110,
- 120,
- ui::EF_LEFT_MOUSE_BUTTON);
+ gfx::Point p1(110, 120);
+ ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1,
+ ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(pressed);
EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_PRESSED);
EXPECT_EQ(v2->location_.x(), 10);
@@ -403,10 +402,9 @@
// Drag event out of bounds. Should still go to v2
v1->Reset();
v2->Reset();
- MouseEvent dragged(ui::ET_MOUSE_DRAGGED,
- 50,
- 40,
- ui::EF_LEFT_MOUSE_BUTTON);
+ gfx::Point p2(50, 40);
+ ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, p2, p2,
+ ui::EF_LEFT_MOUSE_BUTTON);
root->OnMouseDragged(dragged);
EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_DRAGGED);
EXPECT_EQ(v2->location_.x(), -50);
@@ -417,7 +415,7 @@
// Releasted event out of bounds. Should still go to v2
v1->Reset();
v2->Reset();
- MouseEvent released(ui::ET_MOUSE_RELEASED, 0, 0, 0);
+ ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0);
root->OnMouseDragged(released);
EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_RELEASED);
EXPECT_EQ(v2->location_.x(), -100);
@@ -450,10 +448,9 @@
v1->AddChildView(v2);
v2->delete_on_pressed_ = true;
- MouseEvent pressed(ui::ET_MOUSE_PRESSED,
- 110,
- 120,
- ui::EF_LEFT_MOUSE_BUTTON);
+ gfx::Point point(110, 120);
+ ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point,
+ ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(pressed);
EXPECT_EQ(0, v1->child_count());
@@ -1074,7 +1071,8 @@
v21->Reset();
// Move the mouse in v111.
- MouseEvent move1(ui::ET_MOUSE_MOVED, 6, 6, 0);
+ gfx::Point p1(6, 6);
+ ui::MouseEvent move1(ui::ET_MOUSE_MOVED, p1, p1, 0);
root_view->OnMouseMoved(move1);
EXPECT_TRUE(v111->received_mouse_enter_);
EXPECT_FALSE(v11->last_mouse_event_type_);
@@ -1084,7 +1082,8 @@
v1->Reset();
// Now, move into v121.
- MouseEvent move2(ui::ET_MOUSE_MOVED, 65, 21, 0);
+ gfx::Point p2(65, 21);
+ ui::MouseEvent move2(ui::ET_MOUSE_MOVED, p2, p2, 0);
root_view->OnMouseMoved(move2);
EXPECT_TRUE(v111->received_mouse_exit_);
EXPECT_TRUE(v121->received_mouse_enter_);
@@ -1094,7 +1093,8 @@
v121->Reset();
// Now, move into v11.
- MouseEvent move3(ui::ET_MOUSE_MOVED, 1, 1, 0);
+ gfx::Point p3(1, 1);
+ ui::MouseEvent move3(ui::ET_MOUSE_MOVED, p3, p3, 0);
root_view->OnMouseMoved(move3);
EXPECT_TRUE(v121->received_mouse_exit_);
EXPECT_TRUE(v11->received_mouse_enter_);
@@ -1104,7 +1104,8 @@
v11->Reset();
// Move to v21.
- MouseEvent move4(ui::ET_MOUSE_MOVED, 121, 15, 0);
+ gfx::Point p4(121, 15);
+ ui::MouseEvent move4(ui::ET_MOUSE_MOVED, p4, p4, 0);
root_view->OnMouseMoved(move4);
EXPECT_TRUE(v21->received_mouse_enter_);
EXPECT_FALSE(v2->last_mouse_event_type_);
@@ -1116,7 +1117,8 @@
v1->Reset();
// Move to v1.
- MouseEvent move5(ui::ET_MOUSE_MOVED, 21, 0, 0);
+ gfx::Point p5(21, 0);
+ ui::MouseEvent move5(ui::ET_MOUSE_MOVED, p5, p5, 0);
root_view->OnMouseMoved(move5);
EXPECT_TRUE(v21->received_mouse_exit_);
EXPECT_TRUE(v1->received_mouse_enter_);
@@ -1125,7 +1127,8 @@
v1->Reset();
// Now, move into v11.
- MouseEvent mouse6(ui::ET_MOUSE_MOVED, 15, 15, 0);
+ gfx::Point p6(15, 15);
+ ui::MouseEvent mouse6(ui::ET_MOUSE_MOVED, p6, p6, 0);
root_view->OnMouseMoved(mouse6);
EXPECT_TRUE(v11->received_mouse_enter_);
EXPECT_FALSE(v1->last_mouse_event_type_);
@@ -1136,7 +1139,8 @@
// Move back into v1. Although |v1| had already received an ENTER for mouse6,
// and the mouse remains inside |v1| the whole time, it receives another ENTER
// when the mouse leaves v11.
- MouseEvent mouse7(ui::ET_MOUSE_MOVED, 21, 0, 0);
+ gfx::Point p7(21, 0);
+ ui::MouseEvent mouse7(ui::ET_MOUSE_MOVED, p7, p7, 0);
root_view->OnMouseMoved(mouse7);
EXPECT_TRUE(v11->received_mouse_exit_);
EXPECT_FALSE(v1->received_mouse_enter_);
@@ -1814,9 +1818,11 @@
// Ensure that regular clicks on the drop down button still work. (i.e. - the
// click events are processed and the listener gets the click)
TEST_F(ButtonDropDownTest, RegularClickTest) {
- MouseEvent press_event(ui::ET_MOUSE_PRESSED, 1, 1, ui::EF_LEFT_MOUSE_BUTTON);
- MouseEvent release_event(ui::ET_MOUSE_RELEASED, 1, 1,
- ui::EF_LEFT_MOUSE_BUTTON);
+ gfx::Point point(1, 1);
+ ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, point, point,
+ ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, point, point,
+ ui::EF_LEFT_MOUSE_BUTTON);
button_as_view_->OnMousePressed(press_event);
button_as_view_->OnMouseReleased(release_event);
EXPECT_EQ(test_dialog_->last_pressed_button_, test_dialog_->button_drop_);
@@ -2072,16 +2078,16 @@
v1->Reset();
v2->Reset();
- MouseEvent pressed(ui::ET_MOUSE_PRESSED,
- 110, 210,
- ui::EF_LEFT_MOUSE_BUTTON);
+ gfx::Point p1(110, 210);
+ ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1,
+ ui::EF_LEFT_MOUSE_BUTTON);
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());
- MouseEvent released(ui::ET_MOUSE_RELEASED, 0, 0, 0);
+ ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0);
root->OnMouseReleased(released);
// Now rotate |v2| inside |v1| clockwise.
@@ -2096,9 +2102,9 @@
v1->Reset();
v2->Reset();
- MouseEvent p2(ui::ET_MOUSE_PRESSED,
- 110, 320,
- ui::EF_LEFT_MOUSE_BUTTON);
+ gfx::Point point2(110, 320);
+ ui::MouseEvent p2(ui::ET_MOUSE_PRESSED, point2, point2,
+ ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(p2);
EXPECT_EQ(0, v1->last_mouse_event_type_);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_);
@@ -2131,9 +2137,9 @@
v2->Reset();
v3->Reset();
- MouseEvent p3(ui::ET_MOUSE_PRESSED,
- 112, 110,
- ui::EF_LEFT_MOUSE_BUTTON);
+ gfx::Point point(112, 110);
+ ui::MouseEvent p3(ui::ET_MOUSE_PRESSED, point, point,
+ ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(p3);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_);
@@ -2167,9 +2173,9 @@
// |v3| now occupies (120, 120) to (144, 130) in |root|.
- MouseEvent p4(ui::ET_MOUSE_PRESSED,
- 124, 125,
- ui::EF_LEFT_MOUSE_BUTTON);
+ gfx::Point point3(124, 125);
+ ui::MouseEvent p4(ui::ET_MOUSE_PRESSED, point3, point3,
+ ui::EF_LEFT_MOUSE_BUTTON);
root->OnMousePressed(p4);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_);
« no previous file with comments | « ui/views/view.cc ('k') | ui/views/widget/native_widget_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698