Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: ash/wm/panels/panel_window_resizer_unittest.cc

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock with zero width (comments on unit tests) Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.GetInitialLocationForTest();
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(
77 aura::Window* window,
78 const gfx::Point& point_in_parent,
79 int window_component) {
80 return static_cast<PanelWindowResizer*>(CreateWindowResizer(
81 window, point_in_parent, window_component).release());
82 }
83
84 void DragStart(aura::Window* window) { 76 void DragStart(aura::Window* window) {
85 resizer_.reset(CreatePanelWindowResizer(window, window->bounds().origin(), 77 resizer_.reset(CreateWindowResizer(window,
86 HTCAPTION)); 78 window->bounds().origin(),
79 HTCAPTION).release());
87 ASSERT_TRUE(resizer_.get()); 80 ASSERT_TRUE(resizer_.get());
88 } 81 }
89 82
90 void DragMove(int dx, int dy) { 83 void DragMove(int dx, int dy) {
91 resizer_->Drag(CalculateDragPoint(*resizer_, dx, dy), 0); 84 resizer_->Drag(CalculateDragPoint(*resizer_, dx, dy), 0);
92 } 85 }
93 86
94 void DragEnd() { 87 void DragEnd() {
95 resizer_->CompleteDrag(0); 88 resizer_->CompleteDrag(0);
96 resizer_.reset(); 89 resizer_.reset();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 DragStart(w2.get()); 174 DragStart(w2.get());
182 DragMove(-400 * dx, -400 * dy); 175 DragMove(-400 * dx, -400 * dy);
183 TestWindowOrder(window_order_original); 176 TestWindowOrder(window_order_original);
184 DragEnd(); 177 DragEnd();
185 178
186 // Expect original order. 179 // Expect original order.
187 TestWindowOrder(window_order_original); 180 TestWindowOrder(window_order_original);
188 } 181 }
189 182
190 private: 183 private:
191 scoped_ptr<PanelWindowResizer> resizer_; 184 scoped_ptr<WindowResizer> resizer_;
192 internal::PanelLayoutManager* panel_layout_manager_; 185 internal::PanelLayoutManager* panel_layout_manager_;
193 LauncherModel* model_; 186 LauncherModel* model_;
194 187
195 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest); 188 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest);
196 }; 189 };
197 190
198 class PanelWindowResizerTextDirectionTest 191 class PanelWindowResizerTextDirectionTest
199 : public PanelWindowResizerTest, 192 : public PanelWindowResizerTest,
200 public testing::WithParamInterface<bool> { 193 public testing::WithParamInterface<bool> {
201 public: 194 public:
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 ash::Shell* shell = ash::Shell::GetInstance(); 437 ash::Shell* shell = ash::Shell::GetInstance();
445 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow()); 438 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow());
446 DragAlongShelfReorder(0, -1); 439 DragAlongShelfReorder(0, -1);
447 } 440 }
448 441
449 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, 442 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest,
450 testing::Bool()); 443 testing::Bool());
451 444
452 } // namespace internal 445 } // namespace internal
453 } // namespace ash 446 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698