| 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" |
| 11 #include "ash/shelf/shelf_types.h" | 11 #include "ash/shelf/shelf_types.h" |
| 12 #include "ash/shelf/shelf_util.h" | 12 #include "ash/shelf/shelf_util.h" |
| 13 #include "ash/shelf/shelf_widget.h" | 13 #include "ash/shelf/shelf_widget.h" |
| 14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 15 #include "ash/shell_window_ids.h" | 15 #include "ash/shell_window_ids.h" |
| 16 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
| 17 #include "ash/test/cursor_manager_test_api.h" | 17 #include "ash/test/cursor_manager_test_api.h" |
| 18 #include "ash/test/shell_test_api.h" | 18 #include "ash/test/shell_test_api.h" |
| 19 #include "ash/test/test_shelf_delegate.h" | 19 #include "ash/test/test_shelf_delegate.h" |
| 20 #include "ash/wm/drag_window_resizer.h" | 20 #include "ash/wm/drag_window_resizer.h" |
| 21 #include "ash/wm/panels/panel_layout_manager.h" | 21 #include "ash/wm/panels/panel_layout_manager.h" |
| 22 #include "ash/wm/window_state.h" | 22 #include "ash/wm/window_state.h" |
| 23 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
| 24 #include "ui/aura/client/aura_constants.h" | 24 #include "ui/aura/client/aura_constants.h" |
| 25 #include "ui/aura/root_window.h" | 25 #include "ui/aura/root_window.h" |
| 26 #include "ui/base/hit_test.h" | 26 #include "ui/base/hit_test.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/ui_base_types.h" | 28 #include "ui/base/ui_base_types.h" |
| 29 #include "ui/views/corewm/window_util.h" |
| 29 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| 30 | 31 |
| 31 namespace ash { | 32 namespace ash { |
| 32 namespace internal { | 33 namespace internal { |
| 33 | 34 |
| 34 class PanelWindowResizerTest : public test::AshTestBase { | 35 class PanelWindowResizerTest : public test::AshTestBase { |
| 35 public: | 36 public: |
| 36 PanelWindowResizerTest() {} | 37 PanelWindowResizerTest() {} |
| 37 virtual ~PanelWindowResizerTest() {} | 38 virtual ~PanelWindowResizerTest() {} |
| 38 | 39 |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 464 |
| 464 // Tests that panels can have transient children of different types. | 465 // Tests that panels can have transient children of different types. |
| 465 // The transient children should be reparented in sync with the panel. | 466 // The transient children should be reparented in sync with the panel. |
| 466 TEST_P(PanelWindowResizerTransientTest, PanelWithTransientChild) { | 467 TEST_P(PanelWindowResizerTransientTest, PanelWithTransientChild) { |
| 467 if (!SupportsHostWindowResize()) | 468 if (!SupportsHostWindowResize()) |
| 468 return; | 469 return; |
| 469 | 470 |
| 470 scoped_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 471 scoped_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
| 471 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithDelegateAndType( | 472 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithDelegateAndType( |
| 472 NULL, transient_window_type_, 0, gfx::Rect(20, 20, 150, 40))); | 473 NULL, transient_window_type_, 0, gfx::Rect(20, 20, 150, 40))); |
| 473 window->AddTransientChild(child.get()); | 474 views::corewm::AddTransientChild(window.get(), child.get()); |
| 474 if (window->parent() != child->parent()) | 475 if (window->parent() != child->parent()) |
| 475 window->parent()->AddChild(child.get()); | 476 window->parent()->AddChild(child.get()); |
| 476 EXPECT_EQ(window.get(), child->transient_parent()); | 477 EXPECT_EQ(window.get(), views::corewm::GetTransientParent(child.get())); |
| 477 | 478 |
| 478 // Drag the child to the shelf. Its new position should not be overridden. | 479 // Drag the child to the shelf. Its new position should not be overridden. |
| 479 const gfx::Rect attached_bounds(window->GetBoundsInScreen()); | 480 const gfx::Rect attached_bounds(window->GetBoundsInScreen()); |
| 480 const int dy = window->GetBoundsInScreen().bottom() - | 481 const int dy = window->GetBoundsInScreen().bottom() - |
| 481 child->GetBoundsInScreen().bottom(); | 482 child->GetBoundsInScreen().bottom(); |
| 482 DragStart(child.get()); | 483 DragStart(child.get()); |
| 483 DragMove(50, dy); | 484 DragMove(50, dy); |
| 484 // While moving the transient child window should be in the panel container. | 485 // While moving the transient child window should be in the panel container. |
| 485 EXPECT_EQ(internal::kShellWindowId_PanelContainer, child->parent()->id()); | 486 EXPECT_EQ(internal::kShellWindowId_PanelContainer, child->parent()->id()); |
| 486 DragEnd(); | 487 DragEnd(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, | 527 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, |
| 527 testing::Bool()); | 528 testing::Bool()); |
| 528 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, | 529 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, |
| 529 PanelWindowResizerTransientTest, | 530 PanelWindowResizerTransientTest, |
| 530 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 531 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 531 ui::wm::WINDOW_TYPE_PANEL, | 532 ui::wm::WINDOW_TYPE_PANEL, |
| 532 ui::wm::WINDOW_TYPE_POPUP)); | 533 ui::wm::WINDOW_TYPE_POPUP)); |
| 533 | 534 |
| 534 } // namespace internal | 535 } // namespace internal |
| 535 } // namespace ash | 536 } // namespace ash |
| OLD | NEW |