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

Side by Side Diff: ash/wm/dock/docked_window_layout_manager_unittest.cc

Issue 115153002: wm: public window_types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ozone deps Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/dock/docked_window_layout_manager.cc ('k') | ash/wm/dock/docked_window_resizer.cc » ('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/dock/docked_window_layout_manager.h" 5 #include "ash/wm/dock/docked_window_layout_manager.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_ash.h" 10 #include "ash/screen_ash.h"
(...skipping 22 matching lines...) Expand all
33 #include "ui/aura/window.h" 33 #include "ui/aura/window.h"
34 #include "ui/base/hit_test.h" 34 #include "ui/base/hit_test.h"
35 #include "ui/gfx/screen.h" 35 #include "ui/gfx/screen.h"
36 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
37 37
38 namespace ash { 38 namespace ash {
39 namespace internal { 39 namespace internal {
40 40
41 class DockedWindowLayoutManagerTest 41 class DockedWindowLayoutManagerTest
42 : public test::AshTestBase, 42 : public test::AshTestBase,
43 public testing::WithParamInterface<aura::client::WindowType> { 43 public testing::WithParamInterface<ui::wm::WindowType> {
44 public: 44 public:
45 DockedWindowLayoutManagerTest() : window_type_(GetParam()) {} 45 DockedWindowLayoutManagerTest() : window_type_(GetParam()) {}
46 virtual ~DockedWindowLayoutManagerTest() {} 46 virtual ~DockedWindowLayoutManagerTest() {}
47 47
48 virtual void SetUp() OVERRIDE { 48 virtual void SetUp() OVERRIDE {
49 CommandLine::ForCurrentProcess()->AppendSwitch( 49 CommandLine::ForCurrentProcess()->AppendSwitch(
50 ash::switches::kAshEnableDockedWindows); 50 ash::switches::kAshEnableDockedWindows);
51 AshTestBase::SetUp(); 51 AshTestBase::SetUp();
52 UpdateDisplay("600x600"); 52 UpdateDisplay("600x600");
53 ASSERT_TRUE(test::TestShelfDelegate::instance()); 53 ASSERT_TRUE(test::TestShelfDelegate::instance());
(...skipping 12 matching lines...) Expand all
66 66
67 int min_dock_gap() const { return DockedWindowLayoutManager::kMinDockGap; } 67 int min_dock_gap() const { return DockedWindowLayoutManager::kMinDockGap; }
68 int ideal_width() const { return DockedWindowLayoutManager::kIdealWidth; } 68 int ideal_width() const { return DockedWindowLayoutManager::kIdealWidth; }
69 int docked_width(const DockedWindowLayoutManager* layout_manager) const { 69 int docked_width(const DockedWindowLayoutManager* layout_manager) const {
70 return layout_manager->docked_width_; 70 return layout_manager->docked_width_;
71 } 71 }
72 72
73 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 73 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
74 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( 74 aura::Window* window = CreateTestWindowInShellWithDelegateAndType(
75 NULL, window_type_, 0, bounds); 75 NULL, window_type_, 0, bounds);
76 if (window_type_ == aura::client::WINDOW_TYPE_PANEL) { 76 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) {
77 test::TestShelfDelegate* shelf_delegate = 77 test::TestShelfDelegate* shelf_delegate =
78 test::TestShelfDelegate::instance(); 78 test::TestShelfDelegate::instance();
79 shelf_delegate->AddLauncherItem(window); 79 shelf_delegate->AddLauncherItem(window);
80 PanelLayoutManager* manager = 80 PanelLayoutManager* manager =
81 static_cast<PanelLayoutManager*>(GetPanelContainer(window)-> 81 static_cast<PanelLayoutManager*>(GetPanelContainer(window)->
82 layout_manager()); 82 layout_manager());
83 manager->Relayout(); 83 manager->Relayout();
84 } 84 }
85 return window; 85 return window;
86 } 86 }
87 87
88 aura::Window* CreateTestWindowWithDelegate( 88 aura::Window* CreateTestWindowWithDelegate(
89 const gfx::Rect& bounds, 89 const gfx::Rect& bounds,
90 aura::test::TestWindowDelegate* delegate) { 90 aura::test::TestWindowDelegate* delegate) {
91 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( 91 aura::Window* window = CreateTestWindowInShellWithDelegateAndType(
92 delegate, window_type_, 0, bounds); 92 delegate, window_type_, 0, bounds);
93 if (window_type_ == aura::client::WINDOW_TYPE_PANEL) { 93 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) {
94 test::TestShelfDelegate* shelf_delegate = 94 test::TestShelfDelegate* shelf_delegate =
95 test::TestShelfDelegate::instance(); 95 test::TestShelfDelegate::instance();
96 shelf_delegate->AddLauncherItem(window); 96 shelf_delegate->AddLauncherItem(window);
97 PanelLayoutManager* manager = 97 PanelLayoutManager* manager =
98 static_cast<PanelLayoutManager*>(GetPanelContainer(window)-> 98 static_cast<PanelLayoutManager*>(GetPanelContainer(window)->
99 layout_manager()); 99 layout_manager());
100 manager->Relayout(); 100 manager->Relayout();
101 } 101 }
102 return window; 102 return window;
103 } 103 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 void DragRevert() { 144 void DragRevert() {
145 resizer_->RevertDrag(); 145 resizer_->RevertDrag();
146 resizer_.reset(); 146 resizer_.reset();
147 } 147 }
148 148
149 // Panels are parented by panel container during drags. 149 // Panels are parented by panel container during drags.
150 // Docked windows are parented by dock container during drags. 150 // Docked windows are parented by dock container during drags.
151 // All other windows that we are testing here have default container as a 151 // All other windows that we are testing here have default container as a
152 // parent. 152 // parent.
153 int CorrectContainerIdDuringDrag() { 153 int CorrectContainerIdDuringDrag() {
154 if (window_type_ == aura::client::WINDOW_TYPE_PANEL) 154 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL)
155 return internal::kShellWindowId_PanelContainer; 155 return internal::kShellWindowId_PanelContainer;
156 return internal::kShellWindowId_DockedContainer; 156 return internal::kShellWindowId_DockedContainer;
157 } 157 }
158 158
159 // Test dragging the window vertically (to detach if it is a panel) and then 159 // Test dragging the window vertically (to detach if it is a panel) and then
160 // horizontally to the edge with an added offset from the edge of |dx|. 160 // horizontally to the edge with an added offset from the edge of |dx|.
161 void DragRelativeToEdge(DockedEdge edge, 161 void DragRelativeToEdge(DockedEdge edge, aura::Window* window, int dx) {
162 aura::Window* window,
163 int dx) {
164 DragVerticallyAndRelativeToEdge( 162 DragVerticallyAndRelativeToEdge(
165 edge, 163 edge,
166 window, 164 window,
167 dx, 165 dx,
168 window_type_ == aura::client::WINDOW_TYPE_PANEL ? -100 : 20); 166 window_type_ == ui::wm::WINDOW_TYPE_PANEL ? -100 : 20);
169 } 167 }
170 168
171 void DragToVerticalPositionAndToEdge(DockedEdge edge, 169 void DragToVerticalPositionAndToEdge(DockedEdge edge,
172 aura::Window* window, 170 aura::Window* window,
173 int y) { 171 int y) {
174 DragToVerticalPositionRelativeToEdge(edge, window, 0, y); 172 DragToVerticalPositionRelativeToEdge(edge, window, 0, y);
175 } 173 }
176 174
177 void DragToVerticalPositionRelativeToEdge(DockedEdge edge, 175 void DragToVerticalPositionRelativeToEdge(DockedEdge edge,
178 aura::Window* window, 176 aura::Window* window,
(...skipping 30 matching lines...) Expand all
209 // y-coordinate could be changed by possible automatic layout if docked. 207 // y-coordinate could be changed by possible automatic layout if docked.
210 if (window->parent()->id() != internal::kShellWindowId_DockedContainer && 208 if (window->parent()->id() != internal::kShellWindowId_DockedContainer &&
211 !wm::GetWindowState(window)->HasRestoreBounds()) { 209 !wm::GetWindowState(window)->HasRestoreBounds()) {
212 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); 210 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
213 } 211 }
214 } 212 }
215 213
216 private: 214 private:
217 scoped_ptr<WindowResizer> resizer_; 215 scoped_ptr<WindowResizer> resizer_;
218 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; 216 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_;
219 aura::client::WindowType window_type_; 217 ui::wm::WindowType window_type_;
220 218
221 // Location at start of the drag in |window->parent()|'s coordinates. 219 // Location at start of the drag in |window->parent()|'s coordinates.
222 gfx::Point initial_location_in_parent_; 220 gfx::Point initial_location_in_parent_;
223 221
224 DISALLOW_COPY_AND_ASSIGN(DockedWindowLayoutManagerTest); 222 DISALLOW_COPY_AND_ASSIGN(DockedWindowLayoutManagerTest);
225 }; 223 };
226 224
227 // Tests that a created window is successfully added to the dock 225 // Tests that a created window is successfully added to the dock
228 // layout manager. 226 // layout manager.
229 TEST_P(DockedWindowLayoutManagerTest, AddOneWindow) { 227 TEST_P(DockedWindowLayoutManagerTest, AddOneWindow) {
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 // w2 should be less than half of the work area height (even with a margin). 804 // w2 should be less than half of the work area height (even with a margin).
807 gfx::Rect work_area = 805 gfx::Rect work_area =
808 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); 806 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area();
809 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10); 807 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10);
810 EXPECT_LT(w2->GetBoundsInScreen().height(), work_area.height() / 2 - 10); 808 EXPECT_LT(w2->GetBoundsInScreen().height(), work_area.height() / 2 - 10);
811 } 809 }
812 810
813 // Tests run twice - on both panels and normal windows 811 // Tests run twice - on both panels and normal windows
814 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 812 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
815 DockedWindowLayoutManagerTest, 813 DockedWindowLayoutManagerTest,
816 testing::Values(aura::client::WINDOW_TYPE_NORMAL, 814 testing::Values(ui::wm::WINDOW_TYPE_NORMAL,
817 aura::client::WINDOW_TYPE_PANEL)); 815 ui::wm::WINDOW_TYPE_PANEL));
818 } // namespace internal 816 } // namespace internal
819 } // namespace ash 817 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_layout_manager.cc ('k') | ash/wm/dock/docked_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698