Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 protected: | 52 protected: |
| 53 gfx::Point CalculateDragPoint(const WindowResizer& resizer, | 53 gfx::Point CalculateDragPoint(const WindowResizer& resizer, |
| 54 int delta_x, | 54 int delta_x, |
| 55 int delta_y) const { | 55 int delta_y) const { |
| 56 gfx::Point location = resizer.GetInitialLocation(); | 56 gfx::Point location = resizer.GetInitialLocation(); |
| 57 location.set_x(location.x() + delta_x); | 57 location.set_x(location.x() + delta_x); |
| 58 location.set_y(location.y() + delta_y); | 58 location.set_y(location.y() + delta_y); |
| 59 return location; | 59 return location; |
| 60 } | 60 } |
| 61 | 61 |
| 62 aura::Window* CreateWindow(const gfx::Point& origin) { | |
| 63 gfx::Rect bounds(origin, gfx::Size(101, 101)); | |
| 64 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | |
| 65 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, bounds); | |
| 66 return window; | |
| 67 } | |
|
oshima
2014/02/21 19:49:46
Looks a bit overkill. Can you just do
CreateTestW
flackr
2014/02/24 16:21:10
Done.
| |
| 68 | |
| 62 aura::Window* CreatePanelWindow(const gfx::Point& origin) { | 69 aura::Window* CreatePanelWindow(const gfx::Point& origin) { |
| 63 gfx::Rect bounds(origin, gfx::Size(101, 101)); | 70 gfx::Rect bounds(origin, gfx::Size(101, 101)); |
| 64 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 71 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
| 65 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); | 72 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); |
| 66 shelf_delegate_->AddShelfItem(window); | 73 shelf_delegate_->AddShelfItem(window); |
| 67 PanelLayoutManager* manager = | 74 PanelLayoutManager* manager = |
| 68 static_cast<PanelLayoutManager*>( | 75 static_cast<PanelLayoutManager*>( |
| 69 Shell::GetContainer(window->GetRootWindow(), | 76 Shell::GetContainer(window->GetRootWindow(), |
| 70 internal::kShellWindowId_PanelContainer)-> | 77 internal::kShellWindowId_PanelContainer)-> |
| 71 layout_manager()); | 78 layout_manager()); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 // Should stick to other launcher. | 400 // Should stick to other launcher. |
| 394 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); | 401 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); |
| 395 DragEnd(); | 402 DragEnd(); |
| 396 | 403 |
| 397 // When dropped should move to second display's panel container. | 404 // When dropped should move to second display's panel container. |
| 398 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 405 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 399 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); | 406 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); |
| 400 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 407 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); |
| 401 } | 408 } |
| 402 | 409 |
| 410 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) { | |
| 411 if (!SupportsMultipleDisplays()) | |
| 412 return; | |
| 413 | |
| 414 UpdateDisplay("600x400,600x600"); | |
| 415 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
| 416 scoped_ptr<aura::Window> window( | |
| 417 CreatePanelWindow(gfx::Point(0, 0))); | |
| 418 scoped_ptr<aura::Window> fullscreen( | |
| 419 CreateWindow(gfx::Point(600, 0))); | |
| 420 wm::GetWindowState(fullscreen.get())->Activate(); | |
| 421 wm::GetWindowState(fullscreen.get())->ToggleFullscreen(); | |
| 422 EXPECT_TRUE(wm::GetWindowState(fullscreen.get())->IsFullscreen()); | |
| 423 | |
| 424 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | |
| 425 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | |
| 426 | |
| 427 // Activate and drag the window to the other display's launcher. | |
| 428 wm::GetWindowState(window.get())->Activate(); | |
| 429 DragStart(window.get()); | |
| 430 DragMove(500, 250); | |
| 431 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | |
| 432 EXPECT_GT(window->GetBoundsInScreen().y(), | |
| 433 initial_bounds.y() + 200); | |
| 434 DragEnd(); | |
| 435 | |
| 436 // When dropped should move to second display's panel container. | |
| 437 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | |
| 438 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); | |
| 439 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | |
| 440 EXPECT_TRUE(window->IsVisible()); | |
| 441 EXPECT_TRUE(wm::GetWindowState(window.get())->IsActive()); | |
| 442 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); | |
| 443 } | |
| 444 | |
| 403 TEST_F(PanelWindowResizerTest, RevertDragRestoresAttachment) { | 445 TEST_F(PanelWindowResizerTest, RevertDragRestoresAttachment) { |
| 404 scoped_ptr<aura::Window> window( | 446 scoped_ptr<aura::Window> window( |
| 405 CreatePanelWindow(gfx::Point(0, 0))); | 447 CreatePanelWindow(gfx::Point(0, 0))); |
| 406 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); | 448 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); |
| 407 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 449 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); |
| 408 DragStart(window.get()); | 450 DragStart(window.get()); |
| 409 DragMove(0, -100); | 451 DragMove(0, -100); |
| 410 DragRevert(); | 452 DragRevert(); |
| 411 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); | 453 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); |
| 412 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); | 454 EXPECT_EQ(internal::kShellWindowId_PanelContainer, window->parent()->id()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, | 569 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, |
| 528 testing::Bool()); | 570 testing::Bool()); |
| 529 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, | 571 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, |
| 530 PanelWindowResizerTransientTest, | 572 PanelWindowResizerTransientTest, |
| 531 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 573 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 532 ui::wm::WINDOW_TYPE_PANEL, | 574 ui::wm::WINDOW_TYPE_PANEL, |
| 533 ui::wm::WINDOW_TYPE_POPUP)); | 575 ui::wm::WINDOW_TYPE_POPUP)); |
| 534 | 576 |
| 535 } // namespace internal | 577 } // namespace internal |
| 536 } // namespace ash | 578 } // namespace ash |
| OLD | NEW |