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

Unified Diff: ui/aura/window_targeter_unittest.cc

Issue 180253006: Merge 252257 "events: Fix event-targeting for transformed windows." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1847/src/
Patch Set: Created 6 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
« no previous file with comments | « ui/aura/window_targeter.cc ('k') | ui/wm/core/easy_resize_window_targeter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_targeter_unittest.cc
===================================================================
--- ui/aura/window_targeter_unittest.cc (revision 253296)
+++ ui/aura/window_targeter_unittest.cc (working copy)
@@ -40,6 +40,18 @@
Window* root_window() { return AuraTestBase::root_window(); }
};
+gfx::RectF GetEffectiveVisibleBoundsInRootWindow(Window* window) {
+ gfx::RectF bounds = gfx::Rect(window->bounds().size());
+ Window* root = window->GetRootWindow();
+ CHECK(window->layer());
+ CHECK(root->layer());
+ gfx::Transform transform;
+ if (!window->layer()->GetTargetTransformRelativeTo(root->layer(), &transform))
+ return gfx::RectF();
+ transform.TransformRect(&bounds);
+ return bounds;
+}
+
TEST_F(WindowTargeterTest, Basic) {
test::TestWindowDelegate delegate;
scoped_ptr<Window> window(CreateNormalWindow(1, root_window(), &delegate));
@@ -106,4 +118,48 @@
}
}
+TEST_F(WindowTargeterTest, TargetTransformedWindow) {
+ root_window()->Show();
+
+ test::TestWindowDelegate delegate;
+ scoped_ptr<Window> window(CreateNormalWindow(2, root_window(), &delegate));
+
+ const gfx::Rect window_bounds(100, 20, 400, 80);
+ window->SetBounds(window_bounds);
+
+ ui::EventTarget* root_target = root_window();
+ ui::EventTargeter* targeter = root_target->GetEventTargeter();
+ gfx::Point event_location(490, 50);
+ {
+ ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
+ ui::EF_NONE, ui::EF_NONE);
+ EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &mouse));
+ }
+
+ // Scale |window| by 50%. This should move it away from underneath
+ // |event_location|, so an event in that location will not be targeted to it.
+ gfx::Transform transform;
+ transform.Scale(0.5, 0.5);
+ window->SetTransform(transform);
+ EXPECT_EQ(gfx::RectF(100, 20, 200, 40).ToString(),
+ GetEffectiveVisibleBoundsInRootWindow(window.get()).ToString());
+ {
+ ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
+ ui::EF_NONE, ui::EF_NONE);
+ EXPECT_EQ(root_window(), targeter->FindTargetForEvent(root_target, &mouse));
+ }
+
+ transform = gfx::Transform();
+ transform.Translate(200, 10);
+ transform.Scale(0.5, 0.5);
+ window->SetTransform(transform);
+ EXPECT_EQ(gfx::RectF(300, 30, 200, 40).ToString(),
+ GetEffectiveVisibleBoundsInRootWindow(window.get()).ToString());
+ {
+ ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
+ ui::EF_NONE, ui::EF_NONE);
+ EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &mouse));
+ }
+}
+
} // namespace aura
« no previous file with comments | « ui/aura/window_targeter.cc ('k') | ui/wm/core/easy_resize_window_targeter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698