OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/wm/panels/panel_window_resizer.h" | 5 #include "ash/wm/panels/panel_window_resizer.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_model.h" | 10 #include "ash/shelf/shelf_model.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 if (!SupportsHostWindowResize()) | 266 if (!SupportsHostWindowResize()) |
267 return; | 267 return; |
268 | 268 |
269 ash::Shell* shell = ash::Shell::GetInstance(); | 269 ash::Shell* shell = ash::Shell::GetInstance(); |
270 shell->SetShelfAlignment(SHELF_ALIGNMENT_TOP, shell->GetPrimaryRootWindow()); | 270 shell->SetShelfAlignment(SHELF_ALIGNMENT_TOP, shell->GetPrimaryRootWindow()); |
271 scoped_ptr<aura::Window> window( | 271 scoped_ptr<aura::Window> window( |
272 CreatePanelWindow(gfx::Point(0, 0))); | 272 CreatePanelWindow(gfx::Point(0, 0))); |
273 DetachReattachTest(window.get(), 0, 1); | 273 DetachReattachTest(window.get(), 0, 1); |
274 } | 274 } |
275 | 275 |
| 276 // Tests that a drag continues when the shelf is hidden. This occurs as part of |
| 277 // the animation when switching profiles. http://crbug.com/393047. |
| 278 TEST_F(PanelWindowResizerTest, DetachThenHideShelf) { |
| 279 if (!SupportsHostWindowResize()) |
| 280 return; |
| 281 scoped_ptr<aura::Window> window( |
| 282 CreatePanelWindow(gfx::Point(0, 0))); |
| 283 wm::WindowState* state = wm::GetWindowState(window.get()); |
| 284 gfx::Rect expected_bounds = window->GetBoundsInScreen(); |
| 285 expected_bounds.set_y(expected_bounds.y() - 100); |
| 286 DragStart(window.get()); |
| 287 DragMove(0, -100); |
| 288 EXPECT_FALSE(state->IsMinimized()); |
| 289 |
| 290 // Hide the shelf. This minimizes all attached windows but should ignore |
| 291 // the dragged window. |
| 292 ShelfLayoutManager* shelf = RootWindowController::ForWindow(window.get())-> |
| 293 shelf()->shelf_layout_manager(); |
| 294 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 295 shelf->UpdateVisibilityState(); |
| 296 RunAllPendingInMessageLoop(); |
| 297 EXPECT_FALSE(state->IsMinimized()); |
| 298 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
| 299 DragEnd(); |
| 300 |
| 301 // When the drag ends the window should be detached and placed where it was |
| 302 // dragged to. |
| 303 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
| 304 EXPECT_FALSE(state->IsMinimized()); |
| 305 EXPECT_EQ(expected_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 306 } |
| 307 |
276 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) { | 308 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) { |
277 if (!SupportsMultipleDisplays()) | 309 if (!SupportsMultipleDisplays()) |
278 return; | 310 return; |
279 | 311 |
280 UpdateDisplay("600x400,600x400"); | 312 UpdateDisplay("600x400,600x400"); |
281 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 313 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
282 scoped_ptr<aura::Window> window( | 314 scoped_ptr<aura::Window> window( |
283 CreatePanelWindow(gfx::Point(600, 0))); | 315 CreatePanelWindow(gfx::Point(600, 0))); |
284 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 316 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
285 DetachReattachTest(window.get(), 0, -1); | 317 DetachReattachTest(window.get(), 0, -1); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 | 586 |
555 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, | 587 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, |
556 testing::Bool()); | 588 testing::Bool()); |
557 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, | 589 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, |
558 PanelWindowResizerTransientTest, | 590 PanelWindowResizerTransientTest, |
559 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 591 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
560 ui::wm::WINDOW_TYPE_PANEL, | 592 ui::wm::WINDOW_TYPE_PANEL, |
561 ui::wm::WINDOW_TYPE_POPUP)); | 593 ui::wm::WINDOW_TYPE_POPUP)); |
562 | 594 |
563 } // namespace ash | 595 } // namespace ash |
OLD | NEW |