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

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

Issue 2897993003: chromeos: converts WindowResizer to aura::Window (Closed)
Patch Set: remove include from exo Created 3 years, 7 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/workspace/workspace_window_resizer.cc ('k') | ash/wm/workspace_controller_unittest.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) 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/wm/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include "ash/public/cpp/config.h" 7 #include "ash/public/cpp/config.h"
8 #include "ash/public/cpp/shell_window_ids.h" 8 #include "ash/public/cpp/shell_window_ids.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shelf/shelf_constants.h" 10 #include "ash/shelf/shelf_constants.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 } 130 }
131 return result; 131 return result;
132 } 132 }
133 133
134 protected: 134 protected:
135 WindowResizer* CreateResizerForTest(aura::Window* window, 135 WindowResizer* CreateResizerForTest(aura::Window* window,
136 const gfx::Point& point_in_parent, 136 const gfx::Point& point_in_parent,
137 int window_component) { 137 int window_component) {
138 WindowResizer* resizer = 138 WindowResizer* resizer =
139 CreateWindowResizer(WmWindow::Get(window), point_in_parent, 139 CreateWindowResizer(window, point_in_parent, window_component,
140 window_component,
141 aura::client::WINDOW_MOVE_SOURCE_MOUSE) 140 aura::client::WINDOW_MOVE_SOURCE_MOUSE)
142 .release(); 141 .release();
143 workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest(); 142 workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest();
144 return resizer; 143 return resizer;
145 } 144 }
146 WorkspaceWindowResizer* CreateWorkspaceResizerForTest( 145 WorkspaceWindowResizer* CreateWorkspaceResizerForTest(
147 aura::Window* window, 146 aura::Window* window,
148 const gfx::Point& point_in_parent, 147 const gfx::Point& point_in_parent,
149 int window_component, 148 int window_component,
150 aura::client::WindowMoveSource source, 149 aura::client::WindowMoveSource source,
151 const std::vector<aura::Window*>& attached_windows) { 150 const std::vector<aura::Window*>& attached_windows) {
152 wm::WindowState* window_state = wm::GetWindowState(window); 151 wm::WindowState* window_state = wm::GetWindowState(window);
153 window_state->CreateDragDetails(point_in_parent, window_component, source); 152 window_state->CreateDragDetails(point_in_parent, window_component, source);
154 return WorkspaceWindowResizer::Create( 153 return WorkspaceWindowResizer::Create(window_state, attached_windows);
155 window_state, WmWindow::FromAuraWindows(attached_windows));
156 } 154 }
157 155
158 PhantomWindowController* snap_phantom_window_controller() const { 156 PhantomWindowController* snap_phantom_window_controller() const {
159 return workspace_resizer_->snap_phantom_window_controller_.get(); 157 return workspace_resizer_->snap_phantom_window_controller_.get();
160 } 158 }
161 159
162 gfx::Point CalculateDragPoint(const WindowResizer& resizer, 160 gfx::Point CalculateDragPoint(const WindowResizer& resizer,
163 int delta_x, 161 int delta_x,
164 int delta_y) const { 162 int delta_y) const {
165 gfx::Point location = resizer.GetInitialLocation(); 163 gfx::Point location = resizer.GetInitialLocation();
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 // TODO(varkha): Insets are reset after every drag because of 540 // TODO(varkha): Insets are reset after every drag because of
543 // http://crbug.com/292238. 541 // http://crbug.com/292238.
544 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); 542 window_->SetBounds(gfx::Rect(20, 30, 400, 60));
545 window_->SetProperty(aura::client::kResizeBehaviorKey, 543 window_->SetProperty(aura::client::kResizeBehaviorKey,
546 ui::mojom::kResizeBehaviorCanResize | 544 ui::mojom::kResizeBehaviorCanResize |
547 ui::mojom::kResizeBehaviorCanMaximize); 545 ui::mojom::kResizeBehaviorCanMaximize);
548 wm::WindowState* window_state = wm::GetWindowState(window_.get()); 546 wm::WindowState* window_state = wm::GetWindowState(window_.get());
549 547
550 { 548 {
551 gfx::Rect expected_bounds_in_parent( 549 gfx::Rect expected_bounds_in_parent(
552 wm::GetDefaultLeftSnappedWindowBoundsInParent( 550 wm::GetDefaultLeftSnappedWindowBoundsInParent(window_.get()));
553 WmWindow::Get(window_.get())));
554 551
555 std::unique_ptr<WindowResizer> resizer( 552 std::unique_ptr<WindowResizer> resizer(
556 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 553 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
557 ASSERT_TRUE(resizer.get()); 554 ASSERT_TRUE(resizer.get());
558 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); 555 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0);
559 resizer->CompleteDrag(); 556 resizer->CompleteDrag();
560 557
561 EXPECT_EQ(expected_bounds_in_parent.ToString(), 558 EXPECT_EQ(expected_bounds_in_parent.ToString(),
562 window_->bounds().ToString()); 559 window_->bounds().ToString());
563 ASSERT_TRUE(window_state->HasRestoreBounds()); 560 ASSERT_TRUE(window_state->HasRestoreBounds());
564 EXPECT_EQ("20,30 400x60", 561 EXPECT_EQ("20,30 400x60",
565 window_state->GetRestoreBoundsInScreen().ToString()); 562 window_state->GetRestoreBoundsInScreen().ToString());
566 } 563 }
567 // Try the same with the right side. 564 // Try the same with the right side.
568 { 565 {
569 gfx::Rect expected_bounds_in_parent( 566 gfx::Rect expected_bounds_in_parent(
570 wm::GetDefaultRightSnappedWindowBoundsInParent( 567 wm::GetDefaultRightSnappedWindowBoundsInParent(window_.get()));
571 WmWindow::Get(window_.get())));
572 568
573 std::unique_ptr<WindowResizer> resizer( 569 std::unique_ptr<WindowResizer> resizer(
574 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 570 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
575 ASSERT_TRUE(resizer.get()); 571 ASSERT_TRUE(resizer.get());
576 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 572 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
577 resizer->CompleteDrag(); 573 resizer->CompleteDrag();
578 EXPECT_EQ(expected_bounds_in_parent.ToString(), 574 EXPECT_EQ(expected_bounds_in_parent.ToString(),
579 window_->bounds().ToString()); 575 window_->bounds().ToString());
580 ASSERT_TRUE(window_state->HasRestoreBounds()); 576 ASSERT_TRUE(window_state->HasRestoreBounds());
581 EXPECT_EQ("20,30 400x60", 577 EXPECT_EQ("20,30 400x60",
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 touch_resize_window_->bounds().ToString()); 1850 touch_resize_window_->bounds().ToString());
1855 // Drag even more to snap to the edge. 1851 // Drag even more to snap to the edge.
1856 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1852 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1857 gfx::Point(400, kRootHeight - 25), 1853 gfx::Point(400, kRootHeight - 25),
1858 base::TimeDelta::FromMilliseconds(10), 5); 1854 base::TimeDelta::FromMilliseconds(10), 5);
1859 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1855 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1860 touch_resize_window_->bounds().ToString()); 1856 touch_resize_window_->bounds().ToString());
1861 } 1857 }
1862 1858
1863 } // namespace ash 1859 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.cc ('k') | ash/wm/workspace_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698