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

Unified Diff: ui/views/view_unittest.cc

Issue 406943002: Add test WidgetTest.GestureEventDispatch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « no previous file | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view_unittest.cc
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index 48ec8d758e54c9e4e0aa70233f5cf60f74c488aa..b1cac7eef7be8f3c13a1c38a7168a373277634b8 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -485,84 +485,6 @@ TEST_F(ViewTest, DeleteOnPressed) {
void TestView::OnGestureEvent(ui::GestureEvent* event) {
}
-TEST_F(ViewTest, GestureEvent) {
- // Views hierarchy for non delivery of GestureEvent.
- TestView* v1 = new TestViewConsumeGesture();
- v1->SetBoundsRect(gfx::Rect(0, 0, 300, 300));
-
- TestView* v2 = new TestViewConsumeGesture();
- v2->SetBoundsRect(gfx::Rect(100, 100, 100, 100));
-
- TestView* v3 = new TestViewIgnoreGesture();
- v3->SetBoundsRect(gfx::Rect(0, 0, 100, 100));
-
- scoped_ptr<Widget> widget(new Widget());
- Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
- params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.bounds = gfx::Rect(50, 50, 650, 650);
- widget->Init(params);
- internal::RootView* root =
- static_cast<internal::RootView*>(widget->GetRootView());
- ui::EventDispatchDetails details;
-
- root->AddChildView(v1);
- v1->AddChildView(v2);
- v2->AddChildView(v3);
-
- // |v3| completely obscures |v2|, but all the gesture events on |v3| should
- // reach |v2| because |v3| doesn't process any gesture events. However, since
- // |v2| does process gesture events, gesture events on |v3| or |v2| should not
- // reach |v1|.
-
- v1->Reset();
- v2->Reset();
- v3->Reset();
-
- // Gesture on |v3|
- GestureEventForTest g1(ui::ET_GESTURE_TAP, 110, 110, 0);
- details = root->OnEventFromSource(&g1);
- EXPECT_FALSE(details.dispatcher_destroyed);
- EXPECT_FALSE(details.target_destroyed);
-
- EXPECT_EQ(ui::ET_GESTURE_TAP, v2->last_gesture_event_type_);
- EXPECT_EQ(gfx::Point(10, 10), v2->location_);
- EXPECT_EQ(ui::ET_UNKNOWN, v1->last_gesture_event_type_);
-
- // Simulate an up so that RootView is no longer targetting |v3|.
- GestureEventForTest g1_up(ui::ET_GESTURE_END, 110, 110, 0);
- details = root->OnEventFromSource(&g1_up);
- EXPECT_FALSE(details.dispatcher_destroyed);
- EXPECT_FALSE(details.target_destroyed);
-
- v1->Reset();
- v2->Reset();
- v3->Reset();
-
- // Gesture on |v1|
- GestureEventForTest g2(ui::ET_GESTURE_TAP, 80, 80, 0);
- details = root->OnEventFromSource(&g2);
- EXPECT_FALSE(details.dispatcher_destroyed);
- EXPECT_FALSE(details.target_destroyed);
-
- EXPECT_EQ(ui::ET_GESTURE_TAP, v1->last_gesture_event_type_);
- EXPECT_EQ(gfx::Point(80, 80), v1->location_);
- EXPECT_EQ(ui::ET_UNKNOWN, v2->last_gesture_event_type_);
-
- // Send event |g1| again. Even though the coordinates target |v3| it should go
- // to |v1| as that is the view the touch was initially down on.
- v1->last_gesture_event_type_ = ui::ET_UNKNOWN;
- v3->last_gesture_event_type_ = ui::ET_UNKNOWN;
- details = root->OnEventFromSource(&g1);
- EXPECT_FALSE(details.dispatcher_destroyed);
- EXPECT_FALSE(details.target_destroyed);
-
- EXPECT_EQ(ui::ET_GESTURE_TAP, v1->last_gesture_event_type_);
- EXPECT_EQ(ui::ET_UNKNOWN, v3->last_gesture_event_type_);
- EXPECT_EQ("110,110", v1->location_.ToString());
-
- widget->CloseNow();
-}
-
TEST_F(ViewTest, ScrollGestureEvent) {
// Views hierarchy for non delivery of GestureEvent.
TestView* v1 = new TestViewConsumeGesture();
« no previous file with comments | « no previous file | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698