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

Side by Side Diff: ash/wm/overview/window_selector_unittest.cc

Issue 173443002: aura: Take transformation into account when computing window bounds in root-window/screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/drag_drop/drag_drop_controller.h" 5 #include "ash/drag_drop/drag_drop_controller.h"
6 #include "ash/root_window_controller.h" 6 #include "ash/root_window_controller.h"
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shelf/shelf.h" 8 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_widget.h" 9 #include "ash/shelf/shelf_widget.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 gfx::RectF GetTransformedTargetBounds(aura::Window* window) { 192 gfx::RectF GetTransformedTargetBounds(aura::Window* window) {
193 gfx::RectF bounds(ScreenUtil::ConvertRectToScreen( 193 gfx::RectF bounds(ScreenUtil::ConvertRectToScreen(
194 window->parent(), window->layer()->GetTargetBounds())); 194 window->parent(), window->layer()->GetTargetBounds()));
195 gfx::Transform transform(GetTransformRelativeTo(bounds.origin(), 195 gfx::Transform transform(GetTransformRelativeTo(bounds.origin(),
196 window->layer()->GetTargetTransform())); 196 window->layer()->GetTargetTransform()));
197 transform.TransformRect(&bounds); 197 transform.TransformRect(&bounds);
198 return bounds; 198 return bounds;
199 } 199 }
200 200
201 gfx::RectF GetTransformedBoundsInRootWindow(aura::Window* window) {
202 gfx::RectF bounds = gfx::Rect(window->bounds().size());
203 aura::Window* root = window->GetRootWindow();
204 CHECK(window->layer());
205 CHECK(root->layer());
206 gfx::Transform transform;
207 if (!window->layer()->GetTargetTransformRelativeTo(root->layer(),
208 &transform)) {
209 return gfx::RectF();
210 }
211 transform.TransformRect(&bounds);
212 return bounds;
213 }
214
215 void ClickWindow(aura::Window* window) { 201 void ClickWindow(aura::Window* window) {
216 aura::test::EventGenerator event_generator(window->GetRootWindow(), window); 202 aura::test::EventGenerator event_generator(window->GetRootWindow(), window);
217 gfx::RectF target = GetTransformedBounds(window); 203 gfx::RectF target = GetTransformedBounds(window);
218 event_generator.ClickLeftButton(); 204 event_generator.ClickLeftButton();
219 } 205 }
220 206
221 bool IsSelecting() { 207 bool IsSelecting() {
222 return ash::Shell::GetInstance()->window_selector_controller()-> 208 return ash::Shell::GetInstance()->window_selector_controller()->
223 IsSelecting(); 209 IsSelecting();
224 } 210 }
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 RunAllPendingInMessageLoop(); 1030 RunAllPendingInMessageLoop();
1045 } 1031 }
1046 1032
1047 TEST_F(WindowSelectorTest, HitTestingInOverview) { 1033 TEST_F(WindowSelectorTest, HitTestingInOverview) {
1048 gfx::Rect window_bounds(20, 10, 200, 300); 1034 gfx::Rect window_bounds(20, 10, 200, 300);
1049 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 1035 aura::Window* root_window = Shell::GetPrimaryRootWindow();
1050 scoped_ptr<aura::Window> window1(CreateWindow(window_bounds)); 1036 scoped_ptr<aura::Window> window1(CreateWindow(window_bounds));
1051 scoped_ptr<aura::Window> window2(CreateWindow(window_bounds)); 1037 scoped_ptr<aura::Window> window2(CreateWindow(window_bounds));
1052 1038
1053 ToggleOverview(); 1039 ToggleOverview();
1054 gfx::RectF bounds1 = GetTransformedBoundsInRootWindow(window1.get()); 1040 gfx::Rect bounds1 = window1->GetBoundsInRootWindow();
1055 gfx::RectF bounds2 = GetTransformedBoundsInRootWindow(window2.get()); 1041 gfx::Rect bounds2 = window2->GetBoundsInRootWindow();
1056 EXPECT_NE(bounds1.ToString(), bounds2.ToString()); 1042 EXPECT_NE(bounds1.ToString(), bounds2.ToString());
1057 1043
1058 ui::EventTarget* root_target = root_window; 1044 ui::EventTarget* root_target = root_window;
1059 ui::EventTargeter* targeter = root_target->GetEventTargeter(); 1045 ui::EventTargeter* targeter = root_target->GetEventTargeter();
1060 aura::Window* windows[] = { window1.get(), window2.get() }; 1046 aura::Window* windows[] = { window1.get(), window2.get() };
1061 for (size_t w = 0; w < arraysize(windows); ++w) { 1047 for (size_t w = 0; w < arraysize(windows); ++w) {
1062 gfx::RectF bounds = GetTransformedBoundsInRootWindow(windows[w]); 1048 gfx::Rect bounds = windows[w]->GetBoundsInRootWindow();
1063 gfx::Point points[] = { 1049 gfx::Point points[] = {
1064 gfx::Point(bounds.x(), bounds.y()), 1050 gfx::Point(bounds.x(), bounds.y()),
1065 gfx::Point(bounds.right() - 1, bounds.y()), 1051 gfx::Point(bounds.right() - 1, bounds.y()),
1066 gfx::Point(bounds.x(), bounds.bottom() - 1), 1052 gfx::Point(bounds.x(), bounds.bottom() - 1),
1067 gfx::Point(bounds.right() - 1, bounds.bottom() - 1), 1053 gfx::Point(bounds.right() - 1, bounds.bottom() - 1),
1068 }; 1054 };
1069 1055
1070 for (size_t p = 0; p < arraysize(points); ++p) { 1056 for (size_t p = 0; p < arraysize(points); ++p) {
1071 ui::MouseEvent event(ui::ET_MOUSE_MOVED, points[p], points[p], 1057 ui::MouseEvent event(ui::ET_MOUSE_MOVED, points[p], points[p],
1072 ui::EF_NONE, ui::EF_NONE); 1058 ui::EF_NONE, ui::EF_NONE);
1073 EXPECT_EQ(windows[w], 1059 EXPECT_EQ(windows[w],
1074 targeter->FindTargetForEvent(root_target, &event)); 1060 targeter->FindTargetForEvent(root_target, &event));
1075 } 1061 }
1076 } 1062 }
1077 } 1063 }
1078 1064
1079 } // namespace internal 1065 } // namespace internal
1080 } // namespace ash 1066 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698