summaryrefslogtreecommitdiffstats
path: root/ui/aura/gestures/gesture_recognizer_unittest.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 00:16:59 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 00:16:59 +0000
commita8dffcec83c5eba7b9f17b03e0e35f28b44a8d52 (patch)
tree27e7dc26d245d83d5a8b81318d236d19e0ae0c21 /ui/aura/gestures/gesture_recognizer_unittest.cc
parent06ea3e51e4ca77a6e16f549eff9094c472786f91 (diff)
downloadchromium_src-a8dffcec83c5eba7b9f17b03e0e35f28b44a8d52.zip
chromium_src-a8dffcec83c5eba7b9f17b03e0e35f28b44a8d52.tar.gz
chromium_src-a8dffcec83c5eba7b9f17b03e0e35f28b44a8d52.tar.bz2
Take 2 at: Changes RootWindow capture code so that we only have one capture
type. Makes gesture generated mouse events use the right mouse generating code so that we generate the correct enter/exit/moved events and update the appropriate state. BUG=115684 TEST=covered by unit tests TBR=sadrul@chromium.org Review URL: https://chromiumcodereview.appspot.com/10332141 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137030 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/gestures/gesture_recognizer_unittest.cc')
-rw-r--r--ui/aura/gestures/gesture_recognizer_unittest.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index 20ff390..863041b 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/memory/scoped_vector.h"
+#include "base/string_number_conversions.h"
#include "base/timer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/event.h"
@@ -23,6 +24,11 @@ namespace test {
namespace {
+std::string WindowIDAsString(ui::GestureConsumer* consumer) {
+ return consumer && !consumer->ignores_events() ?
+ base::IntToString(static_cast<Window*>(consumer)->id()) : "?";
+}
+
// A delegate that keeps track of gesture events.
class GestureEventConsumeDelegate : public TestWindowDelegate {
public:
@@ -923,17 +929,17 @@ TEST_F(GestureRecognizerTest, GestureTapSyntheticMouse) {
EXPECT_TRUE(delegate->mouse_enter());
EXPECT_TRUE(delegate->mouse_press());
EXPECT_TRUE(delegate->mouse_release());
- EXPECT_TRUE(delegate->mouse_exit());
+ EXPECT_FALSE(delegate->mouse_exit());
EXPECT_FALSE(delegate->double_click());
delegate->Reset();
GestureEvent tap2(ui::ET_GESTURE_DOUBLE_TAP, 20, 20, 0,
base::Time::Now(), 0, 0, 1 << kTouchId);
root_window()->DispatchGestureEvent(&tap2);
- EXPECT_TRUE(delegate->mouse_enter());
+ EXPECT_FALSE(delegate->mouse_enter());
EXPECT_TRUE(delegate->mouse_press());
EXPECT_TRUE(delegate->mouse_release());
- EXPECT_TRUE(delegate->mouse_exit());
+ EXPECT_FALSE(delegate->mouse_exit());
EXPECT_TRUE(delegate->double_click());
}
@@ -1397,6 +1403,7 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
delegates[i] = new GestureEventConsumeDelegate();
windows[i] = CreateTestWindowWithDelegate(
delegates[i], i, *window_bounds[i], NULL);
+ windows[i]->set_id(i);
TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i]->origin(),
i, GetTime());
root_window()->DispatchTouchEvent(&press);
@@ -1405,13 +1412,13 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
// Touches should now be associated with the closest touch within
// ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels
target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11));
- EXPECT_EQ(windows[0], target);
+ EXPECT_EQ("0", WindowIDAsString(target));
target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11));
- EXPECT_EQ(windows[1], target);
+ EXPECT_EQ("1", WindowIDAsString(target));
target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 511));
- EXPECT_EQ(windows[2], target);
+ EXPECT_EQ("2", WindowIDAsString(target));
target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 511));
- EXPECT_EQ(windows[3], target);
+ EXPECT_EQ("3", WindowIDAsString(target));
// Add a touch in the middle associated with windows[2]
TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 500),
@@ -1422,16 +1429,16 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
root_window()->DispatchTouchEvent(&move);
target = gesture_recognizer->GetTargetForLocation(gfx::Point(250, 250));
- EXPECT_EQ(windows[2], target);
+ EXPECT_EQ("2", WindowIDAsString(target));
// Make sure that ties are broken by distance to a current touch
// Closer to the point in the bottom right.
target = gesture_recognizer->GetTargetForLocation(gfx::Point(380, 380));
- EXPECT_EQ(windows[3], target);
+ EXPECT_EQ("3", WindowIDAsString(target));
// This touch is closer to the point in the middle
target = gesture_recognizer->GetTargetForLocation(gfx::Point(300, 300));
- EXPECT_EQ(windows[2], target);
+ EXPECT_EQ("2", WindowIDAsString(target));
// A touch too far from other touches won't be locked to anything
target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000));
@@ -1443,7 +1450,7 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
root_window()->DispatchTouchEvent(&move2);
target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000));
- EXPECT_EQ(windows[2], target);
+ EXPECT_EQ("2", WindowIDAsString(target));
}
// Check that touch events outside the root window are still handled