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

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

Issue 2629643002: chromeos: Renames WmWindowAura to WmWindow (Closed)
Patch Set: unnecessary casts Created 3 years, 11 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/common/wm/dock/docked_window_layout_manager.h" 5 #include "ash/common/wm/dock/docked_window_layout_manager.h"
6 6
7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
9 #include "ash/common/shelf/wm_shelf.h" 8 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/test/test_shelf_delegate.h" 9 #include "ash/common/test/test_shelf_delegate.h"
11 #include "ash/common/wm/panels/panel_layout_manager.h" 10 #include "ash/common/wm/panels/panel_layout_manager.h"
12 #include "ash/common/wm/window_resizer.h" 11 #include "ash/common/wm/window_resizer.h"
13 #include "ash/common/wm/window_state.h" 12 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm_window.h"
14 #include "ash/public/cpp/shell_window_ids.h" 14 #include "ash/public/cpp/shell_window_ids.h"
15 #include "ash/root_window_controller.h" 15 #include "ash/root_window_controller.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/test/ash_test_base.h" 17 #include "ash/test/ash_test_base.h"
18 #include "ash/test/shelf_view_test_api.h" 18 #include "ash/test/shelf_view_test_api.h"
19 #include "ash/test/shell_test_api.h" 19 #include "ash/test/shell_test_api.h"
20 #include "ash/wm/window_state_aura.h" 20 #include "ash/wm/window_state_aura.h"
21 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
22 #include "base/command_line.h" 22 #include "base/command_line.h"
23 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 70 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
71 return CreateTestWindowWithDelegate(bounds, nullptr); 71 return CreateTestWindowWithDelegate(bounds, nullptr);
72 } 72 }
73 73
74 aura::Window* CreateTestWindowWithDelegate( 74 aura::Window* CreateTestWindowWithDelegate(
75 const gfx::Rect& bounds, 75 const gfx::Rect& bounds,
76 aura::test::TestWindowDelegate* delegate) { 76 aura::test::TestWindowDelegate* delegate) {
77 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( 77 aura::Window* window = CreateTestWindowInShellWithDelegateAndType(
78 delegate, window_type_, 0, bounds); 78 delegate, window_type_, 0, bounds);
79 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) { 79 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) {
80 WmWindow* wm_window = WmWindowAura::Get(window); 80 WmWindow* wm_window = WmWindow::Get(window);
81 test::TestShelfDelegate::instance()->AddShelfItem(wm_window); 81 test::TestShelfDelegate::instance()->AddShelfItem(wm_window);
82 PanelLayoutManager::Get(wm_window)->Relayout(); 82 PanelLayoutManager::Get(wm_window)->Relayout();
83 } 83 }
84 return window; 84 return window;
85 } 85 }
86 86
87 static WindowResizer* CreateSomeWindowResizer( 87 static WindowResizer* CreateSomeWindowResizer(
88 aura::Window* window, 88 aura::Window* window,
89 const gfx::Point& point_in_parent, 89 const gfx::Point& point_in_parent,
90 int window_component) { 90 int window_component) {
91 return CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, 91 return CreateWindowResizer(WmWindow::Get(window), point_in_parent,
92 window_component, 92 window_component,
93 aura::client::WINDOW_MOVE_SOURCE_MOUSE) 93 aura::client::WINDOW_MOVE_SOURCE_MOUSE)
94 .release(); 94 .release();
95 } 95 }
96 96
97 void DragStart(aura::Window* window) { 97 void DragStart(aura::Window* window) {
98 DragStartAtOffsetFromwindowOrigin(window, 0, 0); 98 DragStartAtOffsetFromwindowOrigin(window, 0, 0);
99 } 99 }
100 100
101 void DragStartAtOffsetFromwindowOrigin(aura::Window* window, int dx, int dy) { 101 void DragStartAtOffsetFromwindowOrigin(aura::Window* window, int dx, int dy) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 gfx::Rect bounds(0, 0, 201, 201); 231 gfx::Rect bounds(0, 0, 201, 201);
232 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); 232 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds));
233 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); 233 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0);
234 234
235 // The window should be attached and snapped to the right side of the screen. 235 // The window should be attached and snapped to the right side of the screen.
236 EXPECT_EQ(window->GetRootWindow()->bounds().x(), 236 EXPECT_EQ(window->GetRootWindow()->bounds().x(),
237 window->GetBoundsInScreen().x()); 237 window->GetBoundsInScreen().x());
238 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); 238 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
239 239
240 DockedWindowLayoutManager* manager = 240 DockedWindowLayoutManager* manager =
241 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); 241 DockedWindowLayoutManager::Get(WmWindow::Get(window.get()));
242 242
243 // Create two additional windows and test their auto-placement 243 // Create two additional windows and test their auto-placement
244 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); 244 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1));
245 gfx::Rect desktop_area = window1->parent()->bounds(); 245 gfx::Rect desktop_area = window1->parent()->bounds();
246 wm::GetWindowState(window1.get())->set_window_position_managed(true); 246 wm::GetWindowState(window1.get())->set_window_position_managed(true);
247 window1->Hide(); 247 window1->Hide();
248 window1->SetBounds(gfx::Rect(250, 32, 231, 320)); 248 window1->SetBounds(gfx::Rect(250, 32, 231, 320));
249 window1->Show(); 249 window1->Show();
250 // |window1| should be centered in work area. 250 // |window1| should be centered in work area.
251 EXPECT_EQ(base::IntToString(docked_width(manager) + min_dock_gap() + 251 EXPECT_EQ(base::IntToString(docked_width(manager) + min_dock_gap() +
(...skipping 27 matching lines...) Expand all
279 gfx::Rect bounds(0, 0, 201, 201); 279 gfx::Rect bounds(0, 0, 201, 201);
280 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); 280 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds));
281 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 281 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
282 282
283 // The window should be attached and snapped to the right side of the screen. 283 // The window should be attached and snapped to the right side of the screen.
284 EXPECT_EQ(window->GetRootWindow()->bounds().right(), 284 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
285 window->GetBoundsInScreen().right()); 285 window->GetBoundsInScreen().right());
286 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); 286 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
287 287
288 DockedWindowLayoutManager* manager = 288 DockedWindowLayoutManager* manager =
289 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); 289 DockedWindowLayoutManager::Get(WmWindow::Get(window.get()));
290 290
291 // Create two additional windows and test their auto-placement 291 // Create two additional windows and test their auto-placement
292 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); 292 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1));
293 gfx::Rect desktop_area = window1->parent()->bounds(); 293 gfx::Rect desktop_area = window1->parent()->bounds();
294 wm::GetWindowState(window1.get())->set_window_position_managed(true); 294 wm::GetWindowState(window1.get())->set_window_position_managed(true);
295 window1->Hide(); 295 window1->Hide();
296 window1->SetBounds(gfx::Rect(16, 32, 231, 320)); 296 window1->SetBounds(gfx::Rect(16, 32, 231, 320));
297 window1->Show(); 297 window1->Show();
298 298
299 // |window1| should be centered in work area. 299 // |window1| should be centered in work area.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); 333 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds));
334 // Drag pointer to the right edge of the second screen. 334 // Drag pointer to the right edge of the second screen.
335 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 335 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
336 336
337 // The window should be attached and snapped to the right side of the screen. 337 // The window should be attached and snapped to the right side of the screen.
338 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 338 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
339 window->GetBoundsInScreen().right()); 339 window->GetBoundsInScreen().right());
340 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); 340 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
341 341
342 DockedWindowLayoutManager* manager = 342 DockedWindowLayoutManager* manager =
343 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); 343 DockedWindowLayoutManager::Get(WmWindow::Get(window.get()));
344 344
345 // Create two additional windows and test their auto-placement 345 // Create two additional windows and test their auto-placement
346 bounds = gfx::Rect(616, 32, 231, 320); 346 bounds = gfx::Rect(616, 32, 231, 320);
347 std::unique_ptr<aura::Window> window1( 347 std::unique_ptr<aura::Window> window1(
348 CreateTestWindowInShellWithDelegate(nullptr, 1, bounds)); 348 CreateTestWindowInShellWithDelegate(nullptr, 1, bounds));
349 gfx::Rect desktop_area = window1->parent()->bounds(); 349 gfx::Rect desktop_area = window1->parent()->bounds();
350 wm::GetWindowState(window1.get())->set_window_position_managed(true); 350 wm::GetWindowState(window1.get())->set_window_position_managed(true);
351 window1->Hide(); 351 window1->Hide();
352 window1->Show(); 352 window1->Show();
353 353
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); 802 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height());
803 } 803 }
804 804
805 // Tests run twice - on both panels and normal windows 805 // Tests run twice - on both panels and normal windows
806 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 806 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
807 DockedWindowLayoutManagerTest, 807 DockedWindowLayoutManagerTest,
808 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, 808 testing::Values(ui::wm::WINDOW_TYPE_NORMAL,
809 ui::wm::WINDOW_TYPE_PANEL)); 809 ui::wm::WINDOW_TYPE_PANEL));
810 810
811 } // namespace ash 811 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698