| 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/common/wm/panels/panel_window_resizer.h" | 5 #include "ash/common/wm/panels/panel_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_layout_manager.h" | 7 #include "ash/common/shelf/shelf_layout_manager.h" |
| 8 #include "ash/common/shelf/shelf_model.h" | 8 #include "ash/common/shelf/shelf_model.h" |
| 9 #include "ash/common/shelf/shelf_widget.h" | 9 #include "ash/common/shelf/shelf_widget.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 DragEnd(); | 263 DragEnd(); |
| 264 | 264 |
| 265 // When the drag ends the window should be detached and placed where it was | 265 // When the drag ends the window should be detached and placed where it was |
| 266 // dragged to. | 266 // dragged to. |
| 267 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 267 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
| 268 EXPECT_FALSE(state->IsMinimized()); | 268 EXPECT_FALSE(state->IsMinimized()); |
| 269 EXPECT_EQ(expected_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 269 EXPECT_EQ(expected_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 270 } | 270 } |
| 271 | 271 |
| 272 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) { | 272 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) { |
| 273 if (!SupportsMultipleDisplays()) | |
| 274 return; | |
| 275 | |
| 276 UpdateDisplay("600x400,600x400"); | 273 UpdateDisplay("600x400,600x400"); |
| 277 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 274 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 278 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(600, 0))); | 275 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(600, 0))); |
| 279 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 276 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 280 DetachReattachTest(window.get(), 0, -1); | 277 DetachReattachTest(window.get(), 0, -1); |
| 281 } | 278 } |
| 282 | 279 |
| 283 TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) { | 280 TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) { |
| 284 if (!SupportsMultipleDisplays()) | |
| 285 return; | |
| 286 | |
| 287 UpdateDisplay("600x400,600x400"); | 281 UpdateDisplay("600x400,600x400"); |
| 288 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 282 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 289 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 283 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
| 290 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 284 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 291 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 285 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 292 DragStart(window.get()); | 286 DragStart(window.get()); |
| 293 DragMove(0, -100); | 287 DragMove(0, -100); |
| 294 DragEnd(); | 288 DragEnd(); |
| 295 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 289 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 296 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); | 290 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); |
| 297 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 291 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
| 298 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 292 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
| 299 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 293 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
| 300 | 294 |
| 301 DragStart(window.get()); | 295 DragStart(window.get()); |
| 302 DragMove(500, 0); | 296 DragMove(500, 0); |
| 303 DragEnd(); | 297 DragEnd(); |
| 304 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 298 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 305 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 299 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
| 306 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 300 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
| 307 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 301 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
| 308 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 302 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
| 309 } | 303 } |
| 310 | 304 |
| 311 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) { | 305 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) { |
| 312 if (!SupportsMultipleDisplays()) | |
| 313 return; | |
| 314 | |
| 315 UpdateDisplay("600x400,600x400"); | 306 UpdateDisplay("600x400,600x400"); |
| 316 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 307 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 317 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 308 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
| 318 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 309 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 319 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 310 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 320 DragStart(window.get()); | 311 DragStart(window.get()); |
| 321 DragMove(500, -100); | 312 DragMove(500, -100); |
| 322 DragEnd(); | 313 DragEnd(); |
| 323 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 314 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 324 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 315 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
| 325 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 316 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
| 326 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 317 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
| 327 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 318 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
| 328 } | 319 } |
| 329 | 320 |
| 330 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { | 321 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { |
| 331 if (!SupportsMultipleDisplays()) | |
| 332 return; | |
| 333 | |
| 334 UpdateDisplay("600x400,600x600"); | 322 UpdateDisplay("600x400,600x600"); |
| 335 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 323 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 336 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 324 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
| 337 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 325 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 338 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 326 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 339 | 327 |
| 340 // Detach the window. | 328 // Detach the window. |
| 341 DragStart(window.get()); | 329 DragStart(window.get()); |
| 342 DragMove(0, -100); | 330 DragMove(0, -100); |
| 343 DragEnd(); | 331 DragEnd(); |
| 344 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 332 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 345 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 333 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
| 346 | 334 |
| 347 // Drag the window just above the other display's launcher. | 335 // Drag the window just above the other display's launcher. |
| 348 DragStart(window.get()); | 336 DragStart(window.get()); |
| 349 DragMove(500, 295); | 337 DragMove(500, 295); |
| 350 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 338 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
| 351 | 339 |
| 352 // Should stick to other launcher. | 340 // Should stick to other launcher. |
| 353 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); | 341 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); |
| 354 DragEnd(); | 342 DragEnd(); |
| 355 | 343 |
| 356 // When dropped should move to second display's panel container. | 344 // When dropped should move to second display's panel container. |
| 357 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 345 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 358 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); | 346 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); |
| 359 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); | 347 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
| 360 } | 348 } |
| 361 | 349 |
| 362 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) { | 350 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) { |
| 363 if (!SupportsMultipleDisplays()) | |
| 364 return; | |
| 365 | |
| 366 UpdateDisplay("600x400,600x600"); | 351 UpdateDisplay("600x400,600x600"); |
| 367 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 352 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 368 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 353 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
| 369 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 354 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 370 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 355 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 371 | 356 |
| 372 // Drag the window just above the other display's launcher. | 357 // Drag the window just above the other display's launcher. |
| 373 DragStart(window.get()); | 358 DragStart(window.get()); |
| 374 DragMove(500, 195); | 359 DragMove(500, 195); |
| 375 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 360 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
| 376 | 361 |
| 377 // Should stick to other launcher. | 362 // Should stick to other launcher. |
| 378 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); | 363 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); |
| 379 DragEnd(); | 364 DragEnd(); |
| 380 | 365 |
| 381 // When dropped should move to second display's panel container. | 366 // When dropped should move to second display's panel container. |
| 382 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 367 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 383 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); | 368 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); |
| 384 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); | 369 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
| 385 } | 370 } |
| 386 | 371 |
| 387 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) { | 372 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) { |
| 388 if (!SupportsMultipleDisplays()) | |
| 389 return; | |
| 390 | |
| 391 UpdateDisplay("600x400,600x600"); | 373 UpdateDisplay("600x400,600x600"); |
| 392 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 374 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 393 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 375 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
| 394 std::unique_ptr<aura::Window> fullscreen( | 376 std::unique_ptr<aura::Window> fullscreen( |
| 395 CreateTestWindowInShellWithBounds(gfx::Rect(600, 0, 101, 101))); | 377 CreateTestWindowInShellWithBounds(gfx::Rect(600, 0, 101, 101))); |
| 396 wm::GetWindowState(fullscreen.get())->Activate(); | 378 wm::GetWindowState(fullscreen.get())->Activate(); |
| 397 const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 379 const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 398 wm::GetWindowState(fullscreen.get())->OnWMEvent(&event); | 380 wm::GetWindowState(fullscreen.get())->OnWMEvent(&event); |
| 399 EXPECT_TRUE(wm::GetWindowState(fullscreen.get())->IsFullscreen()); | 381 EXPECT_TRUE(wm::GetWindowState(fullscreen.get())->IsFullscreen()); |
| 400 | 382 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 INSTANTIATE_TEST_CASE_P(LtrRtl, | 516 INSTANTIATE_TEST_CASE_P(LtrRtl, |
| 535 PanelWindowResizerTextDirectionTest, | 517 PanelWindowResizerTextDirectionTest, |
| 536 testing::Bool()); | 518 testing::Bool()); |
| 537 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, | 519 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, |
| 538 PanelWindowResizerTransientTest, | 520 PanelWindowResizerTransientTest, |
| 539 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 521 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 540 ui::wm::WINDOW_TYPE_PANEL, | 522 ui::wm::WINDOW_TYPE_PANEL, |
| 541 ui::wm::WINDOW_TYPE_POPUP)); | 523 ui::wm::WINDOW_TYPE_POPUP)); |
| 542 | 524 |
| 543 } // namespace ash | 525 } // namespace ash |
| OLD | NEW |