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

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

Issue 477823003: Clear restore bounds for user resize/drag actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 3 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') | no next file » | 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/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); 1174 window_->SetBounds(gfx::Rect(96, 112, 320, 160));
1175 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1175 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
1176 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); 1176 window_.get(), gfx::Point(), HTBOTTOMRIGHT));
1177 ASSERT_TRUE(resizer.get()); 1177 ASSERT_TRUE(resizer.get());
1178 // Resize the right bottom to add 10 in width, 12 in height. 1178 // Resize the right bottom to add 10 in width, 12 in height.
1179 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), ui::EF_CONTROL_DOWN); 1179 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), ui::EF_CONTROL_DOWN);
1180 // Both bottom and right sides to resize to exact size requested. 1180 // Both bottom and right sides to resize to exact size requested.
1181 EXPECT_EQ("96,112 330x172", window_->bounds().ToString()); 1181 EXPECT_EQ("96,112 330x172", window_->bounds().ToString());
1182 } 1182 }
1183 1183
1184 // Verifies that a dragged, non-snapped window will clear restore bounds.
1185 TEST_F(WorkspaceWindowResizerTest, RestoreClearedOnResize) {
1186 window_->SetBounds(gfx::Rect(10, 10, 100, 100));
1187 wm::WindowState* window_state = wm::GetWindowState(window_.get());
1188 window_state->SetRestoreBoundsInScreen(gfx::Rect(50, 50, 50, 50));
1189 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
1190 window_.get(), gfx::Point(), HTBOTTOMRIGHT));
1191 ASSERT_TRUE(resizer.get());
1192 // Drag the window to new position by adding (20, 30) to original point,
1193 // the original restore bound should be cleared.
1194 resizer->Drag(CalculateDragPoint(*resizer, 20, 30), 0);
1195 resizer->CompleteDrag();
1196 EXPECT_EQ("10,10 120x130", window_->bounds().ToString());
1197 EXPECT_FALSE(window_state->HasRestoreBounds());
1198 }
1199
1184 // Verifies that a dragged window will restore to its pre-maximized size. 1200 // Verifies that a dragged window will restore to its pre-maximized size.
1185 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { 1201 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) {
1186 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); 1202 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000));
1187 wm::WindowState* window_state = wm::GetWindowState(window_.get()); 1203 wm::WindowState* window_state = wm::GetWindowState(window_.get());
1188 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); 1204 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160));
1189 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1205 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
1190 window_.get(), gfx::Point(), HTCAPTION)); 1206 window_.get(), gfx::Point(), HTCAPTION));
1191 ASSERT_TRUE(resizer.get()); 1207 ASSERT_TRUE(resizer.get());
1192 // Drag the window to new position by adding (10, 10) to original point, 1208 // Drag the window to new position by adding (10, 10) to original point,
1193 // the window should get restored. 1209 // the window should get restored.
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 // Drag even more to snap to the edge. 1878 // Drag even more to snap to the edge.
1863 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1879 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1864 gfx::Point(400, kRootHeight - 25), 1880 gfx::Point(400, kRootHeight - 25),
1865 base::TimeDelta::FromMilliseconds(10), 1881 base::TimeDelta::FromMilliseconds(10),
1866 5); 1882 5);
1867 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1883 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1868 touch_resize_window_->bounds().ToString()); 1884 touch_resize_window_->bounds().ToString());
1869 } 1885 }
1870 1886
1871 } // namespace ash 1887 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698