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

Unified Diff: ui/aura/root_window_unittest.cc

Issue 10823295: aura: Dispatch touch-events targetted to the root-window properly. (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/aura/root_window.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/root_window_unittest.cc
diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc
index 48b3743fd5105f797ef9865561a09189ba3fa537..c23a8881747d74d6967312f9492d01db42af864a 100644
--- a/ui/aura/root_window_unittest.cc
+++ b/ui/aura/root_window_unittest.cc
@@ -69,11 +69,16 @@ class NonClientDelegate : public test::TestWindowDelegate {
// seen.
class EventCountFilter : public EventFilter {
public:
- EventCountFilter() : num_key_events_(0), num_mouse_events_(0) {}
+ EventCountFilter()
+ : num_key_events_(0),
+ num_mouse_events_(0),
+ num_touch_events_(0) {
+ }
virtual ~EventCountFilter() {}
int num_key_events() const { return num_key_events_; }
int num_mouse_events() const { return num_mouse_events_; }
+ int num_touch_events() const { return num_touch_events_; }
void Reset() {
num_key_events_ = 0;
@@ -92,6 +97,7 @@ class EventCountFilter : public EventFilter {
}
virtual ui::TouchStatus PreHandleTouchEvent(
Window* target, ui::TouchEvent* event) OVERRIDE {
+ num_touch_events_++;
return ui::TOUCH_STATUS_UNKNOWN;
}
virtual ui::GestureStatus PreHandleGestureEvent(
@@ -106,6 +112,8 @@ class EventCountFilter : public EventFilter {
// How many mouse events have been received?
int num_mouse_events_;
+ int num_touch_events_;
+
DISALLOW_COPY_AND_ASSIGN(EventCountFilter);
};
@@ -345,6 +353,26 @@ TEST_F(RootWindowTest, IgnoreUnknownKeys) {
EXPECT_EQ(1, filter->num_key_events());
}
+// Tests that touch-events that are beyond the bounds of the root-window do get
+// propagated to the event filters correctly with the root as the target.
+TEST_F(RootWindowTest, TouchEventsOutsideBounds) {
+ EventCountFilter* filter = new EventCountFilter;
+ root_window()->SetEventFilter(filter); // passes ownership
+
+ gfx::Point position = root_window()->bounds().origin();
+ position.Offset(-10, -10);
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position, 0, base::TimeDelta());
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
+ EXPECT_EQ(1, filter->num_touch_events());
+
+ position = root_window()->bounds().origin();
+ position.Offset(root_window()->bounds().width() + 10,
+ root_window()->bounds().height() + 10);
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, position, 0, base::TimeDelta());
+ root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
+ EXPECT_EQ(2, filter->num_touch_events());
+}
+
namespace {
// FilterFilter that tracks the types of events it's seen.
« no previous file with comments | « ui/aura/root_window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698