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

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 (rebase) 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
« no previous file with comments | « ash/wm/panels/panel_window_resizer.cc ('k') | ash/wm/window_resizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.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
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
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
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_window_resizer.cc ('k') | ash/wm/window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698