summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-10 21:53:40 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-10 21:53:40 +0000
commitdd87b6eadc850d21a19c9e8bffd742074f638b83 (patch)
tree30dbc7794655c7ae3f302fa02c9e393769c17972 /views
parent2c57915bb705f2b45d525b56b103d930603441de (diff)
downloadchromium_src-dd87b6eadc850d21a19c9e8bffd742074f638b83.zip
chromium_src-dd87b6eadc850d21a19c9e8bffd742074f638b83.tar.gz
chromium_src-dd87b6eadc850d21a19c9e8bffd742074f638b83.tar.bz2
touchui: Gesture manager should ignore already handled touch events.
BUG=none TEST=none Review URL: http://codereview.chromium.org/6184002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/touchui/gesture_manager.cc3
-rw-r--r--views/view_unittest.cc52
2 files changed, 44 insertions, 11 deletions
diff --git a/views/touchui/gesture_manager.cc b/views/touchui/gesture_manager.cc
index 5f0cbd5..05e0ced 100644
--- a/views/touchui/gesture_manager.cc
+++ b/views/touchui/gesture_manager.cc
@@ -23,6 +23,9 @@ GestureManager* GestureManager::GetInstance() {
bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event,
View* source,
bool previouslyHandled) {
+ if (previouslyHandled)
+ return false;
+
// TODO(rjkroege): A realistic version of the GestureManager will
// appear in a subsequent CL. This interim version permits verifying that the
// event distribution code works by turning all touch inputs into
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 721bab7..f5d564d 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -214,16 +214,18 @@ class MockGestureManager : public GestureManager {
last_touch_event_ = 0;
last_view_ = NULL;
previously_handled_flag_ = false;
+ dispatched_synthetic_event_ = false;
}
- bool previously_handled_flag_;
bool ProcessTouchEventForGesture(const TouchEvent& event,
View* source,
bool previouslyHandled);
MockGestureManager();
+ bool previously_handled_flag_;
int last_touch_event_;
View *last_view_;
+ bool dispatched_synthetic_event_;
DISALLOW_COPY_AND_ASSIGN(MockGestureManager);
};
@@ -431,9 +433,14 @@ bool MockGestureManager::ProcessTouchEventForGesture(
const TouchEvent& event,
View* source,
bool previouslyHandled) {
+ if (previouslyHandled) {
+ dispatched_synthetic_event_ = false;
+ return false;
+ }
last_touch_event_ = event.GetType();
last_view_ = source;
previously_handled_flag_ = previouslyHandled;
+ dispatched_synthetic_event_ = true;
return true;
}
@@ -470,6 +477,28 @@ TEST_F(ViewTest, TouchEvent) {
root->SetGestureManager(gm);
v1->AddChildView(v2);
+ // Make sure if none of the views handle the touch event, the gesture manager
+ // does.
+ v1->Reset();
+ v2->Reset();
+ gm->Reset();
+
+ TouchEvent unhandled(Event::ET_TOUCH_MOVED,
+ 400,
+ 400,
+ 0, /* no flags */
+ 0 /* first finger touch */);
+ root->OnTouchEvent(unhandled);
+
+ EXPECT_EQ(v1->last_touch_event_type_, 0);
+ EXPECT_EQ(v2->last_touch_event_type_, 0);
+
+ EXPECT_EQ(gm->previously_handled_flag_, false);
+ EXPECT_EQ(gm->last_touch_event_, Event::ET_TOUCH_MOVED);
+ EXPECT_EQ(gm->last_view_, root);
+ EXPECT_EQ(gm->dispatched_synthetic_event_, true);
+
+ // Test press, drag, release touch sequence.
v1->Reset();
v2->Reset();
gm->Reset();
@@ -488,9 +517,10 @@ TEST_F(ViewTest, TouchEvent) {
// Make sure v1 did not receive the event
EXPECT_EQ(v1->last_touch_event_type_, 0);
- EXPECT_EQ(gm->last_touch_event_, Event::ET_TOUCH_PRESSED);
- EXPECT_EQ(gm->last_view_, root);
- EXPECT_EQ(gm->previously_handled_flag_, true);
+ // Since v2 handled the touch-event, the gesture manager should not handle it.
+ EXPECT_EQ(gm->last_touch_event_, 0);
+ EXPECT_EQ(NULL, gm->last_view_);
+ EXPECT_EQ(gm->previously_handled_flag_, false);
// Drag event out of bounds. Should still go to v2
v1->Reset();
@@ -507,11 +537,11 @@ TEST_F(ViewTest, TouchEvent) {
// Make sure v1 did not receive the event
EXPECT_EQ(v1->last_touch_event_type_, 0);
- EXPECT_EQ(gm->last_touch_event_, Event::ET_TOUCH_MOVED);
- EXPECT_EQ(gm->last_view_, root);
- EXPECT_EQ(gm->previously_handled_flag_, true);
+ EXPECT_EQ(gm->last_touch_event_, 0);
+ EXPECT_EQ(NULL, gm->last_view_);
+ EXPECT_EQ(gm->previously_handled_flag_, false);
- // Releasted event out of bounds. Should still go to v2
+ // Released event out of bounds. Should still go to v2
v1->Reset();
v2->Reset();
TouchEvent released(Event::ET_TOUCH_RELEASED, 0, 0, 0, 0 /* first finger */);
@@ -523,9 +553,9 @@ TEST_F(ViewTest, TouchEvent) {
// Make sure v1 did not receive the event
EXPECT_EQ(v1->last_touch_event_type_, 0);
- EXPECT_EQ(gm->last_touch_event_, Event::ET_TOUCH_RELEASED);
- EXPECT_EQ(gm->last_view_, root);
- EXPECT_EQ(gm->previously_handled_flag_, true);
+ EXPECT_EQ(gm->last_touch_event_, 0);
+ EXPECT_EQ(NULL, gm->last_view_);
+ EXPECT_EQ(gm->previously_handled_flag_, false);
window->CloseNow();
}