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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 2629643002: chromeos: Renames WmWindowAura to WmWindow (Closed)
Patch Set: feedback 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/workspace/workspace_window_resizer.h" 5 #include "ash/common/wm/workspace/workspace_window_resizer.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/shelf_constants.h" 8 #include "ash/common/shelf/shelf_constants.h"
10 #include "ash/common/shelf/wm_shelf.h" 9 #include "ash/common/shelf/wm_shelf.h"
11 #include "ash/common/wm/window_positioning_utils.h" 10 #include "ash/common/wm/window_positioning_utils.h"
12 #include "ash/common/wm/window_state.h" 11 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm/wm_event.h" 12 #include "ash/common/wm/wm_event.h"
14 #include "ash/common/wm/workspace/phantom_window_controller.h" 13 #include "ash/common/wm/workspace/phantom_window_controller.h"
15 #include "ash/common/wm/workspace_controller.h" 14 #include "ash/common/wm/workspace_controller.h"
15 #include "ash/common/wm_window.h"
16 #include "ash/public/cpp/shell_window_ids.h" 16 #include "ash/public/cpp/shell_window_ids.h"
17 #include "ash/screen_util.h" 17 #include "ash/screen_util.h"
18 #include "ash/shell.h" 18 #include "ash/shell.h"
19 #include "ash/test/ash_md_test_base.h" 19 #include "ash/test/ash_md_test_base.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"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" 25 #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 } 131 }
132 return result; 132 return result;
133 } 133 }
134 134
135 protected: 135 protected:
136 WindowResizer* CreateResizerForTest(aura::Window* window, 136 WindowResizer* CreateResizerForTest(aura::Window* window,
137 const gfx::Point& point_in_parent, 137 const gfx::Point& point_in_parent,
138 int window_component) { 138 int window_component) {
139 WindowResizer* resizer = 139 WindowResizer* resizer =
140 CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, 140 CreateWindowResizer(WmWindow::Get(window), point_in_parent,
141 window_component, 141 window_component,
142 aura::client::WINDOW_MOVE_SOURCE_MOUSE) 142 aura::client::WINDOW_MOVE_SOURCE_MOUSE)
143 .release(); 143 .release();
144 workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest(); 144 workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest();
145 return resizer; 145 return resizer;
146 } 146 }
147 WorkspaceWindowResizer* CreateWorkspaceResizerForTest( 147 WorkspaceWindowResizer* CreateWorkspaceResizerForTest(
148 aura::Window* window, 148 aura::Window* window,
149 const gfx::Point& point_in_parent, 149 const gfx::Point& point_in_parent,
150 int window_component, 150 int window_component,
151 aura::client::WindowMoveSource source, 151 aura::client::WindowMoveSource source,
152 const std::vector<aura::Window*>& attached_windows) { 152 const std::vector<aura::Window*>& attached_windows) {
153 wm::WindowState* window_state = wm::GetWindowState(window); 153 wm::WindowState* window_state = wm::GetWindowState(window);
154 window_state->CreateDragDetails(point_in_parent, window_component, source); 154 window_state->CreateDragDetails(point_in_parent, window_component, source);
155 return WorkspaceWindowResizer::Create( 155 return WorkspaceWindowResizer::Create(
156 window_state, WmWindowAura::FromAuraWindows(attached_windows)); 156 window_state, WmWindow::FromAuraWindows(attached_windows));
157 } 157 }
158 158
159 PhantomWindowController* snap_phantom_window_controller() const { 159 PhantomWindowController* snap_phantom_window_controller() const {
160 return workspace_resizer_->snap_phantom_window_controller_.get(); 160 return workspace_resizer_->snap_phantom_window_controller_.get();
161 } 161 }
162 162
163 gfx::Point CalculateDragPoint(const WindowResizer& resizer, 163 gfx::Point CalculateDragPoint(const WindowResizer& resizer,
164 int delta_x, 164 int delta_x,
165 int delta_y) const { 165 int delta_y) const {
166 gfx::Point location = resizer.GetInitialLocation(); 166 gfx::Point location = resizer.GetInitialLocation();
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // Window is wide enough not to get docked right away. 547 // Window is wide enough not to get docked right away.
548 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); 548 window_->SetBounds(gfx::Rect(20, 30, 400, 60));
549 window_->SetProperty(aura::client::kResizeBehaviorKey, 549 window_->SetProperty(aura::client::kResizeBehaviorKey,
550 ui::mojom::kResizeBehaviorCanResize | 550 ui::mojom::kResizeBehaviorCanResize |
551 ui::mojom::kResizeBehaviorCanMaximize); 551 ui::mojom::kResizeBehaviorCanMaximize);
552 wm::WindowState* window_state = wm::GetWindowState(window_.get()); 552 wm::WindowState* window_state = wm::GetWindowState(window_.get());
553 553
554 { 554 {
555 gfx::Rect expected_bounds_in_parent( 555 gfx::Rect expected_bounds_in_parent(
556 wm::GetDefaultLeftSnappedWindowBoundsInParent( 556 wm::GetDefaultLeftSnappedWindowBoundsInParent(
557 WmWindowAura::Get(window_.get()))); 557 WmWindow::Get(window_.get())));
558 558
559 std::unique_ptr<WindowResizer> resizer( 559 std::unique_ptr<WindowResizer> resizer(
560 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 560 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
561 ASSERT_TRUE(resizer.get()); 561 ASSERT_TRUE(resizer.get());
562 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); 562 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0);
563 resizer->CompleteDrag(); 563 resizer->CompleteDrag();
564 564
565 EXPECT_EQ(expected_bounds_in_parent.ToString(), 565 EXPECT_EQ(expected_bounds_in_parent.ToString(),
566 window_->bounds().ToString()); 566 window_->bounds().ToString());
567 ASSERT_TRUE(window_state->HasRestoreBounds()); 567 ASSERT_TRUE(window_state->HasRestoreBounds());
568 EXPECT_EQ("20,30 400x60", 568 EXPECT_EQ("20,30 400x60",
569 window_state->GetRestoreBoundsInScreen().ToString()); 569 window_state->GetRestoreBoundsInScreen().ToString());
570 } 570 }
571 // Try the same with the right side. 571 // Try the same with the right side.
572 { 572 {
573 gfx::Rect expected_bounds_in_parent( 573 gfx::Rect expected_bounds_in_parent(
574 wm::GetDefaultRightSnappedWindowBoundsInParent( 574 wm::GetDefaultRightSnappedWindowBoundsInParent(
575 WmWindowAura::Get(window_.get()))); 575 WmWindow::Get(window_.get())));
576 576
577 std::unique_ptr<WindowResizer> resizer( 577 std::unique_ptr<WindowResizer> resizer(
578 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 578 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
579 ASSERT_TRUE(resizer.get()); 579 ASSERT_TRUE(resizer.get());
580 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 580 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
581 resizer->CompleteDrag(); 581 resizer->CompleteDrag();
582 EXPECT_EQ(expected_bounds_in_parent.ToString(), 582 EXPECT_EQ(expected_bounds_in_parent.ToString(),
583 window_->bounds().ToString()); 583 window_->bounds().ToString());
584 ASSERT_TRUE(window_state->HasRestoreBounds()); 584 ASSERT_TRUE(window_state->HasRestoreBounds());
585 EXPECT_EQ("20,30 400x60", 585 EXPECT_EQ("20,30 400x60",
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 touch_resize_window_->bounds().ToString()); 1894 touch_resize_window_->bounds().ToString());
1895 // Drag even more to snap to the edge. 1895 // Drag even more to snap to the edge.
1896 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1896 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1897 gfx::Point(400, kRootHeight - 25), 1897 gfx::Point(400, kRootHeight - 25),
1898 base::TimeDelta::FromMilliseconds(10), 5); 1898 base::TimeDelta::FromMilliseconds(10), 5);
1899 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1899 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1900 touch_resize_window_->bounds().ToString()); 1900 touch_resize_window_->bounds().ToString());
1901 } 1901 }
1902 1902
1903 } // namespace ash 1903 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager_unittest.cc ('k') | ash/wm/workspace_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698