OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/wm/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/launcher/launcher.h" | |
9 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
10 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 10 #include "ash/shelf/shelf.h" |
11 #include "ash/shelf/shelf_button.h" | 11 #include "ash/shelf/shelf_button.h" |
12 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
13 #include "ash/shelf/shelf_model.h" | 13 #include "ash/shelf/shelf_model.h" |
14 #include "ash/shelf/shelf_types.h" | 14 #include "ash/shelf/shelf_types.h" |
15 #include "ash/shelf/shelf_util.h" | 15 #include "ash/shelf/shelf_util.h" |
16 #include "ash/shelf/shelf_view.h" | 16 #include "ash/shelf/shelf_view.h" |
17 #include "ash/shelf/shelf_widget.h" | 17 #include "ash/shelf/shelf_widget.h" |
18 #include "ash/shell.h" | 18 #include "ash/shell.h" |
19 #include "ash/shell_window_ids.h" | 19 #include "ash/shell_window_ids.h" |
20 #include "ash/test/ash_test_base.h" | 20 #include "ash/test/ash_test_base.h" |
21 #include "ash/test/launcher_test_api.h" | 21 #include "ash/test/shelf_test_api.h" |
22 #include "ash/test/shelf_view_test_api.h" | 22 #include "ash/test/shelf_view_test_api.h" |
23 #include "ash/test/shell_test_api.h" | 23 #include "ash/test/shell_test_api.h" |
24 #include "ash/test/test_shelf_delegate.h" | 24 #include "ash/test/test_shelf_delegate.h" |
25 #include "ash/wm/mru_window_tracker.h" | 25 #include "ash/wm/mru_window_tracker.h" |
26 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
27 #include "base/basictypes.h" | 27 #include "base/basictypes.h" |
28 #include "base/command_line.h" | 28 #include "base/command_line.h" |
29 #include "base/compiler_specific.h" | 29 #include "base/compiler_specific.h" |
30 #include "base/i18n/rtl.h" | 30 #include "base/i18n/rtl.h" |
31 #include "base/run_loop.h" | 31 #include "base/run_loop.h" |
(...skipping 14 matching lines...) Expand all Loading... |
46 class PanelLayoutManagerTest : public test::AshTestBase { | 46 class PanelLayoutManagerTest : public test::AshTestBase { |
47 public: | 47 public: |
48 PanelLayoutManagerTest() {} | 48 PanelLayoutManagerTest() {} |
49 virtual ~PanelLayoutManagerTest() {} | 49 virtual ~PanelLayoutManagerTest() {} |
50 | 50 |
51 virtual void SetUp() OVERRIDE { | 51 virtual void SetUp() OVERRIDE { |
52 test::AshTestBase::SetUp(); | 52 test::AshTestBase::SetUp(); |
53 ASSERT_TRUE(test::TestShelfDelegate::instance()); | 53 ASSERT_TRUE(test::TestShelfDelegate::instance()); |
54 | 54 |
55 shelf_view_test_.reset(new test::ShelfViewTestAPI( | 55 shelf_view_test_.reset(new test::ShelfViewTestAPI( |
56 GetShelfView(Launcher::ForPrimaryDisplay()))); | 56 GetShelfView(Shelf::ForPrimaryDisplay()))); |
57 shelf_view_test_->SetAnimationDuration(1); | 57 shelf_view_test_->SetAnimationDuration(1); |
58 } | 58 } |
59 | 59 |
60 aura::Window* CreateNormalWindow(const gfx::Rect& bounds) { | 60 aura::Window* CreateNormalWindow(const gfx::Rect& bounds) { |
61 return CreateTestWindowInShellWithBounds(bounds); | 61 return CreateTestWindowInShellWithBounds(bounds); |
62 } | 62 } |
63 | 63 |
64 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { | 64 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { |
65 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 65 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
66 NULL, | 66 NULL, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 EXPECT_FALSE(window1_bounds.Intersects(window2_bounds)); | 118 EXPECT_FALSE(window1_bounds.Intersects(window2_bounds)); |
119 } | 119 } |
120 | 120 |
121 // TODO(dcheng): This should be const, but GetScreenBoundsOfItemIconForWindow | 121 // TODO(dcheng): This should be const, but GetScreenBoundsOfItemIconForWindow |
122 // takes a non-const Window. We can probably fix that. | 122 // takes a non-const Window. We can probably fix that. |
123 void IsPanelAboveLauncherIcon(aura::Window* panel) { | 123 void IsPanelAboveLauncherIcon(aura::Window* panel) { |
124 // Waits until all shelf view animations are done. | 124 // Waits until all shelf view animations are done. |
125 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 125 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
126 | 126 |
127 Launcher* launcher = | 127 Shelf* shelf = RootWindowController::ForShelf(panel)->shelf()->shelf(); |
128 RootWindowController::ForLauncher(panel)->shelf()->launcher(); | 128 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); |
129 gfx::Rect icon_bounds = launcher->GetScreenBoundsOfItemIconForWindow(panel); | |
130 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); | 129 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); |
131 | 130 |
132 gfx::Rect window_bounds = panel->GetBoundsInScreen(); | 131 gfx::Rect window_bounds = panel->GetBoundsInScreen(); |
133 ASSERT_LT(icon_bounds.width(), window_bounds.width()); | 132 ASSERT_LT(icon_bounds.width(), window_bounds.width()); |
134 ASSERT_LT(icon_bounds.height(), window_bounds.height()); | 133 ASSERT_LT(icon_bounds.height(), window_bounds.height()); |
135 gfx::Rect launcher_bounds = launcher->shelf_widget()-> | 134 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); |
136 GetWindowBoundsInScreen(); | |
137 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); | 135 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); |
138 | 136 |
139 if (IsHorizontal(alignment)) { | 137 if (IsHorizontal(alignment)) { |
140 // The horizontal bounds of the panel window should contain the bounds of | 138 // The horizontal bounds of the panel window should contain the bounds of |
141 // the launcher icon. | 139 // the shelf icon. |
142 EXPECT_LE(window_bounds.x(), icon_bounds.x()); | 140 EXPECT_LE(window_bounds.x(), icon_bounds.x()); |
143 EXPECT_GE(window_bounds.right(), icon_bounds.right()); | 141 EXPECT_GE(window_bounds.right(), icon_bounds.right()); |
144 } else { | 142 } else { |
145 // The vertical bounds of the panel window should contain the bounds of | 143 // The vertical bounds of the panel window should contain the bounds of |
146 // the launcher icon. | 144 // the shelf icon. |
147 EXPECT_LE(window_bounds.y(), icon_bounds.y()); | 145 EXPECT_LE(window_bounds.y(), icon_bounds.y()); |
148 EXPECT_GE(window_bounds.bottom(), icon_bounds.bottom()); | 146 EXPECT_GE(window_bounds.bottom(), icon_bounds.bottom()); |
149 } | 147 } |
150 | 148 |
151 switch (alignment) { | 149 switch (alignment) { |
152 case SHELF_ALIGNMENT_BOTTOM: | 150 case SHELF_ALIGNMENT_BOTTOM: |
153 EXPECT_EQ(launcher_bounds.y(), window_bounds.bottom()); | 151 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); |
154 break; | 152 break; |
155 case SHELF_ALIGNMENT_LEFT: | 153 case SHELF_ALIGNMENT_LEFT: |
156 EXPECT_EQ(launcher_bounds.right(), window_bounds.x()); | 154 EXPECT_EQ(shelf_bounds.right(), window_bounds.x()); |
157 break; | 155 break; |
158 case SHELF_ALIGNMENT_RIGHT: | 156 case SHELF_ALIGNMENT_RIGHT: |
159 EXPECT_EQ(launcher_bounds.x(), window_bounds.right()); | 157 EXPECT_EQ(shelf_bounds.x(), window_bounds.right()); |
160 break; | 158 break; |
161 case SHELF_ALIGNMENT_TOP: | 159 case SHELF_ALIGNMENT_TOP: |
162 EXPECT_EQ(launcher_bounds.bottom(), window_bounds.y()); | 160 EXPECT_EQ(shelf_bounds.bottom(), window_bounds.y()); |
163 break; | 161 break; |
164 } | 162 } |
165 } | 163 } |
166 | 164 |
167 void IsCalloutAboveLauncherIcon(aura::Window* panel) { | 165 void IsCalloutAboveLauncherIcon(aura::Window* panel) { |
168 // Flush the message loop, since callout updates use a delayed task. | 166 // Flush the message loop, since callout updates use a delayed task. |
169 base::RunLoop().RunUntilIdle(); | 167 base::RunLoop().RunUntilIdle(); |
170 views::Widget* widget = GetCalloutWidgetForPanel(panel); | 168 views::Widget* widget = GetCalloutWidgetForPanel(panel); |
171 | 169 |
172 Launcher* launcher = | 170 Shelf* shelf = RootWindowController::ForShelf(panel)->shelf()->shelf(); |
173 RootWindowController::ForLauncher(panel)->shelf()->launcher(); | 171 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); |
174 gfx::Rect icon_bounds = launcher->GetScreenBoundsOfItemIconForWindow(panel); | |
175 ASSERT_FALSE(icon_bounds.IsEmpty()); | 172 ASSERT_FALSE(icon_bounds.IsEmpty()); |
176 | 173 |
177 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); | 174 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); |
178 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); | 175 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); |
179 ASSERT_FALSE(icon_bounds.IsEmpty()); | 176 ASSERT_FALSE(icon_bounds.IsEmpty()); |
180 | 177 |
181 EXPECT_TRUE(widget->IsVisible()); | 178 EXPECT_TRUE(widget->IsVisible()); |
182 | 179 |
183 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); | 180 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); |
184 switch (alignment) { | 181 switch (alignment) { |
(...skipping 24 matching lines...) Expand all Loading... |
209 | 206 |
210 bool IsPanelCalloutVisible(aura::Window* panel) { | 207 bool IsPanelCalloutVisible(aura::Window* panel) { |
211 views::Widget* widget = GetCalloutWidgetForPanel(panel); | 208 views::Widget* widget = GetCalloutWidgetForPanel(panel); |
212 return widget->IsVisible(); | 209 return widget->IsVisible(); |
213 } | 210 } |
214 | 211 |
215 test::ShelfViewTestAPI* shelf_view_test() { | 212 test::ShelfViewTestAPI* shelf_view_test() { |
216 return shelf_view_test_.get(); | 213 return shelf_view_test_.get(); |
217 } | 214 } |
218 | 215 |
219 // Clicks the launcher items on |shelf_view| that is | 216 // Clicks the shelf items on |shelf_view| that is associated with given |
220 /// associated with given |window|. | 217 // |window|. |
221 void ClickLauncherItemForWindow(ShelfView* shelf_view, | 218 void ClickLauncherItemForWindow(ShelfView* shelf_view, |
222 aura::Window* window) { | 219 aura::Window* window) { |
223 test::ShelfViewTestAPI test_api(shelf_view); | 220 test::ShelfViewTestAPI test_api(shelf_view); |
224 test_api.SetAnimationDuration(1); | 221 test_api.SetAnimationDuration(1); |
225 test_api.RunMessageLoopUntilAnimationsDone(); | 222 test_api.RunMessageLoopUntilAnimationsDone(); |
226 ShelfModel* model = test::ShellTestApi(Shell::GetInstance()).shelf_model(); | 223 ShelfModel* model = test::ShellTestApi(Shell::GetInstance()).shelf_model(); |
227 int index = model->ItemIndexByID(GetLauncherIDForWindow(window)); | 224 int index = model->ItemIndexByID(GetLauncherIDForWindow(window)); |
228 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); | 225 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); |
229 | 226 |
230 aura::test::EventGenerator& event_generator = GetEventGenerator(); | 227 aura::test::EventGenerator& event_generator = GetEventGenerator(); |
(...skipping 12 matching lines...) Expand all Loading... |
243 ash::Shell* shell = ash::Shell::GetInstance(); | 240 ash::Shell* shell = ash::Shell::GetInstance(); |
244 return shell->GetShelfAlignment(root_window); | 241 return shell->GetShelfAlignment(root_window); |
245 } | 242 } |
246 | 243 |
247 void SetShelfAutoHideBehavior(aura::Window* window, | 244 void SetShelfAutoHideBehavior(aura::Window* window, |
248 ShelfAutoHideBehavior behavior) { | 245 ShelfAutoHideBehavior behavior) { |
249 internal::ShelfLayoutManager* shelf = | 246 internal::ShelfLayoutManager* shelf = |
250 RootWindowController::ForWindow(window)->shelf()-> | 247 RootWindowController::ForWindow(window)->shelf()-> |
251 shelf_layout_manager(); | 248 shelf_layout_manager(); |
252 shelf->SetAutoHideBehavior(behavior); | 249 shelf->SetAutoHideBehavior(behavior); |
253 ShelfView* shelf_view = GetShelfView(Launcher::ForWindow(window)); | 250 ShelfView* shelf_view = GetShelfView(Shelf::ForWindow(window)); |
254 test::ShelfViewTestAPI test_api(shelf_view); | 251 test::ShelfViewTestAPI test_api(shelf_view); |
255 test_api.RunMessageLoopUntilAnimationsDone(); | 252 test_api.RunMessageLoopUntilAnimationsDone(); |
256 } | 253 } |
257 | 254 |
258 void SetShelfVisibilityState(aura::Window* window, | 255 void SetShelfVisibilityState(aura::Window* window, |
259 ShelfVisibilityState visibility_state) { | 256 ShelfVisibilityState visibility_state) { |
260 internal::ShelfLayoutManager* shelf = | 257 internal::ShelfLayoutManager* shelf = |
261 RootWindowController::ForWindow(window)->shelf()-> | 258 RootWindowController::ForWindow(window)->shelf()-> |
262 shelf_layout_manager(); | 259 shelf_layout_manager(); |
263 shelf->SetState(visibility_state); | 260 shelf->SetState(visibility_state); |
264 } | 261 } |
265 | 262 |
266 internal::ShelfView* GetShelfView(Launcher* launcher) { | 263 internal::ShelfView* GetShelfView(Shelf* shelf) { |
267 return test::LauncherTestAPI(launcher).shelf_view(); | 264 return test::ShelfTestAPI(shelf).shelf_view(); |
268 } | 265 } |
269 | 266 |
270 private: | 267 private: |
271 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 268 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
272 | 269 |
273 bool IsHorizontal(ShelfAlignment alignment) { | 270 bool IsHorizontal(ShelfAlignment alignment) { |
274 return alignment == SHELF_ALIGNMENT_BOTTOM || | 271 return alignment == SHELF_ALIGNMENT_BOTTOM || |
275 alignment == SHELF_ALIGNMENT_TOP; | 272 alignment == SHELF_ALIGNMENT_TOP; |
276 } | 273 } |
277 | 274 |
(...skipping 21 matching lines...) Expand all Loading... |
299 PanelLayoutManagerTest::TearDown(); | 296 PanelLayoutManagerTest::TearDown(); |
300 } | 297 } |
301 | 298 |
302 private: | 299 private: |
303 bool is_rtl_; | 300 bool is_rtl_; |
304 std::string original_locale; | 301 std::string original_locale; |
305 | 302 |
306 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTextDirectionTest); | 303 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTextDirectionTest); |
307 }; | 304 }; |
308 | 305 |
309 // Tests that a created panel window is above the launcher icon in LTR and RTL. | 306 // Tests that a created panel window is above the shelf icon in LTR and RTL. |
310 TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) { | 307 TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) { |
311 gfx::Rect bounds(0, 0, 201, 201); | 308 gfx::Rect bounds(0, 0, 201, 201); |
312 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); | 309 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); |
313 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); | 310 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); |
314 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); | 311 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); |
315 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); | 312 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); |
316 } | 313 } |
317 | 314 |
318 // Tests that a created panel window is successfully aligned over a hidden | 315 // Tests that a created panel window is successfully aligned over a hidden |
319 // launcher icon. | 316 // shelf icon. |
320 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { | 317 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { |
321 gfx::Rect bounds(0, 0, 201, 201); | 318 gfx::Rect bounds(0, 0, 201, 201); |
322 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), | 319 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), |
323 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 320 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
324 scoped_ptr<aura::Window> normal_window(CreateNormalWindow(bounds)); | 321 scoped_ptr<aura::Window> normal_window(CreateNormalWindow(bounds)); |
325 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); | 322 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); |
326 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); | 323 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); |
327 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); | 324 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); |
328 } | 325 } |
329 | 326 |
330 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIconSecondDisplay) { | 327 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIconSecondDisplay) { |
331 if (!SupportsMultipleDisplays()) | 328 if (!SupportsMultipleDisplays()) |
332 return; | 329 return; |
333 | 330 |
334 // Keep the displays wide so that launchers have enough | 331 // Keep the displays wide so that shelves have enough space for shelves |
335 // space for launcher buttons. | 332 // buttons. |
336 UpdateDisplay("400x400,600x400"); | 333 UpdateDisplay("400x400,600x400"); |
337 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 334 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
338 | 335 |
339 scoped_ptr<aura::Window> normal_window( | 336 scoped_ptr<aura::Window> normal_window( |
340 CreateNormalWindow(gfx::Rect(450, 0, 100, 100))); | 337 CreateNormalWindow(gfx::Rect(450, 0, 100, 100))); |
341 scoped_ptr<aura::Window> panel(CreatePanelWindow(gfx::Rect(400, 0, 50, 50))); | 338 scoped_ptr<aura::Window> panel(CreatePanelWindow(gfx::Rect(400, 0, 50, 50))); |
342 EXPECT_EQ(root_windows[1], panel->GetRootWindow()); | 339 EXPECT_EQ(root_windows[1], panel->GetRootWindow()); |
343 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(panel.get())); | 340 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(panel.get())); |
344 gfx::Rect shelf_visible_position = panel->GetBoundsInScreen(); | 341 gfx::Rect shelf_visible_position = panel->GetBoundsInScreen(); |
345 | 342 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); | 388 EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); |
392 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); | 389 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); |
393 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); | 390 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); |
394 | 391 |
395 wm::ActivateWindow(w3.get()); | 392 wm::ActivateWindow(w3.get()); |
396 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); | 393 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); |
397 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); | 394 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); |
398 } | 395 } |
399 | 396 |
400 TEST_F(PanelLayoutManagerTest, MultiplePanelStackingVertical) { | 397 TEST_F(PanelLayoutManagerTest, MultiplePanelStackingVertical) { |
401 // set launcher shelf to be aligned on the right | 398 // Set shelf to be aligned on the right. |
402 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT); | 399 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT); |
403 | 400 |
404 // Size panels in such a way that ordering them by X coordinate would cause | 401 // Size panels in such a way that ordering them by X coordinate would cause |
405 // stacking order to be incorrect. Test that stacking order is based on Y. | 402 // stacking order to be incorrect. Test that stacking order is based on Y. |
406 scoped_ptr<aura::Window> w1(CreatePanelWindow(gfx::Rect(0, 0, 210, 201))); | 403 scoped_ptr<aura::Window> w1(CreatePanelWindow(gfx::Rect(0, 0, 210, 201))); |
407 scoped_ptr<aura::Window> w2(CreatePanelWindow(gfx::Rect(0, 0, 220, 201))); | 404 scoped_ptr<aura::Window> w2(CreatePanelWindow(gfx::Rect(0, 0, 220, 201))); |
408 scoped_ptr<aura::Window> w3(CreatePanelWindow(gfx::Rect(0, 0, 200, 201))); | 405 scoped_ptr<aura::Window> w3(CreatePanelWindow(gfx::Rect(0, 0, 200, 201))); |
409 | 406 |
410 // Default stacking order. | 407 // Default stacking order. |
411 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); | 408 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 TEST_F(PanelLayoutManagerTest, FanWindows) { | 537 TEST_F(PanelLayoutManagerTest, FanWindows) { |
541 gfx::Rect bounds(0, 0, 201, 201); | 538 gfx::Rect bounds(0, 0, 201, 201); |
542 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 539 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
543 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 540 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
544 scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 541 scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
545 | 542 |
546 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 543 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
547 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); | 544 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); |
548 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); | 545 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); |
549 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); | 546 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); |
550 Launcher* launcher = Launcher::ForPrimaryDisplay(); | 547 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
551 int icon_x1 = launcher->GetScreenBoundsOfItemIconForWindow(w1.get()).x(); | 548 int icon_x1 = shelf->GetScreenBoundsOfItemIconForWindow(w1.get()).x(); |
552 int icon_x2 = launcher->GetScreenBoundsOfItemIconForWindow(w2.get()).x(); | 549 int icon_x2 = shelf->GetScreenBoundsOfItemIconForWindow(w2.get()).x(); |
553 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); | 550 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); |
554 int spacing = window_x2 - window_x1; | 551 int spacing = window_x2 - window_x1; |
555 EXPECT_GT(spacing, icon_x2 - icon_x1); | 552 EXPECT_GT(spacing, icon_x2 - icon_x1); |
556 } | 553 } |
557 | 554 |
558 TEST_F(PanelLayoutManagerTest, FanLargeWindow) { | 555 TEST_F(PanelLayoutManagerTest, FanLargeWindow) { |
559 gfx::Rect small_bounds(0, 0, 201, 201); | 556 gfx::Rect small_bounds(0, 0, 201, 201); |
560 gfx::Rect large_bounds(0, 0, 501, 201); | 557 gfx::Rect large_bounds(0, 0, 501, 201); |
561 scoped_ptr<aura::Window> w1(CreatePanelWindow(small_bounds)); | 558 scoped_ptr<aura::Window> w1(CreatePanelWindow(small_bounds)); |
562 scoped_ptr<aura::Window> w2(CreatePanelWindow(large_bounds)); | 559 scoped_ptr<aura::Window> w2(CreatePanelWindow(large_bounds)); |
(...skipping 28 matching lines...) Expand all Loading... |
591 // Activate the window, ensure callout is visible. | 588 // Activate the window, ensure callout is visible. |
592 wm::ActivateWindow(window.get()); | 589 wm::ActivateWindow(window.get()); |
593 RunAllPendingInMessageLoop(); | 590 RunAllPendingInMessageLoop(); |
594 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); | 591 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); |
595 } | 592 } |
596 | 593 |
597 TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { | 594 TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { |
598 if (!SupportsMultipleDisplays()) | 595 if (!SupportsMultipleDisplays()) |
599 return; | 596 return; |
600 | 597 |
601 // Keep the displays wide so that launchers have enough | 598 // Keep the displays wide so that shelves have enough space for launcher |
602 // space for launcher buttons. | 599 // buttons. |
603 UpdateDisplay("600x400,600x400"); | 600 UpdateDisplay("600x400,600x400"); |
604 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 601 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
605 | 602 |
606 scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 603 scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
607 scoped_ptr<aura::Window> p2_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 604 scoped_ptr<aura::Window> p2_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
608 scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 605 scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
609 scoped_ptr<aura::Window> p2_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 606 scoped_ptr<aura::Window> p2_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
610 | 607 |
611 ShelfView* shelf_view_1st = GetShelfView(Launcher::ForPrimaryDisplay()); | 608 ShelfView* shelf_view_1st = GetShelfView(Shelf::ForPrimaryDisplay()); |
612 ShelfView* shelf_view_2nd = | 609 ShelfView* shelf_view_2nd = |
613 GetShelfView(Launcher::ForWindow(root_windows[1])); | 610 GetShelfView(Shelf::ForWindow(root_windows[1])); |
614 | 611 |
615 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); | 612 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); |
616 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); | 613 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); |
617 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 614 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
618 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); | 615 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); |
619 | 616 |
620 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p1_d1->parent()->id()); | 617 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p1_d1->parent()->id()); |
621 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p2_d1->parent()->id()); | 618 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p2_d1->parent()->id()); |
622 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p1_d2->parent()->id()); | 619 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p1_d2->parent()->id()); |
623 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p2_d2->parent()->id()); | 620 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p2_d2->parent()->id()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 EXPECT_EQ(root_windows[0], p1_d2->GetRootWindow()); | 667 EXPECT_EQ(root_windows[0], p1_d2->GetRootWindow()); |
671 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); | 668 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); |
672 EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains( | 669 EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains( |
673 p1_d1->GetBoundsInScreen())); | 670 p1_d1->GetBoundsInScreen())); |
674 } | 671 } |
675 | 672 |
676 TEST_F(PanelLayoutManagerTest, PanelAttachPositionMultipleDisplays) { | 673 TEST_F(PanelLayoutManagerTest, PanelAttachPositionMultipleDisplays) { |
677 if (!SupportsMultipleDisplays()) | 674 if (!SupportsMultipleDisplays()) |
678 return; | 675 return; |
679 | 676 |
680 // Keep the displays wide so that launchers have enough space for launcher | 677 // Keep the displays wide so that shelves have enough space for shelf buttons. |
681 // buttons. Use differently sized displays so the launcher is in a different | 678 // Use differently sized displays so the shelf is in a different |
682 // position on second display. | 679 // position on second display. |
683 UpdateDisplay("600x400,600x600"); | 680 UpdateDisplay("600x400,600x600"); |
684 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 681 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
685 | 682 |
686 scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 683 scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
687 scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 684 scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
688 | 685 |
689 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); | 686 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); |
690 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 687 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
691 | 688 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 EXPECT_TRUE(w1->IsVisible()); | 788 EXPECT_TRUE(w1->IsVisible()); |
792 EXPECT_FALSE(w2->IsVisible()); | 789 EXPECT_FALSE(w2->IsVisible()); |
793 EXPECT_TRUE(w3->IsVisible()); | 790 EXPECT_TRUE(w3->IsVisible()); |
794 } | 791 } |
795 | 792 |
796 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, | 793 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, |
797 testing::Bool()); | 794 testing::Bool()); |
798 | 795 |
799 } // namespace internal | 796 } // namespace internal |
800 } // namespace ash | 797 } // namespace ash |
OLD | NEW |