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

Unified Diff: ui/aura/window_event_dispatcher_unittest.cc

Issue 2681613002: Avoid two targeting phases in aura client-lib and EventProcessor. (Closed)
Patch Set: tests Created 3 years, 10 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
Index: ui/aura/window_event_dispatcher_unittest.cc
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc
index ca48fb2d792765baa17ffcf7eea237184fa72651..3197a4541149a059ae3947a11e762325ef2449b0 100644
--- a/ui/aura/window_event_dispatcher_unittest.cc
+++ b/ui/aura/window_event_dispatcher_unittest.cc
@@ -2742,6 +2742,50 @@ TEST_F(WindowEventDispatcherMusTest, LastEventLocation) {
EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location());
}
+TEST_F(WindowEventDispatcherMusTest, UseDefaultTargeterToFindTarget) {
+ LastEventLocationDelegate last_event_location_delegate1;
+ std::unique_ptr<Window> child1(
+ CreateTestWindowWithDelegate(&last_event_location_delegate1, 123,
+ gfx::Rect(10, 10, 100, 100), root_window()));
+ LastEventLocationDelegate last_event_location_delegate2;
+ std::unique_ptr<Window> child2(
+ CreateTestWindowWithDelegate(&last_event_location_delegate2, 124,
+ gfx::Rect(20, 30, 100, 100), child1.get()));
+
+ const gfx::Point mouse_location(30, 40);
+ ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, mouse_location, mouse_location,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
+ ui::EF_LEFT_MOUSE_BUTTON);
+ DispatchEventUsingWindowDispatcher(&mouse);
+ EXPECT_EQ(0, last_event_location_delegate1.mouse_event_count());
+ EXPECT_EQ(1, last_event_location_delegate2.mouse_event_count());
+ EXPECT_EQ(gfx::Point(), last_event_location_delegate1.last_mouse_location());
+ EXPECT_EQ(mouse_location,
+ last_event_location_delegate2.last_mouse_location());
+}
+
+TEST_F(WindowEventDispatcherMusTest, UseDefaultTargeterToFindTarget2) {
+ LastEventLocationDelegate last_event_location_delegate1;
+ std::unique_ptr<Window> child1(
+ CreateTestWindowWithDelegate(&last_event_location_delegate1, 123,
+ gfx::Rect(10, 10, 100, 100), root_window()));
+ LastEventLocationDelegate last_event_location_delegate2;
+ std::unique_ptr<Window> child2(
+ CreateTestWindowWithDelegate(&last_event_location_delegate2, 124,
+ gfx::Rect(20, 30, 100, 100), child1.get()));
+
+ const gfx::Point mouse_location(15, 25);
+ ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, mouse_location, mouse_location,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
+ ui::EF_LEFT_MOUSE_BUTTON);
+ DispatchEventUsingWindowDispatcher(&mouse);
+ EXPECT_EQ(1, last_event_location_delegate1.mouse_event_count());
+ EXPECT_EQ(0, last_event_location_delegate2.mouse_event_count());
+ EXPECT_EQ(mouse_location,
+ last_event_location_delegate1.last_mouse_location());
+ EXPECT_EQ(gfx::Point(), last_event_location_delegate2.last_mouse_location());
+}
+
class NestedLocationDelegate : public test::TestWindowDelegate {
public:
NestedLocationDelegate() {}

Powered by Google App Engine
This is Rietveld 408576698