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

Unified Diff: ash/wm/overview/window_selector_unittest.cc

Issue 167323004: events: Fix event-targeting for transformed windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self-nits 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 | « no previous file | ui/aura/window_targeter.cc » ('j') | ui/aura/window_targeter_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/overview/window_selector_unittest.cc
diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc
index db3c6fb5cb0213d096da2823e2594c95ef4c3c69..c23fedc189d4d293b3ed92475c59743b5e19f62a 100644
--- a/ash/wm/overview/window_selector_unittest.cc
+++ b/ash/wm/overview/window_selector_unittest.cc
@@ -198,6 +198,20 @@ class WindowSelectorTest : public test::AshTestBase {
return bounds;
}
+ gfx::RectF GetTransformedBoundsInRootWindow(aura::Window* window) {
+ gfx::RectF bounds = gfx::Rect(window->bounds().size());
+ aura::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;
+ }
+
void ClickWindow(aura::Window* window) {
aura::test::EventGenerator event_generator(window->GetRootWindow(), window);
gfx::RectF target = GetTransformedBounds(window);
@@ -1030,5 +1044,37 @@ TEST_F(WindowSelectorTest, DISABLED_DragDropInProgress) {
RunAllPendingInMessageLoop();
}
+TEST_F(WindowSelectorTest, HitTestingInOverview) {
+ gfx::Rect window_bounds(20, 10, 200, 300);
+ aura::Window* root_window = Shell::GetPrimaryRootWindow();
+ scoped_ptr<aura::Window> window1(CreateWindow(window_bounds));
+ scoped_ptr<aura::Window> window2(CreateWindow(window_bounds));
+
+ ToggleOverview();
+ gfx::RectF bounds1 = GetTransformedBoundsInRootWindow(window1.get());
+ gfx::RectF bounds2 = GetTransformedBoundsInRootWindow(window2.get());
+ EXPECT_NE(bounds1.ToString(), bounds2.ToString());
+
+ ui::EventTarget* root_target = root_window;
+ ui::EventTargeter* targeter = root_target->GetEventTargeter();
+ aura::Window* windows[] = { window1.get(), window2.get() };
+ for (size_t w = 0; w < arraysize(windows); ++w) {
+ gfx::RectF bounds = GetTransformedBoundsInRootWindow(windows[w]);
+ gfx::Point points[] = {
+ gfx::Point(bounds.x(), bounds.y()),
+ gfx::Point(bounds.right() - 1, bounds.y()),
+ gfx::Point(bounds.x(), bounds.bottom() - 1),
+ gfx::Point(bounds.right() - 1, bounds.bottom() - 1),
+ };
+
+ for (size_t p = 0; p < arraysize(points); ++p) {
+ ui::MouseEvent event(ui::ET_MOUSE_MOVED, points[p], points[p],
+ ui::EF_NONE, ui::EF_NONE);
+ EXPECT_EQ(windows[w],
+ targeter->FindTargetForEvent(root_target, &event));
+ }
+ }
+}
+
} // namespace internal
} // namespace ash
« no previous file with comments | « no previous file | ui/aura/window_targeter.cc » ('j') | ui/aura/window_targeter_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698