| 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 28 matching lines...) Expand all Loading... |
| 39 UpdateDisplay("600x400"); | 39 UpdateDisplay("600x400"); |
| 40 test::ShellTestApi test_api(Shell::GetInstance()); | 40 test::ShellTestApi test_api(Shell::GetInstance()); |
| 41 model_ = test_api.launcher_model(); | 41 model_ = test_api.launcher_model(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual void TearDown() OVERRIDE { | 44 virtual void TearDown() OVERRIDE { |
| 45 AshTestBase::TearDown(); | 45 AshTestBase::TearDown(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 gfx::Point CalculateDragPoint(const PanelWindowResizer& resizer, | 49 gfx::Point CalculateDragPoint(const WindowResizer& resizer, |
| 50 int delta_x, | 50 int delta_x, |
| 51 int delta_y) const { | 51 int delta_y) const { |
| 52 gfx::Point location = resizer.GetInitialLocationInParentForTest(); | 52 gfx::Point location = resizer.GetInitialLocation(); |
| 53 location.set_x(location.x() + delta_x); | 53 location.set_x(location.x() + delta_x); |
| 54 location.set_y(location.y() + delta_y); | 54 location.set_y(location.y() + delta_y); |
| 55 return location; | 55 return location; |
| 56 } | 56 } |
| 57 | 57 |
| 58 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { | 58 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { |
| 59 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 59 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
| 60 NULL, | 60 NULL, |
| 61 aura::client::WINDOW_TYPE_PANEL, | 61 aura::client::WINDOW_TYPE_PANEL, |
| 62 0, | 62 0, |
| 63 bounds); | 63 bounds); |
| 64 test::TestLauncherDelegate* launcher_delegate = | 64 test::TestLauncherDelegate* launcher_delegate = |
| 65 test::TestLauncherDelegate::instance(); | 65 test::TestLauncherDelegate::instance(); |
| 66 launcher_delegate->AddLauncherItem(window); | 66 launcher_delegate->AddLauncherItem(window); |
| 67 PanelLayoutManager* manager = | 67 PanelLayoutManager* manager = |
| 68 static_cast<PanelLayoutManager*>( | 68 static_cast<PanelLayoutManager*>( |
| 69 Shell::GetContainer(window->GetRootWindow(), | 69 Shell::GetContainer(window->GetRootWindow(), |
| 70 internal::kShellWindowId_PanelContainer)-> | 70 internal::kShellWindowId_PanelContainer)-> |
| 71 layout_manager()); | 71 layout_manager()); |
| 72 manager->Relayout(); | 72 manager->Relayout(); |
| 73 return window; | 73 return window; |
| 74 } | 74 } |
| 75 | 75 |
| 76 static PanelWindowResizer* CreatePanelWindowResizer( | 76 void DragStart(aura::Window* window) { |
| 77 aura::Window* window, | 77 resizer_.reset(CreateWindowResizer( |
| 78 const gfx::Point& point_in_parent, | 78 window, |
| 79 int window_component) { | 79 window->bounds().origin(), |
| 80 return static_cast<PanelWindowResizer*>(CreateWindowResizer( | 80 HTCAPTION, |
| 81 window, point_in_parent, window_component, | |
| 82 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release()); | 81 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release()); |
| 83 } | |
| 84 | |
| 85 void DragStart(aura::Window* window) { | |
| 86 resizer_.reset(CreatePanelWindowResizer(window, window->bounds().origin(), | |
| 87 HTCAPTION)); | |
| 88 ASSERT_TRUE(resizer_.get()); | 82 ASSERT_TRUE(resizer_.get()); |
| 89 } | 83 } |
| 90 | 84 |
| 91 void DragMove(int dx, int dy) { | 85 void DragMove(int dx, int dy) { |
| 92 resizer_->Drag(CalculateDragPoint(*resizer_, dx, dy), 0); | 86 resizer_->Drag(CalculateDragPoint(*resizer_, dx, dy), 0); |
| 93 } | 87 } |
| 94 | 88 |
| 95 void DragEnd() { | 89 void DragEnd() { |
| 96 resizer_->CompleteDrag(0); | 90 resizer_->CompleteDrag(0); |
| 97 resizer_.reset(); | 91 resizer_.reset(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 DragStart(w2.get()); | 176 DragStart(w2.get()); |
| 183 DragMove(-400 * dx, -400 * dy); | 177 DragMove(-400 * dx, -400 * dy); |
| 184 TestWindowOrder(window_order_original); | 178 TestWindowOrder(window_order_original); |
| 185 DragEnd(); | 179 DragEnd(); |
| 186 | 180 |
| 187 // Expect original order. | 181 // Expect original order. |
| 188 TestWindowOrder(window_order_original); | 182 TestWindowOrder(window_order_original); |
| 189 } | 183 } |
| 190 | 184 |
| 191 private: | 185 private: |
| 192 scoped_ptr<PanelWindowResizer> resizer_; | 186 scoped_ptr<WindowResizer> resizer_; |
| 193 internal::PanelLayoutManager* panel_layout_manager_; | 187 internal::PanelLayoutManager* panel_layout_manager_; |
| 194 LauncherModel* model_; | 188 LauncherModel* model_; |
| 195 | 189 |
| 196 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest); | 190 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest); |
| 197 }; | 191 }; |
| 198 | 192 |
| 199 class PanelWindowResizerTextDirectionTest | 193 class PanelWindowResizerTextDirectionTest |
| 200 : public PanelWindowResizerTest, | 194 : public PanelWindowResizerTest, |
| 201 public testing::WithParamInterface<bool> { | 195 public testing::WithParamInterface<bool> { |
| 202 public: | 196 public: |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 ash::Shell* shell = ash::Shell::GetInstance(); | 439 ash::Shell* shell = ash::Shell::GetInstance(); |
| 446 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow()); | 440 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow()); |
| 447 DragAlongShelfReorder(0, -1); | 441 DragAlongShelfReorder(0, -1); |
| 448 } | 442 } |
| 449 | 443 |
| 450 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, | 444 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, |
| 451 testing::Bool()); | 445 testing::Bool()); |
| 452 | 446 |
| 453 } // namespace internal | 447 } // namespace internal |
| 454 } // namespace ash | 448 } // namespace ash |
| OLD | NEW |