| 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/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 | 258 |
| 259 TEST_F(PanelWindowResizerTest, PanelDetachReattachTop) { | 259 TEST_F(PanelWindowResizerTest, PanelDetachReattachTop) { |
| 260 ash::Shell* shell = ash::Shell::GetInstance(); | 260 ash::Shell* shell = ash::Shell::GetInstance(); |
| 261 shell->SetShelfAlignment(SHELF_ALIGNMENT_TOP, shell->GetPrimaryRootWindow()); | 261 shell->SetShelfAlignment(SHELF_ALIGNMENT_TOP, shell->GetPrimaryRootWindow()); |
| 262 scoped_ptr<aura::Window> window( | 262 scoped_ptr<aura::Window> window( |
| 263 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); | 263 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); |
| 264 DetachReattachTest(window.get(), 0, 1); | 264 DetachReattachTest(window.get(), 0, 1); |
| 265 } | 265 } |
| 266 | 266 |
| 267 #if defined(OS_WIN) | 267 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) { |
| 268 // Multiple displays aren't supported on Windows Metro/Ash. | 268 if (!SupportsMultipleDisplays()) |
| 269 // http://crbug.com/165962 | 269 return; |
| 270 #define MAYBE_PanelDetachReattachMultipleDisplays \ | |
| 271 DISABLED_PanelDetachReattachMultipleDisplays | |
| 272 #define MAYBE_DetachThenDragAcrossDisplays DISABLED_DetachThenDragAcrossDisplays | |
| 273 #define MAYBE_DetachAcrossDisplays DISABLED_DetachAcrossDisplays | |
| 274 #define MAYBE_DetachThenAttachToSecondDisplay \ | |
| 275 DISABLED_DetachThenAttachToSecondDisplay | |
| 276 #define MAYBE_AttachToSecondDisplay DISABLED_AttachToSecondDisplay | |
| 277 #else | |
| 278 #define MAYBE_PanelDetachReattachMultipleDisplays \ | |
| 279 PanelDetachReattachMultipleDisplays | |
| 280 #define MAYBE_DetachThenDragAcrossDisplays DetachThenDragAcrossDisplays | |
| 281 #define MAYBE_DetachAcrossDisplays DetachAcrossDisplays | |
| 282 #define MAYBE_DetachThenAttachToSecondDisplay DetachThenAttachToSecondDisplay | |
| 283 #define MAYBE_AttachToSecondDisplay AttachToSecondDisplay | |
| 284 #endif | |
| 285 | 270 |
| 286 TEST_F(PanelWindowResizerTest, MAYBE_PanelDetachReattachMultipleDisplays) { | |
| 287 UpdateDisplay("600x400,600x400"); | 271 UpdateDisplay("600x400,600x400"); |
| 288 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 272 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 289 scoped_ptr<aura::Window> window( | 273 scoped_ptr<aura::Window> window( |
| 290 CreatePanelWindow(gfx::Rect(600, 0, 201, 201))); | 274 CreatePanelWindow(gfx::Rect(600, 0, 201, 201))); |
| 291 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 275 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 292 DetachReattachTest(window.get(), 0, -1); | 276 DetachReattachTest(window.get(), 0, -1); |
| 293 } | 277 } |
| 294 | 278 |
| 295 TEST_F(PanelWindowResizerTest, MAYBE_DetachThenDragAcrossDisplays) { | 279 TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) { |
| 280 if (!SupportsMultipleDisplays()) |
| 281 return; |
| 282 |
| 296 UpdateDisplay("600x400,600x400"); | 283 UpdateDisplay("600x400,600x400"); |
| 297 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 284 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 298 scoped_ptr<aura::Window> window( | 285 scoped_ptr<aura::Window> window( |
| 299 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); | 286 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); |
| 300 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 287 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 301 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 288 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 302 DragStart(window.get()); | 289 DragStart(window.get()); |
| 303 DragMove(0, -100); | 290 DragMove(0, -100); |
| 304 DragEnd(); | 291 DragEnd(); |
| 305 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 292 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 306 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); | 293 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); |
| 307 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 294 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
| 308 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 295 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
| 309 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, | 296 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, |
| 310 window->parent()->id()); | 297 window->parent()->id()); |
| 311 | 298 |
| 312 DragStart(window.get()); | 299 DragStart(window.get()); |
| 313 DragMove(500, 0); | 300 DragMove(500, 0); |
| 314 DragEnd(); | 301 DragEnd(); |
| 315 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 302 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 316 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 303 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
| 317 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 304 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
| 318 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 305 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
| 319 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, | 306 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, |
| 320 window->parent()->id()); | 307 window->parent()->id()); |
| 321 } | 308 } |
| 322 | 309 |
| 323 TEST_F(PanelWindowResizerTest, MAYBE_DetachAcrossDisplays) { | 310 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) { |
| 311 if (!SupportsMultipleDisplays()) |
| 312 return; |
| 313 |
| 324 UpdateDisplay("600x400,600x400"); | 314 UpdateDisplay("600x400,600x400"); |
| 325 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 315 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 326 scoped_ptr<aura::Window> window( | 316 scoped_ptr<aura::Window> window( |
| 327 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); | 317 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); |
| 328 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 318 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 329 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 319 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 330 DragStart(window.get()); | 320 DragStart(window.get()); |
| 331 DragMove(500, -100); | 321 DragMove(500, -100); |
| 332 DragEnd(); | 322 DragEnd(); |
| 333 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 323 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 334 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 324 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
| 335 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 325 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
| 336 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 326 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
| 337 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, | 327 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, |
| 338 window->parent()->id()); | 328 window->parent()->id()); |
| 339 } | 329 } |
| 340 | 330 |
| 341 TEST_F(PanelWindowResizerTest, MAYBE_DetachThenAttachToSecondDisplay) { | 331 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { |
| 332 if (!SupportsMultipleDisplays()) |
| 333 return; |
| 334 |
| 342 UpdateDisplay("600x400,600x600"); | 335 UpdateDisplay("600x400,600x600"); |
| 343 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 336 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 344 scoped_ptr<aura::Window> window( | 337 scoped_ptr<aura::Window> window( |
| 345 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); | 338 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); |
| 346 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 339 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 347 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 340 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 348 | 341 |
| 349 // Detach the window. | 342 // Detach the window. |
| 350 DragStart(window.get()); | 343 DragStart(window.get()); |
| 351 DragMove(0, -100); | 344 DragMove(0, -100); |
| 352 DragEnd(); | 345 DragEnd(); |
| 353 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 346 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 354 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 347 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
| 355 | 348 |
| 356 // Drag the window just above the other display's launcher. | 349 // Drag the window just above the other display's launcher. |
| 357 DragStart(window.get()); | 350 DragStart(window.get()); |
| 358 DragMove(500, 295); | 351 DragMove(500, 295); |
| 359 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 352 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
| 360 | 353 |
| 361 // Should stick to other launcher. | 354 // Should stick to other launcher. |
| 362 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); | 355 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); |
| 363 DragEnd(); | 356 DragEnd(); |
| 364 | 357 |
| 365 // When dropped should move to second display's panel container. | 358 // When dropped should move to second display's panel container. |
| 366 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 359 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 367 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); | 360 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); |
| 368 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 361 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); |
| 369 } | 362 } |
| 370 | 363 |
| 371 TEST_F(PanelWindowResizerTest, MAYBE_AttachToSecondDisplay) { | 364 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) { |
| 365 if (!SupportsMultipleDisplays()) |
| 366 return; |
| 367 |
| 372 UpdateDisplay("600x400,600x600"); | 368 UpdateDisplay("600x400,600x600"); |
| 373 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 369 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 374 scoped_ptr<aura::Window> window( | 370 scoped_ptr<aura::Window> window( |
| 375 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); | 371 CreatePanelWindow(gfx::Rect(0, 0, 201, 201))); |
| 376 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 372 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 377 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 373 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 378 | 374 |
| 379 // Drag the window just above the other display's launcher. | 375 // Drag the window just above the other display's launcher. |
| 380 DragStart(window.get()); | 376 DragStart(window.get()); |
| 381 DragMove(500, 195); | 377 DragMove(500, 195); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 ash::Shell* shell = ash::Shell::GetInstance(); | 444 ash::Shell* shell = ash::Shell::GetInstance(); |
| 449 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow()); | 445 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow()); |
| 450 DragAlongShelfReorder(0, -1); | 446 DragAlongShelfReorder(0, -1); |
| 451 } | 447 } |
| 452 | 448 |
| 453 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, | 449 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, |
| 454 testing::Bool()); | 450 testing::Bool()); |
| 455 | 451 |
| 456 } // namespace internal | 452 } // namespace internal |
| 457 } // namespace ash | 453 } // namespace ash |
| OLD | NEW |