summaryrefslogtreecommitdiffstats
path: root/aura
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 18:32:33 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 18:32:33 +0000
commitddf5ff7b90b443c64c124f328cbc5b2f133de601 (patch)
tree95aaf27f61722a470209a3fa8c150a9a8ad2546c /aura
parent5466c9f369999f03d9067fd01953ce326ac3affd (diff)
downloadchromium_src-ddf5ff7b90b443c64c124f328cbc5b2f133de601.zip
chromium_src-ddf5ff7b90b443c64c124f328cbc5b2f133de601.tar.gz
chromium_src-ddf5ff7b90b443c64c124f328cbc5b2f133de601.tar.bz2
Proper MouseEvent targeting. Adds a Window method that locates a Window for a given point.
Also adds an Aura test suite. http://crbug.com/93933 http://crbug.com/93943 TEST=see unittest Review URL: http://codereview.chromium.org/7791030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98850 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'aura')
-rw-r--r--aura/aura.gyp26
-rw-r--r--aura/demo/demo_main.cc6
-rw-r--r--aura/desktop.cc16
-rw-r--r--aura/desktop.h11
-rw-r--r--aura/desktop_host.h3
-rw-r--r--aura/desktop_host_win.cc11
-rw-r--r--aura/desktop_host_win.h1
-rw-r--r--aura/event.cc15
-rw-r--r--aura/event.h12
-rw-r--r--aura/root_window.cc35
-rw-r--r--aura/root_window.h33
-rw-r--r--aura/run_all_unittests.cc9
-rw-r--r--aura/test_suite.cc32
-rw-r--r--aura/test_suite.h22
-rw-r--r--aura/window.cc32
-rw-r--r--aura/window.h18
-rw-r--r--aura/window_delegate.h10
-rw-r--r--aura/window_unittest.cc124
18 files changed, 405 insertions, 11 deletions
diff --git a/aura/aura.gyp b/aura/aura.gyp
index fa76c99..a304860 100644
--- a/aura/aura.gyp
+++ b/aura/aura.gyp
@@ -29,6 +29,8 @@
'event.cc',
'event.h',
'event_win.cc',
+ 'root_window.cc',
+ 'root_window.h',
'window.cc',
'window.h',
'window_delegate.h',
@@ -58,5 +60,29 @@
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc',
],
},
+ {
+ 'target_name': 'aura_unittests',
+ 'type': 'executable',
+ 'dependencies': [
+ '<(DEPTH)/base/base.gyp:test_support_base',
+ '<(DEPTH)/skia/skia.gyp:skia',
+ '<(DEPTH)/testing/gtest.gyp:gtest',
+ '<(DEPTH)/ui/ui.gyp:gfx_resources',
+ '<(DEPTH)/ui/ui.gyp:ui',
+ '<(DEPTH)/ui/ui.gyp:ui_resources',
+ 'aura',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'sources': [
+ 'window_unittest.cc',
+ 'run_all_unittests.cc',
+ 'test_suite.cc',
+ 'test_suite.h',
+ '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc',
+ '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc',
+ ],
+ },
],
}
diff --git a/aura/demo/demo_main.cc b/aura/demo/demo_main.cc
index 09cfc29..a0758c5 100644
--- a/aura/demo/demo_main.cc
+++ b/aura/demo/demo_main.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "aura/desktop.h"
+#include "aura/event.h"
#include "aura/window.h"
#include "aura/window_delegate.h"
#include "base/at_exit.h"
@@ -12,7 +13,6 @@
#include "third_party/skia/include/core/SkXfermode.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
-#include "ui/gfx/canvas.h"
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/rect.h"
@@ -23,6 +23,10 @@ class DemoWindowDelegate : public aura::WindowDelegate {
public:
explicit DemoWindowDelegate(SkColor color) : color_(color) {}
+ virtual bool OnMouseEvent(const aura::MouseEvent& event) OVERRIDE {
+ return true;
+ }
+
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
canvas->AsCanvasSkia()->drawColor(color_, SkXfermode::kSrc_Mode);
}
diff --git a/aura/desktop.cc b/aura/desktop.cc
index f427daf..2bac955 100644
--- a/aura/desktop.cc
+++ b/aura/desktop.cc
@@ -5,6 +5,7 @@
#include "aura/desktop.h"
#include "aura/desktop_host.h"
+#include "aura/root_window.h"
#include "aura/window.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -21,27 +22,34 @@ Desktop::Desktop()
host_->GetSize());
host_->SetDesktop(this);
DCHECK(compositor_.get());
- window_.reset(new Window(NULL));
+ window_.reset(new internal::RootWindow);
}
Desktop::~Desktop() {
}
-void Desktop::Run() {
+void Desktop::Show() {
host_->Show();
+}
+
+void Desktop::SetSize(const gfx::Size& size) {
+ host_->SetSize(size);
+}
+
+void Desktop::Run() {
+ Show();
MessageLoop main_message_loop(MessageLoop::TYPE_UI);
MessageLoopForUI::current()->Run(host_);
}
void Desktop::Draw() {
- // Second pass renders the layers.
compositor_->NotifyStart();
window_->DrawTree();
compositor_->NotifyEnd();
}
bool Desktop::OnMouseEvent(const MouseEvent& event) {
- return window_->OnMouseEvent(event);
+ return window_->HandleMouseEvent(event);
}
// static
diff --git a/aura/desktop.h b/aura/desktop.h
index a894e24..3139cae 100644
--- a/aura/desktop.h
+++ b/aura/desktop.h
@@ -6,7 +6,7 @@
#define AURA_DESKTOP_H_
#pragma once
-#include "aura/window.h"
+#include "aura/root_window.h"
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "ui/gfx/native_widget_types.h"
@@ -23,7 +23,6 @@ namespace aura {
class DesktopHost;
class MouseEvent;
-class Window;
// Desktop is responsible for hosting a set of windows.
class Desktop {
@@ -31,6 +30,12 @@ class Desktop {
Desktop();
~Desktop();
+ // Shows the desktop host.
+ void Show();
+
+ // Sets the size of the desktop.
+ void SetSize(const gfx::Size& size);
+
// Shows the desktop host and runs an event loop for it.
void Run();
@@ -50,7 +55,7 @@ class Desktop {
private:
scoped_refptr<ui::Compositor> compositor_;
- scoped_ptr<Window> window_;
+ scoped_ptr<internal::RootWindow> window_;
DesktopHost* host_;
diff --git a/aura/desktop_host.h b/aura/desktop_host.h
index f7ba295..ad60f40 100644
--- a/aura/desktop_host.h
+++ b/aura/desktop_host.h
@@ -37,8 +37,9 @@ class DesktopHost : public MessageLoop::Dispatcher {
// Shows the DesktopHost.
virtual void Show() = 0;
- // Returns the size of the DesktopHost.
+ // Gets/Sets the size of the DesktopHost.
virtual gfx::Size GetSize() = 0;
+ virtual void SetSize(const gfx::Size& size) = 0;
};
} // namespace aura
diff --git a/aura/desktop_host_win.cc b/aura/desktop_host_win.cc
index f235b6e..d922221 100644
--- a/aura/desktop_host_win.cc
+++ b/aura/desktop_host_win.cc
@@ -47,6 +47,17 @@ gfx::Size DesktopHostWin::GetSize() {
return gfx::Rect(r).size();
}
+void DesktopHostWin::SetSize(const gfx::Size& size) {
+ SetWindowPos(
+ hwnd(),
+ NULL,
+ 0,
+ 0,
+ size.width(),
+ size.height(),
+ SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOREPOSITION);
+}
+
void DesktopHostWin::OnClose() {
// TODO: this obviously shouldn't be here.
MessageLoopForUI::current()->Quit();
diff --git a/aura/desktop_host_win.h b/aura/desktop_host_win.h
index 6a8165b..185cf1f 100644
--- a/aura/desktop_host_win.h
+++ b/aura/desktop_host_win.h
@@ -25,6 +25,7 @@ class DesktopHostWin : public DesktopHost, public ui::WindowImpl {
virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
virtual void Show() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
+ virtual void SetSize(const gfx::Size& size) OVERRIDE;
private:
BEGIN_MSG_MAP_EX(DesktopHostWin)
diff --git a/aura/event.cc b/aura/event.cc
index 2a62a4c..055f004 100644
--- a/aura/event.cc
+++ b/aura/event.cc
@@ -4,6 +4,8 @@
#include "aura/event.h"
+#include "aura/window.h"
+
namespace aura {
Event::Event(ui::EventType type, int flags)
@@ -27,5 +29,18 @@ Event::Event(const Event& copy)
flags_(copy.flags_) {
}
+LocatedEvent::LocatedEvent(const LocatedEvent& model,
+ Window* source,
+ Window* target)
+ : Event(model),
+ location_(model.location_) {
+ if (target && target != source)
+ Window::ConvertPointToWindow(source, target, &location_);
+}
+
+MouseEvent::MouseEvent(const MouseEvent& model, Window* source, Window* target)
+ : LocatedEvent(model, source, target) {
+}
+
} // namespace aura
diff --git a/aura/event.h b/aura/event.h
index 27a8f30..be08345 100644
--- a/aura/event.h
+++ b/aura/event.h
@@ -21,6 +21,8 @@ typedef union _XEvent XEvent;
typedef XEvent* NativeEvent;
#endif
+class Window;
+
class Event {
public:
const NativeEvent& native_event() const { return native_event_; }
@@ -55,6 +57,11 @@ class LocatedEvent : public Event {
protected:
explicit LocatedEvent(NativeEvent native_event);
+ // Create a new LocatedEvent which is identical to the provided model.
+ // If source / target windows are provided, the model location will be
+ // converted from |source| coordinate system to |target| coordinate system.
+ LocatedEvent(const LocatedEvent& model, Window* source, Window* target);
+
gfx::Point location_;
private:
@@ -65,6 +72,11 @@ class MouseEvent : public LocatedEvent {
public:
explicit MouseEvent(NativeEvent native_event);
+ // Create a new MouseEvent which is identical to the provided model.
+ // If source / target windows are provided, the model location will be
+ // converted from |source| coordinate system to |target| coordinate system.
+ MouseEvent(const MouseEvent& model, Window* source, Window* target);
+
private:
DISALLOW_COPY_AND_ASSIGN(MouseEvent);
};
diff --git a/aura/root_window.cc b/aura/root_window.cc
new file mode 100644
index 0000000..6e3df25
--- /dev/null
+++ b/aura/root_window.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "aura/root_window.h"
+
+#include "base/logging.h"
+#include "aura/event.h"
+#include "aura/window_delegate.h"
+#include "ui/base/events.h"
+
+namespace aura {
+namespace internal {
+
+RootWindow::RootWindow() : Window(NULL), mouse_pressed_handler_(NULL) {
+}
+
+RootWindow::~RootWindow() {
+}
+
+bool RootWindow::HandleMouseEvent(const MouseEvent& event) {
+ Window* target = mouse_pressed_handler_;
+ if (!target)
+ target = GetEventHandlerForPoint(event.location());
+ if (event.type() == ui::ET_MOUSE_PRESSED && !mouse_pressed_handler_)
+ mouse_pressed_handler_ = target;
+ if (target->delegate()) {
+ MouseEvent translated_event(event, this, target);
+ return target->delegate()->OnMouseEvent(translated_event);
+ }
+ return false;
+}
+
+} // namespace internal
+} // namespace aura
diff --git a/aura/root_window.h b/aura/root_window.h
new file mode 100644
index 0000000..e2f02fd
--- /dev/null
+++ b/aura/root_window.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef AURA_ROOT_WINDOW_H_
+#define AURA_ROOT_WINDOW_H_
+#pragma once
+
+#include "aura/window.h"
+
+namespace aura {
+namespace internal {
+
+// A Window subclass that handles event targeting for certain types of
+// MouseEvent.
+class RootWindow : public Window {
+ public:
+ RootWindow();
+ virtual ~RootWindow();
+
+ // Handles a mouse event. Returns true if handled.
+ bool HandleMouseEvent(const MouseEvent& event);
+
+ private:
+ Window* mouse_pressed_handler_;
+
+ DISALLOW_COPY_AND_ASSIGN(RootWindow);
+};
+
+} // namespace internal
+} // namespace aura
+
+#endif // AURA_ROOT_WINDOW_H_
diff --git a/aura/run_all_unittests.cc b/aura/run_all_unittests.cc
new file mode 100644
index 0000000..5afef6d
--- /dev/null
+++ b/aura/run_all_unittests.cc
@@ -0,0 +1,9 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "aura/test_suite.h"
+
+int main(int argc, char** argv) {
+ return AuraTestSuite(argc, argv).Run();
+}
diff --git a/aura/test_suite.cc b/aura/test_suite.cc
new file mode 100644
index 0000000..54165f3
--- /dev/null
+++ b/aura/test_suite.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "aura/test_suite.h"
+
+#include "base/file_path.h"
+#include "base/path_service.h"
+#include "build/build_config.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+#include "ui/gfx/gfx_paths.h"
+
+AuraTestSuite::AuraTestSuite(int argc, char** argv)
+ : TestSuite(argc, argv) {}
+
+void AuraTestSuite::Initialize() {
+ base::TestSuite::Initialize();
+
+ gfx::RegisterPathProvider();
+ ui::RegisterPathProvider();
+
+ // Force unittests to run using en-US so if we test against string
+ // output, it'll pass regardless of the system language.
+ ui::ResourceBundle::InitSharedInstance("en-US");
+}
+
+void AuraTestSuite::Shutdown() {
+ ui::ResourceBundle::CleanupSharedInstance();
+
+ base::TestSuite::Shutdown();
+}
diff --git a/aura/test_suite.h b/aura/test_suite.h
new file mode 100644
index 0000000..43465a5
--- /dev/null
+++ b/aura/test_suite.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef AURA_TEST_SUITE_H_
+#define AURA_TEST_SUITE_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "base/test/test_suite.h"
+
+class AuraTestSuite : public base::TestSuite {
+ public:
+ AuraTestSuite(int argc, char** argv);
+
+ protected:
+ // base::TestSuite:
+ virtual void Initialize() OVERRIDE;
+ virtual void Shutdown() OVERRIDE;
+};
+
+#endif // AURA_TEST_SUITE_H_
diff --git a/aura/window.cc b/aura/window.cc
index e6f62a8..5a81bfe 100644
--- a/aura/window.cc
+++ b/aura/window.cc
@@ -24,6 +24,10 @@ Window::Window(WindowDelegate* delegate)
}
Window::~Window() {
+ if (delegate_)
+ delegate_->OnWindowDestroyed();
+ if (parent_)
+ parent_->RemoveChild(this);
}
void Window::Init() {
@@ -70,7 +74,6 @@ void Window::DrawTree() {
UpdateLayerCanvas();
Draw();
- // First pass updates the layer bitmaps.
for (Windows::iterator i = children_.begin(); i != children_.end(); ++i)
(*i)->DrawTree();
}
@@ -91,10 +94,37 @@ void Window::RemoveChild(Window* child) {
children_.erase(i);
}
+// static
+void Window::ConvertPointToWindow(Window* source,
+ Window* target,
+ gfx::Point* point) {
+ ui::Layer::ConvertPointToLayer(source->layer(), target->layer(), point);
+}
+
bool Window::OnMouseEvent(const MouseEvent& event) {
return true;
}
+bool Window::HitTest(const gfx::Point& point) {
+ gfx::Rect local_bounds(gfx::Point(), bounds().size());
+ // TODO(beng): hittest masks.
+ return local_bounds.Contains(point);
+}
+
+Window* Window::GetEventHandlerForPoint(const gfx::Point& point) {
+ Windows::const_reverse_iterator i = children_.rbegin();
+ for (; i != children_.rend(); ++i) {
+ Window* child = *i;
+ if (child->visibility() == Window::VISIBILITY_HIDDEN)
+ continue;
+ gfx::Point point_in_child_coords(point);
+ Window::ConvertPointToWindow(this, child, &point_in_child_coords);
+ if (child->HitTest(point_in_child_coords))
+ return child->GetEventHandlerForPoint(point_in_child_coords);
+ }
+ return this;
+}
+
void Window::UpdateLayerCanvas() {
if (needs_paint_all_) {
needs_paint_all_ = false;
diff --git a/aura/window.h b/aura/window.h
index 871ceb6..f5667b8 100644
--- a/aura/window.h
+++ b/aura/window.h
@@ -27,6 +27,7 @@ class WindowDelegate;
// Aura window implementation. Interesting events are sent to the
// WindowDelegate.
+// TODO(beng): resolve ownership.
class Window {
public:
enum Visibility {
@@ -80,9 +81,26 @@ class Window {
void AddChild(Window* child);
void RemoveChild(Window* child);
+ static void ConvertPointToWindow(Window* source,
+ Window* target,
+ gfx::Point* point);
+
// Handles a mouse event. Returns true if handled.
bool OnMouseEvent(const MouseEvent& event);
+ WindowDelegate* delegate() { return delegate_; }
+
+ // Returns true if the mouse pointer at the specified |point| can trigger an
+ // event for this Window.
+ // TODO(beng):
+ // A Window can supply a hit-test mask to cause some portions of itself to not
+ // trigger events, causing the events to fall through to the Window behind.
+ bool HitTest(const gfx::Point& point);
+
+ // Returns the Window that most closely encloses |point| for the purposes of
+ // event targeting.
+ Window* GetEventHandlerForPoint(const gfx::Point& point);
+
private:
typedef std::vector<Window*> Windows;
diff --git a/aura/window_delegate.h b/aura/window_delegate.h
index ffa3191..93ad8f5 100644
--- a/aura/window_delegate.h
+++ b/aura/window_delegate.h
@@ -12,11 +12,19 @@ class Canvas;
namespace aura {
+class MouseEvent;
+
// Delegate interface for aura::Window.
class WindowDelegate {
public:
+ virtual bool OnMouseEvent(const MouseEvent& event) = 0;
+
// Asks the delegate to paint window contents into the supplied canvas.
- virtual void OnPaint(gfx::Canvas* canvas) = 0;
+ virtual void OnPaint(gfx::Canvas* canvas) = 0;
+
+ // Called when the Window has been destroyed (i.e. from its destructor).
+ // The delegate can use this as an opportunity to delete itself if necessary.
+ virtual void OnWindowDestroyed() = 0;
protected:
virtual ~WindowDelegate() {}
diff --git a/aura/window_unittest.cc b/aura/window_unittest.cc
new file mode 100644
index 0000000..7e16519
--- /dev/null
+++ b/aura/window_unittest.cc
@@ -0,0 +1,124 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "aura/desktop.h"
+#include "aura/window_delegate.h"
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/message_loop.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/canvas_skia.h"
+
+namespace aura {
+namespace internal {
+
+namespace {
+
+// A simple WindowDelegate implementation for these tests. It owns itself
+// (deletes itself when the Window it is attached to is destroyed).
+class TestWindowDelegate : public WindowDelegate {
+ public:
+ TestWindowDelegate(SkColor color) : color_(color) {}
+ virtual ~TestWindowDelegate() {}
+
+ // Overridden from WindowDelegate:
+ virtual bool OnMouseEvent(const MouseEvent& event) OVERRIDE { return false; }
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
+ canvas->AsCanvasSkia()->drawColor(color_, SkXfermode::kSrc_Mode);
+ }
+ virtual void OnWindowDestroyed() OVERRIDE {
+ delete this;
+ }
+
+ private:
+ SkColor color_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate);
+};
+
+class WindowTest : public testing::Test {
+ public:
+ WindowTest() {
+ aura::Desktop::GetInstance()->Show();
+ aura::Desktop::GetInstance()->SetSize(gfx::Size(500, 500));
+ }
+ virtual ~WindowTest() {}
+
+ // Overridden from testing::Test:
+ virtual void SetUp() OVERRIDE {
+ }
+
+ virtual void TearDown() OVERRIDE {
+ }
+
+ Window* CreateTestWindow(SkColor color,
+ int id,
+ const gfx::Rect& bounds,
+ Window* parent) {
+ Window* window = new Window(new TestWindowDelegate(color));
+ window->set_id(id);
+ window->Init();
+ window->SetBounds(bounds, 0);
+ window->SetVisibility(Window::VISIBILITY_SHOWN);
+ window->SetParent(parent);
+ return window;
+ }
+
+ void RunPendingMessages() {
+ MessageLoop main_message_loop(MessageLoop::TYPE_UI);
+ MessageLoopForUI::current()->Run(NULL);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WindowTest);
+};
+
+} // namespace
+
+TEST_F(WindowTest, HitTest) {
+ Window w1(new TestWindowDelegate(SK_ColorWHITE));
+ w1.set_id(1);
+ w1.Init();
+ w1.SetBounds(gfx::Rect(10, 10, 50, 50), 0);
+ w1.SetVisibility(Window::VISIBILITY_SHOWN);
+ w1.SetParent(NULL);
+
+ // Points are in the Window's coordinates.
+ EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1)));
+ EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1)));
+
+ // TODO(beng): clip Window to parent.
+}
+
+TEST_F(WindowTest, GetEventHandlerForPoint) {
+ scoped_ptr<Window> w1(
+ CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL));
+ scoped_ptr<Window> w11(
+ CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get()));
+ scoped_ptr<Window> w111(
+ CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get()));
+ scoped_ptr<Window> w1111(
+ CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get()));
+ scoped_ptr<Window> w12(
+ CreateTestWindow(SK_ColorMAGENTA, 12, gfx::Rect(10, 420, 25, 25),
+ w1.get()));
+ scoped_ptr<Window> w121(
+ CreateTestWindow(SK_ColorYELLOW, 121, gfx::Rect(5, 5, 5, 5), w12.get()));
+ scoped_ptr<Window> w13(
+ CreateTestWindow(SK_ColorGRAY, 13, gfx::Rect(5, 470, 50, 50), w1.get()));
+
+ Window* desktop = Desktop::GetInstance()->window();
+ EXPECT_EQ(desktop, desktop->GetEventHandlerForPoint(gfx::Point(5, 5)));
+ EXPECT_EQ(w1.get(), desktop->GetEventHandlerForPoint(gfx::Point(11, 11)));
+ EXPECT_EQ(w11.get(), desktop->GetEventHandlerForPoint(gfx::Point(16, 16)));
+ EXPECT_EQ(w111.get(), desktop->GetEventHandlerForPoint(gfx::Point(21, 21)));
+ EXPECT_EQ(w1111.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 26)));
+ EXPECT_EQ(w12.get(), desktop->GetEventHandlerForPoint(gfx::Point(21, 431)));
+ EXPECT_EQ(w121.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 436)));
+ EXPECT_EQ(w13.get(), desktop->GetEventHandlerForPoint(gfx::Point(26, 481)));
+}
+
+} // namespace internal
+} // namespace aura
+