OLD | NEW |
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/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
8 #include "ash/common/shelf/shelf_constants.h" | 8 #include "ash/common/shelf/shelf_constants.h" |
9 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
10 #include "ash/common/wm/window_positioning_utils.h" | 10 #include "ash/common/wm/window_positioning_utils.h" |
11 #include "ash/common/wm/window_state.h" | 11 #include "ash/common/wm/window_state.h" |
12 #include "ash/common/wm/wm_event.h" | 12 #include "ash/common/wm/wm_event.h" |
13 #include "ash/common/wm/workspace/phantom_window_controller.h" | 13 #include "ash/common/wm/workspace/phantom_window_controller.h" |
14 #include "ash/common/wm/workspace_controller.h" | 14 #include "ash/common/wm/workspace_controller.h" |
15 #include "ash/common/wm_window.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_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" |
26 #include "ui/aura/client/aura_constants.h" | 26 #include "ui/aura/client/aura_constants.h" |
27 #include "ui/aura/test/test_window_delegate.h" | 27 #include "ui/aura/test/test_window_delegate.h" |
28 #include "ui/aura/window_event_dispatcher.h" | 28 #include "ui/aura/window_event_dispatcher.h" |
29 #include "ui/base/hit_test.h" | 29 #include "ui/base/hit_test.h" |
(...skipping 28 matching lines...) Expand all Loading... |
58 gfx::Size GetMaximumSize() const override { return max_size_; } | 58 gfx::Size GetMaximumSize() const override { return max_size_; } |
59 | 59 |
60 gfx::Size min_size_; | 60 gfx::Size min_size_; |
61 gfx::Size max_size_; | 61 gfx::Size max_size_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate); | 63 DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate); |
64 }; | 64 }; |
65 | 65 |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 class WorkspaceWindowResizerTest : public test::AshMDTestBase { | 68 class WorkspaceWindowResizerTest : public test::AshTestBase { |
69 public: | 69 public: |
70 WorkspaceWindowResizerTest() : workspace_resizer_(nullptr) {} | 70 WorkspaceWindowResizerTest() : workspace_resizer_(nullptr) {} |
71 ~WorkspaceWindowResizerTest() override {} | 71 ~WorkspaceWindowResizerTest() override {} |
72 | 72 |
73 void SetUp() override { | 73 void SetUp() override { |
74 AshMDTestBase::SetUp(); | 74 AshTestBase::SetUp(); |
75 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight)); | 75 UpdateDisplay(base::StringPrintf("800x%d", kRootHeight)); |
76 // Ignore the touch slop region. | 76 // Ignore the touch slop region. |
77 ui::GestureConfiguration::GetInstance() | 77 ui::GestureConfiguration::GetInstance() |
78 ->set_max_touch_move_in_pixels_for_click(0); | 78 ->set_max_touch_move_in_pixels_for_click(0); |
79 | 79 |
80 aura::Window* root = Shell::GetPrimaryRootWindow(); | 80 aura::Window* root = Shell::GetPrimaryRootWindow(); |
81 gfx::Rect root_bounds(root->bounds()); | 81 gfx::Rect root_bounds(root->bounds()); |
82 EXPECT_EQ(800, root_bounds.width()); | 82 EXPECT_EQ(800, root_bounds.width()); |
83 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 83 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
84 window_.reset(new aura::Window(&delegate_)); | 84 window_.reset(new aura::Window(&delegate_)); |
(...skipping 20 matching lines...) Expand all Loading... |
105 ParentWindowInPrimaryRootWindow(window4_.get()); | 105 ParentWindowInPrimaryRootWindow(window4_.get()); |
106 window4_->set_id(4); | 106 window4_->set_id(4); |
107 } | 107 } |
108 | 108 |
109 void TearDown() override { | 109 void TearDown() override { |
110 window_.reset(); | 110 window_.reset(); |
111 window2_.reset(); | 111 window2_.reset(); |
112 window3_.reset(); | 112 window3_.reset(); |
113 window4_.reset(); | 113 window4_.reset(); |
114 touch_resize_window_.reset(); | 114 touch_resize_window_.reset(); |
115 AshMDTestBase::TearDown(); | 115 AshTestBase::TearDown(); |
116 } | 116 } |
117 | 117 |
118 // Returns a string identifying the z-order of each of the known child windows | 118 // Returns a string identifying the z-order of each of the known child windows |
119 // of |parent|. The returned string constains the id of the known windows and | 119 // of |parent|. The returned string constains the id of the known windows and |
120 // is ordered from topmost to bottomost windows. | 120 // is ordered from topmost to bottomost windows. |
121 std::string WindowOrderAsString(aura::Window* parent) const { | 121 std::string WindowOrderAsString(aura::Window* parent) const { |
122 std::string result; | 122 std::string result; |
123 const aura::Window::Windows& windows = parent->children(); | 123 const aura::Window::Windows& windows = parent->children(); |
124 for (aura::Window::Windows::const_reverse_iterator i = windows.rbegin(); | 124 for (aura::Window::Windows::const_reverse_iterator i = windows.rbegin(); |
125 i != windows.rend(); ++i) { | 125 i != windows.rend(); ++i) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 std::unique_ptr<aura::Window> window4_; | 189 std::unique_ptr<aura::Window> window4_; |
190 | 190 |
191 TestWindowDelegate touch_resize_delegate_; | 191 TestWindowDelegate touch_resize_delegate_; |
192 std::unique_ptr<aura::Window> touch_resize_window_; | 192 std::unique_ptr<aura::Window> touch_resize_window_; |
193 WorkspaceWindowResizer* workspace_resizer_; | 193 WorkspaceWindowResizer* workspace_resizer_; |
194 | 194 |
195 private: | 195 private: |
196 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTest); | 196 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTest); |
197 }; | 197 }; |
198 | 198 |
199 INSTANTIATE_TEST_CASE_P( | |
200 /* prefix intentionally left blank due to only one parameterization */, | |
201 WorkspaceWindowResizerTest, | |
202 testing::Values(MaterialDesignController::NON_MATERIAL, | |
203 MaterialDesignController::MATERIAL_NORMAL, | |
204 MaterialDesignController::MATERIAL_EXPERIMENTAL)); | |
205 | |
206 // Assertions around attached window resize dragging from the right with 2 | 199 // Assertions around attached window resize dragging from the right with 2 |
207 // windows. | 200 // windows. |
208 TEST_P(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) { | 201 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) { |
209 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); | 202 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); |
210 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); | 203 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); |
211 | 204 |
212 std::vector<aura::Window*> windows; | 205 std::vector<aura::Window*> windows; |
213 windows.push_back(window2_.get()); | 206 windows.push_back(window2_.get()); |
214 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 207 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
215 window_.get(), gfx::Point(), HTRIGHT, | 208 window_.get(), gfx::Point(), HTRIGHT, |
216 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 209 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
217 ASSERT_TRUE(resizer.get()); | 210 ASSERT_TRUE(resizer.get()); |
218 // Move it 100 to the right, which should expand w1 and push w2. | 211 // Move it 100 to the right, which should expand w1 and push w2. |
(...skipping 13 matching lines...) Expand all Loading... |
232 EXPECT_EQ("500,200 100x200", window2_->bounds().ToString()); | 225 EXPECT_EQ("500,200 100x200", window2_->bounds().ToString()); |
233 | 226 |
234 // Revert and make sure everything moves back. | 227 // Revert and make sure everything moves back. |
235 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0); | 228 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0); |
236 resizer->RevertDrag(); | 229 resizer->RevertDrag(); |
237 EXPECT_EQ("0,300 400x300", window_->bounds().ToString()); | 230 EXPECT_EQ("0,300 400x300", window_->bounds().ToString()); |
238 EXPECT_EQ("400,200 100x200", window2_->bounds().ToString()); | 231 EXPECT_EQ("400,200 100x200", window2_->bounds().ToString()); |
239 } | 232 } |
240 | 233 |
241 // Assertions around collapsing and expanding. | 234 // Assertions around collapsing and expanding. |
242 TEST_P(WorkspaceWindowResizerTest, AttachedResize_RIGHT_Compress) { | 235 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_Compress) { |
243 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); | 236 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); |
244 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); | 237 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); |
245 | 238 |
246 std::vector<aura::Window*> windows; | 239 std::vector<aura::Window*> windows; |
247 windows.push_back(window2_.get()); | 240 windows.push_back(window2_.get()); |
248 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 241 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
249 window_.get(), gfx::Point(), HTRIGHT, | 242 window_.get(), gfx::Point(), HTRIGHT, |
250 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 243 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
251 ASSERT_TRUE(resizer.get()); | 244 ASSERT_TRUE(resizer.get()); |
252 // Move it 100 to the left, which should expand w2 and collapse w1. | 245 // Move it 100 to the left, which should expand w2 and collapse w1. |
(...skipping 18 matching lines...) Expand all Loading... |
271 EXPECT_EQ("500,200 100x200", window2_->bounds().ToString()); | 264 EXPECT_EQ("500,200 100x200", window2_->bounds().ToString()); |
272 | 265 |
273 // Back to -100. | 266 // Back to -100. |
274 resizer->Drag(CalculateDragPoint(*resizer, -100, 20), 0); | 267 resizer->Drag(CalculateDragPoint(*resizer, -100, 20), 0); |
275 EXPECT_EQ("0,300 300x300", window_->bounds().ToString()); | 268 EXPECT_EQ("0,300 300x300", window_->bounds().ToString()); |
276 EXPECT_EQ("300,200 200x200", window2_->bounds().ToString()); | 269 EXPECT_EQ("300,200 200x200", window2_->bounds().ToString()); |
277 } | 270 } |
278 | 271 |
279 // Assertions around attached window resize dragging from the right with 3 | 272 // Assertions around attached window resize dragging from the right with 3 |
280 // windows. | 273 // windows. |
281 TEST_P(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3) { | 274 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3) { |
282 window_->SetBounds(gfx::Rect(100, 300, 200, 300)); | 275 window_->SetBounds(gfx::Rect(100, 300, 200, 300)); |
283 window2_->SetBounds(gfx::Rect(300, 300, 150, 200)); | 276 window2_->SetBounds(gfx::Rect(300, 300, 150, 200)); |
284 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); | 277 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); |
285 delegate2_.set_min_size(gfx::Size(52, 50)); | 278 delegate2_.set_min_size(gfx::Size(52, 50)); |
286 delegate3_.set_min_size(gfx::Size(38, 50)); | 279 delegate3_.set_min_size(gfx::Size(38, 50)); |
287 | 280 |
288 std::vector<aura::Window*> windows; | 281 std::vector<aura::Window*> windows; |
289 windows.push_back(window2_.get()); | 282 windows.push_back(window2_.get()); |
290 windows.push_back(window3_.get()); | 283 windows.push_back(window3_.get()); |
291 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 284 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
(...skipping 20 matching lines...) Expand all Loading... |
312 | 305 |
313 // Revert and make sure everything moves back. | 306 // Revert and make sure everything moves back. |
314 resizer->RevertDrag(); | 307 resizer->RevertDrag(); |
315 EXPECT_EQ("100,300 200x300", window_->bounds().ToString()); | 308 EXPECT_EQ("100,300 200x300", window_->bounds().ToString()); |
316 EXPECT_EQ("300,300 150x200", window2_->bounds().ToString()); | 309 EXPECT_EQ("300,300 150x200", window2_->bounds().ToString()); |
317 EXPECT_EQ("450,300 100x200", window3_->bounds().ToString()); | 310 EXPECT_EQ("450,300 100x200", window3_->bounds().ToString()); |
318 } | 311 } |
319 | 312 |
320 // Assertions around attached window resizing (collapsing and expanding) with | 313 // Assertions around attached window resizing (collapsing and expanding) with |
321 // 3 windows. | 314 // 3 windows. |
322 TEST_P(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3_Compress) { | 315 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3_Compress) { |
323 window_->SetBounds(gfx::Rect(100, 300, 200, 300)); | 316 window_->SetBounds(gfx::Rect(100, 300, 200, 300)); |
324 window2_->SetBounds(gfx::Rect(300, 300, 200, 200)); | 317 window2_->SetBounds(gfx::Rect(300, 300, 200, 200)); |
325 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); | 318 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); |
326 delegate2_.set_min_size(gfx::Size(52, 50)); | 319 delegate2_.set_min_size(gfx::Size(52, 50)); |
327 delegate3_.set_min_size(gfx::Size(38, 50)); | 320 delegate3_.set_min_size(gfx::Size(38, 50)); |
328 | 321 |
329 std::vector<aura::Window*> windows; | 322 std::vector<aura::Window*> windows; |
330 windows.push_back(window2_.get()); | 323 windows.push_back(window2_.get()); |
331 windows.push_back(window3_.get()); | 324 windows.push_back(window3_.get()); |
332 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 325 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
(...skipping 13 matching lines...) Expand all Loading... |
346 EXPECT_EQ("600,300 100x200", window3_->bounds().ToString()); | 339 EXPECT_EQ("600,300 100x200", window3_->bounds().ToString()); |
347 | 340 |
348 // 100 to the left again. | 341 // 100 to the left again. |
349 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0); | 342 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0); |
350 EXPECT_EQ("100,300 100x300", window_->bounds().ToString()); | 343 EXPECT_EQ("100,300 100x300", window_->bounds().ToString()); |
351 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString()); | 344 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString()); |
352 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString()); | 345 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString()); |
353 } | 346 } |
354 | 347 |
355 // Assertions around collapsing and expanding from the bottom. | 348 // Assertions around collapsing and expanding from the bottom. |
356 TEST_P(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_Compress) { | 349 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_Compress) { |
357 window_->SetBounds(gfx::Rect(0, 100, 400, 300)); | 350 window_->SetBounds(gfx::Rect(0, 100, 400, 300)); |
358 window2_->SetBounds(gfx::Rect(400, 400, 100, 200)); | 351 window2_->SetBounds(gfx::Rect(400, 400, 100, 200)); |
359 | 352 |
360 std::vector<aura::Window*> windows; | 353 std::vector<aura::Window*> windows; |
361 windows.push_back(window2_.get()); | 354 windows.push_back(window2_.get()); |
362 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 355 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
363 window_.get(), gfx::Point(), HTBOTTOM, | 356 window_.get(), gfx::Point(), HTBOTTOM, |
364 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 357 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
365 ASSERT_TRUE(resizer.get()); | 358 ASSERT_TRUE(resizer.get()); |
366 // Move it up 100, which should expand w2 and collapse w1. | 359 // Move it up 100, which should expand w2 and collapse w1. |
(...skipping 13 matching lines...) Expand all Loading... |
380 EXPECT_EQ("400,500 100x100", window2_->bounds().ToString()); | 373 EXPECT_EQ("400,500 100x100", window2_->bounds().ToString()); |
381 | 374 |
382 // Back to -100. | 375 // Back to -100. |
383 resizer->Drag(CalculateDragPoint(*resizer, 20, -100), 0); | 376 resizer->Drag(CalculateDragPoint(*resizer, 20, -100), 0); |
384 EXPECT_EQ("0,100 400x200", window_->bounds().ToString()); | 377 EXPECT_EQ("0,100 400x200", window_->bounds().ToString()); |
385 EXPECT_EQ("400,300 100x300", window2_->bounds().ToString()); | 378 EXPECT_EQ("400,300 100x300", window2_->bounds().ToString()); |
386 } | 379 } |
387 | 380 |
388 // Assertions around attached window resize dragging from the bottom with 2 | 381 // Assertions around attached window resize dragging from the bottom with 2 |
389 // windows. | 382 // windows. |
390 TEST_P(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) { | 383 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) { |
391 window_->SetBounds(gfx::Rect(0, 50, 400, 200)); | 384 window_->SetBounds(gfx::Rect(0, 50, 400, 200)); |
392 window2_->SetBounds(gfx::Rect(0, 250, 200, 100)); | 385 window2_->SetBounds(gfx::Rect(0, 250, 200, 100)); |
393 | 386 |
394 std::vector<aura::Window*> windows; | 387 std::vector<aura::Window*> windows; |
395 windows.push_back(window2_.get()); | 388 windows.push_back(window2_.get()); |
396 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 389 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
397 window_.get(), gfx::Point(), HTBOTTOM, | 390 window_.get(), gfx::Point(), HTBOTTOM, |
398 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 391 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
399 ASSERT_TRUE(resizer.get()); | 392 ASSERT_TRUE(resizer.get()); |
400 // Move it 100 to the bottom, which should expand w1 and push w2. | 393 // Move it 100 to the bottom, which should expand w1 and push w2. |
(...skipping 14 matching lines...) Expand all Loading... |
415 | 408 |
416 // Revert and make sure everything moves back. | 409 // Revert and make sure everything moves back. |
417 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0); | 410 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0); |
418 resizer->RevertDrag(); | 411 resizer->RevertDrag(); |
419 EXPECT_EQ("0,50 400x200", window_->bounds().ToString()); | 412 EXPECT_EQ("0,50 400x200", window_->bounds().ToString()); |
420 EXPECT_EQ("0,250 200x100", window2_->bounds().ToString()); | 413 EXPECT_EQ("0,250 200x100", window2_->bounds().ToString()); |
421 } | 414 } |
422 | 415 |
423 // Assertions around attached window resize dragging from the bottom with 3 | 416 // Assertions around attached window resize dragging from the bottom with 3 |
424 // windows. | 417 // windows. |
425 TEST_P(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) { | 418 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) { |
426 UpdateDisplay("600x800"); | 419 UpdateDisplay("600x800"); |
427 aura::Window* root = Shell::GetPrimaryRootWindow(); | 420 aura::Window* root = Shell::GetPrimaryRootWindow(); |
428 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 421 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
429 | 422 |
430 window_->SetBounds(gfx::Rect(300, 100, 300, 200)); | 423 window_->SetBounds(gfx::Rect(300, 100, 300, 200)); |
431 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); | 424 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); |
432 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); | 425 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); |
433 delegate2_.set_min_size(gfx::Size(50, 52)); | 426 delegate2_.set_min_size(gfx::Size(50, 52)); |
434 delegate3_.set_min_size(gfx::Size(50, 38)); | 427 delegate3_.set_min_size(gfx::Size(50, 38)); |
435 | 428 |
(...skipping 24 matching lines...) Expand all Loading... |
460 | 453 |
461 // Revert and make sure everything moves back. | 454 // Revert and make sure everything moves back. |
462 resizer->RevertDrag(); | 455 resizer->RevertDrag(); |
463 EXPECT_EQ("300,100 300x200", window_->bounds().ToString()); | 456 EXPECT_EQ("300,100 300x200", window_->bounds().ToString()); |
464 EXPECT_EQ("300,300 200x150", window2_->bounds().ToString()); | 457 EXPECT_EQ("300,300 200x150", window2_->bounds().ToString()); |
465 EXPECT_EQ("300,450 200x100", window3_->bounds().ToString()); | 458 EXPECT_EQ("300,450 200x100", window3_->bounds().ToString()); |
466 } | 459 } |
467 | 460 |
468 // Assertions around attached window resizing (collapsing and expanding) with | 461 // Assertions around attached window resizing (collapsing and expanding) with |
469 // 3 windows. | 462 // 3 windows. |
470 TEST_P(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3_Compress) { | 463 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3_Compress) { |
471 window_->SetBounds(gfx::Rect(0, 0, 200, 200)); | 464 window_->SetBounds(gfx::Rect(0, 0, 200, 200)); |
472 window2_->SetBounds(gfx::Rect(10, 200, 200, 200)); | 465 window2_->SetBounds(gfx::Rect(10, 200, 200, 200)); |
473 window3_->SetBounds(gfx::Rect(20, 400, 100, 100)); | 466 window3_->SetBounds(gfx::Rect(20, 400, 100, 100)); |
474 delegate2_.set_min_size(gfx::Size(52, 50)); | 467 delegate2_.set_min_size(gfx::Size(52, 50)); |
475 delegate3_.set_min_size(gfx::Size(38, 50)); | 468 delegate3_.set_min_size(gfx::Size(38, 50)); |
476 | 469 |
477 std::vector<aura::Window*> windows; | 470 std::vector<aura::Window*> windows; |
478 windows.push_back(window2_.get()); | 471 windows.push_back(window2_.get()); |
479 windows.push_back(window3_.get()); | 472 windows.push_back(window3_.get()); |
480 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 473 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
(...skipping 14 matching lines...) Expand all Loading... |
495 | 488 |
496 // 100 up again. | 489 // 100 up again. |
497 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); | 490 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); |
498 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); | 491 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); |
499 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); | 492 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); |
500 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); | 493 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); |
501 } | 494 } |
502 | 495 |
503 // Tests that touch-dragging a window does not lock the mouse cursor | 496 // Tests that touch-dragging a window does not lock the mouse cursor |
504 // and therefore shows the cursor on a mousemove. | 497 // and therefore shows the cursor on a mousemove. |
505 TEST_P(WorkspaceWindowResizerTest, MouseMoveWithTouchDrag) { | 498 TEST_F(WorkspaceWindowResizerTest, MouseMoveWithTouchDrag) { |
506 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); | 499 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); |
507 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); | 500 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); |
508 | 501 |
509 Shell* shell = Shell::GetInstance(); | 502 Shell* shell = Shell::GetInstance(); |
510 ui::test::EventGenerator generator(window_->GetRootWindow()); | 503 ui::test::EventGenerator generator(window_->GetRootWindow()); |
511 | 504 |
512 // The cursor should not be locked initially. | 505 // The cursor should not be locked initially. |
513 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); | 506 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); |
514 | 507 |
515 std::vector<aura::Window*> windows; | 508 std::vector<aura::Window*> windows; |
(...skipping 16 matching lines...) Expand all Loading... |
532 | 525 |
533 // Moving the mouse should show the cursor. | 526 // Moving the mouse should show the cursor. |
534 generator.MoveMouseBy(1, 1); | 527 generator.MoveMouseBy(1, 1); |
535 EXPECT_TRUE(shell->cursor_manager()->IsCursorVisible()); | 528 EXPECT_TRUE(shell->cursor_manager()->IsCursorVisible()); |
536 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); | 529 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); |
537 | 530 |
538 resizer->RevertDrag(); | 531 resizer->RevertDrag(); |
539 } | 532 } |
540 | 533 |
541 // Assertions around dragging to the left/right edge of the screen. | 534 // Assertions around dragging to the left/right edge of the screen. |
542 TEST_P(WorkspaceWindowResizerTest, Edge) { | 535 TEST_F(WorkspaceWindowResizerTest, Edge) { |
543 // Resize host window to force insets update. | 536 // Resize host window to force insets update. |
544 UpdateDisplay("800x700"); | 537 UpdateDisplay("800x700"); |
545 // TODO(varkha): Insets are reset after every drag because of | 538 // TODO(varkha): Insets are reset after every drag because of |
546 // http://crbug.com/292238. | 539 // http://crbug.com/292238. |
547 // Window is wide enough not to get docked right away. | 540 // Window is wide enough not to get docked right away. |
548 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); | 541 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); |
549 window_->SetProperty(aura::client::kResizeBehaviorKey, | 542 window_->SetProperty(aura::client::kResizeBehaviorKey, |
550 ui::mojom::kResizeBehaviorCanResize | | 543 ui::mojom::kResizeBehaviorCanResize | |
551 ui::mojom::kResizeBehaviorCanMaximize); | 544 ui::mojom::kResizeBehaviorCanMaximize); |
552 wm::WindowState* window_state = wm::GetWindowState(window_.get()); | 545 wm::WindowState* window_state = wm::GetWindowState(window_.get()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 // size setting. | 604 // size setting. |
612 // TODO(varkha): Insets are updated because of http://crbug.com/292238 | 605 // TODO(varkha): Insets are updated because of http://crbug.com/292238 |
613 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), | 606 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), |
614 window_->bounds().ToString()); | 607 window_->bounds().ToString()); |
615 EXPECT_EQ("800,10 400x60", | 608 EXPECT_EQ("800,10 400x60", |
616 window_state->GetRestoreBoundsInScreen().ToString()); | 609 window_state->GetRestoreBoundsInScreen().ToString()); |
617 } | 610 } |
618 } | 611 } |
619 | 612 |
620 // Check that non resizable windows will not get resized. | 613 // Check that non resizable windows will not get resized. |
621 TEST_P(WorkspaceWindowResizerTest, NonResizableWindows) { | 614 TEST_F(WorkspaceWindowResizerTest, NonResizableWindows) { |
622 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); | 615 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); |
623 window_->SetProperty(aura::client::kResizeBehaviorKey, | 616 window_->SetProperty(aura::client::kResizeBehaviorKey, |
624 ui::mojom::kResizeBehaviorNone); | 617 ui::mojom::kResizeBehaviorNone); |
625 | 618 |
626 std::unique_ptr<WindowResizer> resizer( | 619 std::unique_ptr<WindowResizer> resizer( |
627 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 620 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
628 ASSERT_TRUE(resizer.get()); | 621 ASSERT_TRUE(resizer.get()); |
629 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); | 622 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); |
630 resizer->CompleteDrag(); | 623 resizer->CompleteDrag(); |
631 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); | 624 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); |
632 } | 625 } |
633 | 626 |
634 TEST_P(WorkspaceWindowResizerTest, CancelSnapPhantom) { | 627 TEST_F(WorkspaceWindowResizerTest, CancelSnapPhantom) { |
635 UpdateDisplay("800x600,800x600"); | 628 UpdateDisplay("800x600,800x600"); |
636 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 629 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
637 ASSERT_EQ(2U, root_windows.size()); | 630 ASSERT_EQ(2U, root_windows.size()); |
638 | 631 |
639 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 632 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
640 display::Screen::GetScreen()->GetPrimaryDisplay()); | 633 display::Screen::GetScreen()->GetPrimaryDisplay()); |
641 | 634 |
642 // Make the window snappable by making it resizable and maximizable. | 635 // Make the window snappable by making it resizable and maximizable. |
643 window_->SetProperty(aura::client::kResizeBehaviorKey, | 636 window_->SetProperty(aura::client::kResizeBehaviorKey, |
644 ui::mojom::kResizeBehaviorCanResize | | 637 ui::mojom::kResizeBehaviorCanResize | |
(...skipping 12 matching lines...) Expand all Loading... |
657 EXPECT_TRUE(snap_phantom_window_controller()); | 650 EXPECT_TRUE(snap_phantom_window_controller()); |
658 | 651 |
659 // Move the cursor across the edge. Now the snap phantom window controller | 652 // Move the cursor across the edge. Now the snap phantom window controller |
660 // should be canceled. | 653 // should be canceled. |
661 resizer->Drag(CalculateDragPoint(*resizer, 800, 0), 0); | 654 resizer->Drag(CalculateDragPoint(*resizer, 800, 0), 0); |
662 EXPECT_FALSE(snap_phantom_window_controller()); | 655 EXPECT_FALSE(snap_phantom_window_controller()); |
663 } | 656 } |
664 } | 657 } |
665 | 658 |
666 // Verifies that dragging a snapped window unsnaps it. | 659 // Verifies that dragging a snapped window unsnaps it. |
667 TEST_P(WorkspaceWindowResizerTest, DragSnapped) { | 660 TEST_F(WorkspaceWindowResizerTest, DragSnapped) { |
668 wm::WindowState* window_state = ash::wm::GetWindowState(window_.get()); | 661 wm::WindowState* window_state = ash::wm::GetWindowState(window_.get()); |
669 | 662 |
670 const gfx::Rect kInitialBounds(100, 100, 100, 100); | 663 const gfx::Rect kInitialBounds(100, 100, 100, 100); |
671 window_->SetBounds(kInitialBounds); | 664 window_->SetBounds(kInitialBounds); |
672 window_->Show(); | 665 window_->Show(); |
673 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT); | 666 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT); |
674 window_state->OnWMEvent(&snap_event); | 667 window_state->OnWMEvent(&snap_event); |
675 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); | 668 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); |
676 gfx::Rect snapped_bounds = window_->bounds(); | 669 gfx::Rect snapped_bounds = window_->bounds(); |
677 EXPECT_NE(snapped_bounds.ToString(), kInitialBounds.ToString()); | 670 EXPECT_NE(snapped_bounds.ToString(), kInitialBounds.ToString()); |
678 EXPECT_EQ(window_state->GetRestoreBoundsInParent().ToString(), | 671 EXPECT_EQ(window_state->GetRestoreBoundsInParent().ToString(), |
679 kInitialBounds.ToString()); | 672 kInitialBounds.ToString()); |
680 | 673 |
681 // Dragging a side snapped window should unsnap it. | 674 // Dragging a side snapped window should unsnap it. |
682 std::unique_ptr<WindowResizer> resizer( | 675 std::unique_ptr<WindowResizer> resizer( |
683 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 676 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
684 resizer->Drag(CalculateDragPoint(*resizer, 10, 0), 0); | 677 resizer->Drag(CalculateDragPoint(*resizer, 10, 0), 0); |
685 resizer->CompleteDrag(); | 678 resizer->CompleteDrag(); |
686 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, window_state->GetStateType()); | 679 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, window_state->GetStateType()); |
687 EXPECT_EQ("10,0 100x100", window_->bounds().ToString()); | 680 EXPECT_EQ("10,0 100x100", window_->bounds().ToString()); |
688 EXPECT_FALSE(window_state->HasRestoreBounds()); | 681 EXPECT_FALSE(window_state->HasRestoreBounds()); |
689 } | 682 } |
690 | 683 |
691 // Verifies the behavior of resizing a side snapped window. | 684 // Verifies the behavior of resizing a side snapped window. |
692 TEST_P(WorkspaceWindowResizerTest, ResizeSnapped) { | 685 TEST_F(WorkspaceWindowResizerTest, ResizeSnapped) { |
693 wm::WindowState* window_state = ash::wm::GetWindowState(window_.get()); | 686 wm::WindowState* window_state = ash::wm::GetWindowState(window_.get()); |
694 | 687 |
695 const gfx::Rect kInitialBounds(100, 100, 100, 100); | 688 const gfx::Rect kInitialBounds(100, 100, 100, 100); |
696 window_->SetBounds(kInitialBounds); | 689 window_->SetBounds(kInitialBounds); |
697 window_->Show(); | 690 window_->Show(); |
698 | 691 |
699 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT); | 692 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT); |
700 window_state->OnWMEvent(&snap_event); | 693 window_state->OnWMEvent(&snap_event); |
701 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); | 694 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); |
702 gfx::Rect snapped_bounds = window_->bounds(); | 695 gfx::Rect snapped_bounds = window_->bounds(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 resizer->CompleteDrag(); | 734 resizer->CompleteDrag(); |
742 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, window_state->GetStateType()); | 735 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, window_state->GetStateType()); |
743 gfx::Rect expected_bounds(snapped_bounds); | 736 gfx::Rect expected_bounds(snapped_bounds); |
744 expected_bounds.Inset(0, 0, 0, 10); | 737 expected_bounds.Inset(0, 0, 0, 10); |
745 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString()); | 738 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString()); |
746 EXPECT_FALSE(window_state->HasRestoreBounds()); | 739 EXPECT_FALSE(window_state->HasRestoreBounds()); |
747 } | 740 } |
748 } | 741 } |
749 | 742 |
750 // Verifies windows are correctly restacked when reordering multiple windows. | 743 // Verifies windows are correctly restacked when reordering multiple windows. |
751 TEST_P(WorkspaceWindowResizerTest, RestackAttached) { | 744 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { |
752 window_->SetBounds(gfx::Rect(0, 0, 200, 300)); | 745 window_->SetBounds(gfx::Rect(0, 0, 200, 300)); |
753 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); | 746 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); |
754 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); | 747 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); |
755 | 748 |
756 { | 749 { |
757 std::vector<aura::Window*> windows; | 750 std::vector<aura::Window*> windows; |
758 windows.push_back(window2_.get()); | 751 windows.push_back(window2_.get()); |
759 std::unique_ptr<WorkspaceWindowResizer> resizer( | 752 std::unique_ptr<WorkspaceWindowResizer> resizer( |
760 CreateWorkspaceResizerForTest(window_.get(), gfx::Point(), HTRIGHT, | 753 CreateWorkspaceResizerForTest(window_.get(), gfx::Point(), HTRIGHT, |
761 aura::client::WINDOW_MOVE_SOURCE_MOUSE, | 754 aura::client::WINDOW_MOVE_SOURCE_MOUSE, |
(...skipping 16 matching lines...) Expand all Loading... |
778 ASSERT_TRUE(resizer.get()); | 771 ASSERT_TRUE(resizer.get()); |
779 // Move it 100 to the right, which should expand w1 and push w2 and w3. | 772 // Move it 100 to the right, which should expand w1 and push w2 and w3. |
780 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); | 773 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); |
781 | 774 |
782 // 2 should be topmost since it's initially the highest in the stack. | 775 // 2 should be topmost since it's initially the highest in the stack. |
783 EXPECT_EQ("2 3 1", WindowOrderAsString(window_->parent())); | 776 EXPECT_EQ("2 3 1", WindowOrderAsString(window_->parent())); |
784 } | 777 } |
785 } | 778 } |
786 | 779 |
787 // Makes sure we don't allow dragging below the work area. | 780 // Makes sure we don't allow dragging below the work area. |
788 TEST_P(WorkspaceWindowResizerTest, DontDragOffBottom) { | 781 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { |
789 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 782 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
790 gfx::Insets(0, 0, 10, 0)); | 783 gfx::Insets(0, 0, 10, 0)); |
791 | 784 |
792 ASSERT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); | 785 ASSERT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); |
793 | 786 |
794 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 787 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
795 std::unique_ptr<WindowResizer> resizer( | 788 std::unique_ptr<WindowResizer> resizer( |
796 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 789 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
797 ASSERT_TRUE(resizer.get()); | 790 ASSERT_TRUE(resizer.get()); |
798 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); | 791 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); |
799 int expected_y = | 792 int expected_y = |
800 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 793 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
801 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", | 794 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", |
802 window_->bounds().ToString()); | 795 window_->bounds().ToString()); |
803 } | 796 } |
804 | 797 |
805 // Makes sure we don't allow dragging on the work area with multidisplay. | 798 // Makes sure we don't allow dragging on the work area with multidisplay. |
806 TEST_P(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { | 799 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { |
807 UpdateDisplay("800x600,800x600"); | 800 UpdateDisplay("800x600,800x600"); |
808 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); | 801 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); |
809 | 802 |
810 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 803 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
811 gfx::Insets(0, 0, 10, 0)); | 804 gfx::Insets(0, 0, 10, 0)); |
812 | 805 |
813 // Positions the secondary display at the bottom the primary display. | 806 // Positions the secondary display at the bottom the primary display. |
814 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 807 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
815 display::test::CreateDisplayLayout(display_manager(), | 808 display::test::CreateDisplayLayout(display_manager(), |
816 display::DisplayPlacement::BOTTOM, 0)); | 809 display::DisplayPlacement::BOTTOM, 0)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 // Drag down avoiding getting stuck against the shelf on the bottom screen. | 853 // Drag down avoiding getting stuck against the shelf on the bottom screen. |
861 resizer->Drag(CalculateDragPoint(*resizer, 0, 500), 0); | 854 resizer->Drag(CalculateDragPoint(*resizer, 0, 500), 0); |
862 // The window can move to the secondary display beyond non-work area of | 855 // The window can move to the secondary display beyond non-work area of |
863 // the primary display. | 856 // the primary display. |
864 EXPECT_EQ("100,700 300x400", window_->bounds().ToString()); | 857 EXPECT_EQ("100,700 300x400", window_->bounds().ToString()); |
865 resizer->CompleteDrag(); | 858 resizer->CompleteDrag(); |
866 } | 859 } |
867 } | 860 } |
868 | 861 |
869 // Makes sure we don't allow dragging off the top of the work area. | 862 // Makes sure we don't allow dragging off the top of the work area. |
870 TEST_P(WorkspaceWindowResizerTest, DontDragOffTop) { | 863 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { |
871 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 864 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
872 gfx::Insets(10, 0, 0, 0)); | 865 gfx::Insets(10, 0, 0, 0)); |
873 | 866 |
874 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 867 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
875 std::unique_ptr<WindowResizer> resizer( | 868 std::unique_ptr<WindowResizer> resizer( |
876 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 869 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
877 ASSERT_TRUE(resizer.get()); | 870 ASSERT_TRUE(resizer.get()); |
878 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0); | 871 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0); |
879 EXPECT_EQ("100,10 300x400", window_->bounds().ToString()); | 872 EXPECT_EQ("100,10 300x400", window_->bounds().ToString()); |
880 } | 873 } |
881 | 874 |
882 TEST_P(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { | 875 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { |
883 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 876 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
884 gfx::Insets(0, 0, 50, 0)); | 877 gfx::Insets(0, 0, 50, 0)); |
885 | 878 |
886 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); | 879 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); |
887 std::unique_ptr<WindowResizer> resizer( | 880 std::unique_ptr<WindowResizer> resizer( |
888 CreateResizerForTest(window_.get(), gfx::Point(), HTTOP)); | 881 CreateResizerForTest(window_.get(), gfx::Point(), HTTOP)); |
889 ASSERT_TRUE(resizer.get()); | 882 ASSERT_TRUE(resizer.get()); |
890 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); | 883 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); |
891 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); | 884 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); |
892 } | 885 } |
893 | 886 |
894 TEST_P(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { | 887 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { |
895 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 888 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
896 gfx::Insets(0, 0, 50, 0)); | 889 gfx::Insets(0, 0, 50, 0)); |
897 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); | 890 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); |
898 int pixels_to_left_border = 50; | 891 int pixels_to_left_border = 50; |
899 int window_width = 300; | 892 int window_width = 300; |
900 int window_x = left - window_width + pixels_to_left_border; | 893 int window_x = left - window_width + pixels_to_left_border; |
901 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 894 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
902 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( | 895 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( |
903 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); | 896 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); |
904 ASSERT_TRUE(resizer.get()); | 897 ASSERT_TRUE(resizer.get()); |
905 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); | 898 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); |
906 EXPECT_EQ(base::IntToString(window_x) + ",100 " + | 899 EXPECT_EQ(base::IntToString(window_x) + ",100 " + |
907 base::IntToString(wm::kMinimumOnScreenArea - window_x) + "x380", | 900 base::IntToString(wm::kMinimumOnScreenArea - window_x) + "x380", |
908 window_->bounds().ToString()); | 901 window_->bounds().ToString()); |
909 } | 902 } |
910 | 903 |
911 TEST_P(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { | 904 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { |
912 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 905 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
913 gfx::Insets(0, 0, 50, 0)); | 906 gfx::Insets(0, 0, 50, 0)); |
914 int right = | 907 int right = |
915 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).right(); | 908 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).right(); |
916 int pixels_to_right_border = 50; | 909 int pixels_to_right_border = 50; |
917 int window_width = 300; | 910 int window_width = 300; |
918 int window_x = right - pixels_to_right_border; | 911 int window_x = right - pixels_to_right_border; |
919 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 912 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
920 std::unique_ptr<WindowResizer> resizer( | 913 std::unique_ptr<WindowResizer> resizer( |
921 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTLEFT)); | 914 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTLEFT)); |
922 ASSERT_TRUE(resizer.get()); | 915 ASSERT_TRUE(resizer.get()); |
923 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 916 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
924 EXPECT_EQ(base::IntToString(right - wm::kMinimumOnScreenArea) + ",100 " + | 917 EXPECT_EQ(base::IntToString(right - wm::kMinimumOnScreenArea) + ",100 " + |
925 base::IntToString(window_width - pixels_to_right_border + | 918 base::IntToString(window_width - pixels_to_right_border + |
926 wm::kMinimumOnScreenArea) + | 919 wm::kMinimumOnScreenArea) + |
927 "x380", | 920 "x380", |
928 window_->bounds().ToString()); | 921 window_->bounds().ToString()); |
929 } | 922 } |
930 | 923 |
931 TEST_P(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { | 924 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { |
932 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 925 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
933 gfx::Insets(0, 0, 50, 0)); | 926 gfx::Insets(0, 0, 50, 0)); |
934 int bottom = | 927 int bottom = |
935 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | 928 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
936 int delta_to_bottom = 50; | 929 int delta_to_bottom = 50; |
937 int height = 380; | 930 int height = 380; |
938 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); | 931 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); |
939 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( | 932 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( |
940 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); | 933 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); |
941 ASSERT_TRUE(resizer.get()); | 934 ASSERT_TRUE(resizer.get()); |
942 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); | 935 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); |
943 EXPECT_EQ("100," + base::IntToString(bottom - wm::kMinimumOnScreenArea) + | 936 EXPECT_EQ("100," + base::IntToString(bottom - wm::kMinimumOnScreenArea) + |
944 " 300x" + | 937 " 300x" + |
945 base::IntToString(height - | 938 base::IntToString(height - |
946 (delta_to_bottom - wm::kMinimumOnScreenArea)), | 939 (delta_to_bottom - wm::kMinimumOnScreenArea)), |
947 window_->bounds().ToString()); | 940 window_->bounds().ToString()); |
948 } | 941 } |
949 | 942 |
950 // Verifies that 'outside' check of the resizer take into account the extended | 943 // Verifies that 'outside' check of the resizer take into account the extended |
951 // desktop in case of repositions. | 944 // desktop in case of repositions. |
952 TEST_P(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { | 945 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { |
953 // Only primary display. Changes the window position to fit within the | 946 // Only primary display. Changes the window position to fit within the |
954 // display. | 947 // display. |
955 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 948 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
956 gfx::Insets(0, 0, 50, 0)); | 949 gfx::Insets(0, 0, 50, 0)); |
957 int right = | 950 int right = |
958 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).right(); | 951 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).right(); |
959 int pixels_to_right_border = 50; | 952 int pixels_to_right_border = 50; |
960 int window_width = 300; | 953 int window_width = 300; |
961 int window_x = right - pixels_to_right_border; | 954 int window_x = right - pixels_to_right_border; |
962 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 955 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
(...skipping 11 matching lines...) Expand all Loading... |
974 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 967 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
975 gfx::Insets(0, 0, 50, 0)); | 968 gfx::Insets(0, 0, 50, 0)); |
976 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 969 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
977 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 970 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
978 EXPECT_EQ(base::IntToString(window_x + window_width) + ",100 " + | 971 EXPECT_EQ(base::IntToString(window_x + window_width) + ",100 " + |
979 base::IntToString(window_width) + "x380", | 972 base::IntToString(window_width) + "x380", |
980 window_->bounds().ToString()); | 973 window_->bounds().ToString()); |
981 } | 974 } |
982 | 975 |
983 // Verifies snapping to edges works. | 976 // Verifies snapping to edges works. |
984 TEST_P(WorkspaceWindowResizerTest, SnapToEdge) { | 977 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { |
985 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 978 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
986 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 979 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
987 // Click 50px to the right so that the mouse pointer does not leave the | 980 // Click 50px to the right so that the mouse pointer does not leave the |
988 // workspace ensuring sticky behavior. | 981 // workspace ensuring sticky behavior. |
989 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( | 982 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( |
990 window_.get(), window_->bounds().origin() + gfx::Vector2d(50, 0), | 983 window_.get(), window_->bounds().origin() + gfx::Vector2d(50, 0), |
991 HTCAPTION)); | 984 HTCAPTION)); |
992 ASSERT_TRUE(resizer.get()); | 985 ASSERT_TRUE(resizer.get()); |
993 int distance_to_left = window_->bounds().x(); | 986 int distance_to_left = window_->bounds().x(); |
994 int distance_to_right = | 987 int distance_to_right = |
(...skipping 22 matching lines...) Expand all Loading... |
1017 EXPECT_EQ("465,112 320x160", window_->bounds().ToString()); | 1010 EXPECT_EQ("465,112 320x160", window_->bounds().ToString()); |
1018 resizer->Drag(CalculateDragPoint(*resizer, distance_to_right - 7, 0), 0); | 1011 resizer->Drag(CalculateDragPoint(*resizer, distance_to_right - 7, 0), 0); |
1019 EXPECT_EQ("480,112 320x160", window_->bounds().ToString()); | 1012 EXPECT_EQ("480,112 320x160", window_->bounds().ToString()); |
1020 resizer->Drag(CalculateDragPoint(*resizer, distance_to_right + 15, 0), 0); | 1013 resizer->Drag(CalculateDragPoint(*resizer, distance_to_right + 15, 0), 0); |
1021 EXPECT_EQ("480,112 320x160", window_->bounds().ToString()); | 1014 EXPECT_EQ("480,112 320x160", window_->bounds().ToString()); |
1022 resizer->Drag(CalculateDragPoint(*resizer, distance_to_right + 32, 0), 0); | 1015 resizer->Drag(CalculateDragPoint(*resizer, distance_to_right + 32, 0), 0); |
1023 EXPECT_EQ("512,112 320x160", window_->bounds().ToString()); | 1016 EXPECT_EQ("512,112 320x160", window_->bounds().ToString()); |
1024 resizer->Drag(CalculateDragPoint(*resizer, distance_to_right + 33, 0), 0); | 1017 resizer->Drag(CalculateDragPoint(*resizer, distance_to_right + 33, 0), 0); |
1025 EXPECT_EQ("513,112 320x160", window_->bounds().ToString()); | 1018 EXPECT_EQ("513,112 320x160", window_->bounds().ToString()); |
1026 | 1019 |
1027 // 3 pixels are reserved for auto-hidden shelf height in non-MD, and no space | |
1028 // is reserved for auto hide shelf height in MD. | |
1029 int auto_hidden_shelf_offset = GetMdAutoHiddenShelfHeightOffset(); | |
1030 int auto_hidden_shelf_height = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); | 1020 int auto_hidden_shelf_height = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); |
1031 | 1021 |
1032 // And the bottom should snap too. | 1022 // And the bottom should snap too. |
1033 resizer->Drag( | 1023 resizer->Drag( |
1034 CalculateDragPoint(*resizer, 0, | 1024 CalculateDragPoint(*resizer, 0, |
1035 distance_to_bottom - auto_hidden_shelf_height - 7), | 1025 distance_to_bottom - auto_hidden_shelf_height - 7), |
1036 0); | 1026 0); |
1037 EXPECT_EQ(gfx::Rect(96, 437 + auto_hidden_shelf_offset, 320, 160).ToString(), | 1027 EXPECT_EQ(gfx::Rect(96, 440, 320, 160).ToString(), |
1038 window_->bounds().ToString()); | 1028 window_->bounds().ToString()); |
1039 resizer->Drag( | 1029 resizer->Drag( |
1040 CalculateDragPoint(*resizer, 0, | 1030 CalculateDragPoint(*resizer, 0, |
1041 distance_to_bottom - auto_hidden_shelf_height + 15), | 1031 distance_to_bottom - auto_hidden_shelf_height + 15), |
1042 0); | 1032 0); |
1043 EXPECT_EQ(gfx::Rect(96, 437 + auto_hidden_shelf_offset, 320, 160).ToString(), | 1033 EXPECT_EQ(gfx::Rect(96, 440, 320, 160).ToString(), |
1044 window_->bounds().ToString()); | 1034 window_->bounds().ToString()); |
1045 resizer->Drag(CalculateDragPoint(*resizer, 0, distance_to_bottom - 2 + 32), | 1035 resizer->Drag(CalculateDragPoint(*resizer, 0, distance_to_bottom - 2 + 32), |
1046 0); | 1036 0); |
1047 EXPECT_EQ("96,470 320x160", window_->bounds().ToString()); | 1037 EXPECT_EQ("96,470 320x160", window_->bounds().ToString()); |
1048 resizer->Drag(CalculateDragPoint(*resizer, 0, distance_to_bottom - 2 + 33), | 1038 resizer->Drag(CalculateDragPoint(*resizer, 0, distance_to_bottom - 2 + 33), |
1049 0); | 1039 0); |
1050 EXPECT_EQ("96,471 320x160", window_->bounds().ToString()); | 1040 EXPECT_EQ("96,471 320x160", window_->bounds().ToString()); |
1051 | 1041 |
1052 // And the top should snap too. | 1042 // And the top should snap too. |
1053 resizer->Drag(CalculateDragPoint(*resizer, 0, -distance_to_top + 20), 0); | 1043 resizer->Drag(CalculateDragPoint(*resizer, 0, -distance_to_top + 20), 0); |
1054 EXPECT_EQ("96,20 320x160", window_->bounds().ToString()); | 1044 EXPECT_EQ("96,20 320x160", window_->bounds().ToString()); |
1055 resizer->Drag(CalculateDragPoint(*resizer, 0, -distance_to_top + 7), 0); | 1045 resizer->Drag(CalculateDragPoint(*resizer, 0, -distance_to_top + 7), 0); |
1056 EXPECT_EQ("96,0 320x160", window_->bounds().ToString()); | 1046 EXPECT_EQ("96,0 320x160", window_->bounds().ToString()); |
1057 | 1047 |
1058 // And bottom/left should snap too. | 1048 // And bottom/left should snap too. |
1059 resizer->Drag( | 1049 resizer->Drag( |
1060 CalculateDragPoint(*resizer, 7 - distance_to_left, | 1050 CalculateDragPoint(*resizer, 7 - distance_to_left, |
1061 distance_to_bottom - auto_hidden_shelf_height - 7), | 1051 distance_to_bottom - auto_hidden_shelf_height - 7), |
1062 0); | 1052 0); |
1063 EXPECT_EQ(gfx::Rect(0, 437 + auto_hidden_shelf_offset, 320, 160).ToString(), | 1053 EXPECT_EQ(gfx::Rect(0, 440, 320, 160).ToString(), |
1064 window_->bounds().ToString()); | 1054 window_->bounds().ToString()); |
1065 resizer->Drag( | 1055 resizer->Drag( |
1066 CalculateDragPoint(*resizer, -15 - distance_to_left, | 1056 CalculateDragPoint(*resizer, -15 - distance_to_left, |
1067 distance_to_bottom - auto_hidden_shelf_height + 15), | 1057 distance_to_bottom - auto_hidden_shelf_height + 15), |
1068 0); | 1058 0); |
1069 EXPECT_EQ(gfx::Rect(0, 437 + auto_hidden_shelf_offset, 320, 160).ToString(), | 1059 EXPECT_EQ(gfx::Rect(0, 440, 320, 160).ToString(), |
1070 window_->bounds().ToString()); | 1060 window_->bounds().ToString()); |
1071 // should move past snap points. | 1061 // should move past snap points. |
1072 resizer->Drag(CalculateDragPoint(*resizer, -32 - distance_to_left, | 1062 resizer->Drag(CalculateDragPoint(*resizer, -32 - distance_to_left, |
1073 distance_to_bottom - 2 + 32), | 1063 distance_to_bottom - 2 + 32), |
1074 0); | 1064 0); |
1075 EXPECT_EQ("-32,470 320x160", window_->bounds().ToString()); | 1065 EXPECT_EQ("-32,470 320x160", window_->bounds().ToString()); |
1076 resizer->Drag(CalculateDragPoint(*resizer, -33 - distance_to_left, | 1066 resizer->Drag(CalculateDragPoint(*resizer, -33 - distance_to_left, |
1077 distance_to_bottom - 2 + 33), | 1067 distance_to_bottom - 2 + 33), |
1078 0); | 1068 0); |
1079 EXPECT_EQ("-33,471 320x160", window_->bounds().ToString()); | 1069 EXPECT_EQ("-33,471 320x160", window_->bounds().ToString()); |
1080 | 1070 |
1081 // No need to test dragging < 0 as we force that to 0. | 1071 // No need to test dragging < 0 as we force that to 0. |
1082 } | 1072 } |
1083 | 1073 |
1084 // Verifies a resize snap when dragging TOPLEFT. | 1074 // Verifies a resize snap when dragging TOPLEFT. |
1085 TEST_P(WorkspaceWindowResizerTest, SnapToWorkArea_TOPLEFT) { | 1075 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPLEFT) { |
1086 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1076 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1087 std::unique_ptr<WindowResizer> resizer( | 1077 std::unique_ptr<WindowResizer> resizer( |
1088 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT)); | 1078 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT)); |
1089 ASSERT_TRUE(resizer.get()); | 1079 ASSERT_TRUE(resizer.get()); |
1090 resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0); | 1080 resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0); |
1091 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); | 1081 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); |
1092 } | 1082 } |
1093 | 1083 |
1094 // Verifies a resize snap when dragging TOPRIGHT. | 1084 // Verifies a resize snap when dragging TOPRIGHT. |
1095 TEST_P(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { | 1085 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { |
1096 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1086 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1097 gfx::Rect work_area( | 1087 gfx::Rect work_area( |
1098 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get())); | 1088 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get())); |
1099 std::unique_ptr<WindowResizer> resizer( | 1089 std::unique_ptr<WindowResizer> resizer( |
1100 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT)); | 1090 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT)); |
1101 ASSERT_TRUE(resizer.get()); | 1091 ASSERT_TRUE(resizer.get()); |
1102 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), | 1092 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), |
1103 0); | 1093 0); |
1104 EXPECT_EQ(100, window_->bounds().x()); | 1094 EXPECT_EQ(100, window_->bounds().x()); |
1105 EXPECT_EQ(work_area.y(), window_->bounds().y()); | 1095 EXPECT_EQ(work_area.y(), window_->bounds().y()); |
1106 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1096 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
1107 EXPECT_EQ(230, window_->bounds().height()); | 1097 EXPECT_EQ(230, window_->bounds().height()); |
1108 } | 1098 } |
1109 | 1099 |
1110 // Verifies a resize snap when dragging BOTTOMRIGHT. | 1100 // Verifies a resize snap when dragging BOTTOMRIGHT. |
1111 TEST_P(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { | 1101 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { |
1112 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1102 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1113 gfx::Rect work_area( | 1103 gfx::Rect work_area( |
1114 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get())); | 1104 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get())); |
1115 std::unique_ptr<WindowResizer> resizer( | 1105 std::unique_ptr<WindowResizer> resizer( |
1116 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); | 1106 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
1117 ASSERT_TRUE(resizer.get()); | 1107 ASSERT_TRUE(resizer.get()); |
1118 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 120 - 1, | 1108 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 120 - 1, |
1119 work_area.bottom() - 220 - 2), | 1109 work_area.bottom() - 220 - 2), |
1120 0); | 1110 0); |
1121 EXPECT_EQ(100, window_->bounds().x()); | 1111 EXPECT_EQ(100, window_->bounds().x()); |
1122 EXPECT_EQ(200, window_->bounds().y()); | 1112 EXPECT_EQ(200, window_->bounds().y()); |
1123 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1113 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
1124 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1114 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
1125 } | 1115 } |
1126 | 1116 |
1127 // Verifies a resize snap when dragging BOTTOMLEFT. | 1117 // Verifies a resize snap when dragging BOTTOMLEFT. |
1128 TEST_P(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) { | 1118 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) { |
1129 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1119 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1130 gfx::Rect work_area( | 1120 gfx::Rect work_area( |
1131 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get())); | 1121 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get())); |
1132 std::unique_ptr<WindowResizer> resizer( | 1122 std::unique_ptr<WindowResizer> resizer( |
1133 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT)); | 1123 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT)); |
1134 ASSERT_TRUE(resizer.get()); | 1124 ASSERT_TRUE(resizer.get()); |
1135 resizer->Drag(CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), | 1125 resizer->Drag(CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), |
1136 0); | 1126 0); |
1137 EXPECT_EQ(0, window_->bounds().x()); | 1127 EXPECT_EQ(0, window_->bounds().x()); |
1138 EXPECT_EQ(200, window_->bounds().y()); | 1128 EXPECT_EQ(200, window_->bounds().y()); |
1139 EXPECT_EQ(120, window_->bounds().width()); | 1129 EXPECT_EQ(120, window_->bounds().width()); |
1140 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1130 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
1141 } | 1131 } |
1142 | 1132 |
1143 // Verifies window sticks to both window and work area. | 1133 // Verifies window sticks to both window and work area. |
1144 TEST_P(WorkspaceWindowResizerTest, StickToBothEdgeAndWindow) { | 1134 TEST_F(WorkspaceWindowResizerTest, StickToBothEdgeAndWindow) { |
1145 window_->SetBounds(gfx::Rect(10, 10, 20, 50)); | 1135 window_->SetBounds(gfx::Rect(10, 10, 20, 50)); |
1146 window_->Show(); | 1136 window_->Show(); |
1147 window2_->SetBounds(gfx::Rect(150, 160, 25, 1000)); | 1137 window2_->SetBounds(gfx::Rect(150, 160, 25, 1000)); |
1148 window2_->Show(); | 1138 window2_->Show(); |
1149 | 1139 |
1150 std::unique_ptr<WindowResizer> resizer( | 1140 std::unique_ptr<WindowResizer> resizer( |
1151 CreateResizerForTest(window_.get(), gfx::Point(10, 10), HTCAPTION)); | 1141 CreateResizerForTest(window_.get(), gfx::Point(10, 10), HTCAPTION)); |
1152 ASSERT_TRUE(resizer.get()); | 1142 ASSERT_TRUE(resizer.get()); |
1153 | 1143 |
1154 // Move |window| one pixel to the left of |window2|. Should snap to right. | 1144 // Move |window| one pixel to the left of |window2|. Should snap to right. |
(...skipping 26 matching lines...) Expand all Loading... |
1181 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y + 1), 0); | 1171 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y + 1), 0); |
1182 expected.set_y(attach_y + initial_y); | 1172 expected.set_y(attach_y + initial_y); |
1183 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); | 1173 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); |
1184 | 1174 |
1185 // Moving down further should move the window. | 1175 // Moving down further should move the window. |
1186 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y + 18), 0); | 1176 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y + 18), 0); |
1187 expected.set_y(attach_y + initial_y + 18); | 1177 expected.set_y(attach_y + initial_y + 18); |
1188 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); | 1178 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); |
1189 } | 1179 } |
1190 | 1180 |
1191 TEST_P(WorkspaceWindowResizerTest, CtrlDragResizeToExactPosition) { | 1181 TEST_F(WorkspaceWindowResizerTest, CtrlDragResizeToExactPosition) { |
1192 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 1182 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
1193 std::unique_ptr<WindowResizer> resizer( | 1183 std::unique_ptr<WindowResizer> resizer( |
1194 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); | 1184 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
1195 ASSERT_TRUE(resizer.get()); | 1185 ASSERT_TRUE(resizer.get()); |
1196 // Resize the right bottom to add 10 in width, 12 in height. | 1186 // Resize the right bottom to add 10 in width, 12 in height. |
1197 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), ui::EF_CONTROL_DOWN); | 1187 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), ui::EF_CONTROL_DOWN); |
1198 // Both bottom and right sides to resize to exact size requested. | 1188 // Both bottom and right sides to resize to exact size requested. |
1199 EXPECT_EQ("96,112 330x172", window_->bounds().ToString()); | 1189 EXPECT_EQ("96,112 330x172", window_->bounds().ToString()); |
1200 } | 1190 } |
1201 | 1191 |
1202 // Verifies that a dragged, non-snapped window will clear restore bounds. | 1192 // Verifies that a dragged, non-snapped window will clear restore bounds. |
1203 TEST_P(WorkspaceWindowResizerTest, RestoreClearedOnResize) { | 1193 TEST_F(WorkspaceWindowResizerTest, RestoreClearedOnResize) { |
1204 window_->SetBounds(gfx::Rect(10, 10, 100, 100)); | 1194 window_->SetBounds(gfx::Rect(10, 10, 100, 100)); |
1205 wm::WindowState* window_state = wm::GetWindowState(window_.get()); | 1195 wm::WindowState* window_state = wm::GetWindowState(window_.get()); |
1206 window_state->SetRestoreBoundsInScreen(gfx::Rect(50, 50, 50, 50)); | 1196 window_state->SetRestoreBoundsInScreen(gfx::Rect(50, 50, 50, 50)); |
1207 std::unique_ptr<WindowResizer> resizer( | 1197 std::unique_ptr<WindowResizer> resizer( |
1208 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); | 1198 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
1209 ASSERT_TRUE(resizer.get()); | 1199 ASSERT_TRUE(resizer.get()); |
1210 // Drag the window to new position by adding (20, 30) to original point, | 1200 // Drag the window to new position by adding (20, 30) to original point, |
1211 // the original restore bound should be cleared. | 1201 // the original restore bound should be cleared. |
1212 resizer->Drag(CalculateDragPoint(*resizer, 20, 30), 0); | 1202 resizer->Drag(CalculateDragPoint(*resizer, 20, 30), 0); |
1213 resizer->CompleteDrag(); | 1203 resizer->CompleteDrag(); |
1214 EXPECT_EQ("10,10 120x130", window_->bounds().ToString()); | 1204 EXPECT_EQ("10,10 120x130", window_->bounds().ToString()); |
1215 EXPECT_FALSE(window_state->HasRestoreBounds()); | 1205 EXPECT_FALSE(window_state->HasRestoreBounds()); |
1216 } | 1206 } |
1217 | 1207 |
1218 // Verifies that a dragged window will restore to its pre-maximized size. | 1208 // Verifies that a dragged window will restore to its pre-maximized size. |
1219 TEST_P(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { | 1209 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { |
1220 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); | 1210 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); |
1221 wm::WindowState* window_state = wm::GetWindowState(window_.get()); | 1211 wm::WindowState* window_state = wm::GetWindowState(window_.get()); |
1222 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); | 1212 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); |
1223 std::unique_ptr<WindowResizer> resizer( | 1213 std::unique_ptr<WindowResizer> resizer( |
1224 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 1214 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
1225 ASSERT_TRUE(resizer.get()); | 1215 ASSERT_TRUE(resizer.get()); |
1226 // Drag the window to new position by adding (10, 10) to original point, | 1216 // Drag the window to new position by adding (10, 10) to original point, |
1227 // the window should get restored. | 1217 // the window should get restored. |
1228 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); | 1218 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); |
1229 resizer->CompleteDrag(); | 1219 resizer->CompleteDrag(); |
1230 EXPECT_EQ("10,10 320x160", window_->bounds().ToString()); | 1220 EXPECT_EQ("10,10 320x160", window_->bounds().ToString()); |
1231 // The restore rectangle should get cleared as well. | 1221 // The restore rectangle should get cleared as well. |
1232 EXPECT_FALSE(window_state->HasRestoreBounds()); | 1222 EXPECT_FALSE(window_state->HasRestoreBounds()); |
1233 } | 1223 } |
1234 | 1224 |
1235 // Verifies that a dragged window will restore to its pre-maximized size. | 1225 // Verifies that a dragged window will restore to its pre-maximized size. |
1236 TEST_P(WorkspaceWindowResizerTest, RevertResizeOperation) { | 1226 TEST_F(WorkspaceWindowResizerTest, RevertResizeOperation) { |
1237 const gfx::Rect initial_bounds(0, 0, 200, 400); | 1227 const gfx::Rect initial_bounds(0, 0, 200, 400); |
1238 window_->SetBounds(initial_bounds); | 1228 window_->SetBounds(initial_bounds); |
1239 | 1229 |
1240 wm::WindowState* window_state = wm::GetWindowState(window_.get()); | 1230 wm::WindowState* window_state = wm::GetWindowState(window_.get()); |
1241 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); | 1231 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); |
1242 std::unique_ptr<WindowResizer> resizer( | 1232 std::unique_ptr<WindowResizer> resizer( |
1243 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 1233 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
1244 ASSERT_TRUE(resizer.get()); | 1234 ASSERT_TRUE(resizer.get()); |
1245 // Drag the window to new poistion by adding (180, 16) to original point, | 1235 // Drag the window to new poistion by adding (180, 16) to original point, |
1246 // the window should get restored. | 1236 // the window should get restored. |
1247 resizer->Drag(CalculateDragPoint(*resizer, 180, 16), 0); | 1237 resizer->Drag(CalculateDragPoint(*resizer, 180, 16), 0); |
1248 resizer->RevertDrag(); | 1238 resizer->RevertDrag(); |
1249 EXPECT_EQ(initial_bounds.ToString(), window_->bounds().ToString()); | 1239 EXPECT_EQ(initial_bounds.ToString(), window_->bounds().ToString()); |
1250 EXPECT_EQ("96,112 320x160", | 1240 EXPECT_EQ("96,112 320x160", |
1251 window_state->GetRestoreBoundsInScreen().ToString()); | 1241 window_state->GetRestoreBoundsInScreen().ToString()); |
1252 } | 1242 } |
1253 | 1243 |
1254 // Check that only usable sizes get returned by the resizer. | 1244 // Check that only usable sizes get returned by the resizer. |
1255 TEST_P(WorkspaceWindowResizerTest, MagneticallyAttach) { | 1245 TEST_F(WorkspaceWindowResizerTest, MagneticallyAttach) { |
1256 window_->SetBounds(gfx::Rect(10, 10, 20, 30)); | 1246 window_->SetBounds(gfx::Rect(10, 10, 20, 30)); |
1257 window2_->SetBounds(gfx::Rect(150, 160, 25, 20)); | 1247 window2_->SetBounds(gfx::Rect(150, 160, 25, 20)); |
1258 window2_->Show(); | 1248 window2_->Show(); |
1259 | 1249 |
1260 std::unique_ptr<WindowResizer> resizer( | 1250 std::unique_ptr<WindowResizer> resizer( |
1261 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 1251 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
1262 ASSERT_TRUE(resizer.get()); | 1252 ASSERT_TRUE(resizer.get()); |
1263 // Move |window| one pixel to the left of |window2|. Should snap to right and | 1253 // Move |window| one pixel to the left of |window2|. Should snap to right and |
1264 // top. | 1254 // top. |
1265 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0); | 1255 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0); |
1266 EXPECT_EQ("130,160 20x30", window_->bounds().ToString()); | 1256 EXPECT_EQ("130,160 20x30", window_->bounds().ToString()); |
1267 | 1257 |
1268 // Move |window| one pixel to the right of |window2|. Should snap to left and | 1258 // Move |window| one pixel to the right of |window2|. Should snap to left and |
1269 // top. | 1259 // top. |
1270 resizer->Drag(CalculateDragPoint(*resizer, 164, 145), 0); | 1260 resizer->Drag(CalculateDragPoint(*resizer, 164, 145), 0); |
1271 EXPECT_EQ("175,160 20x30", window_->bounds().ToString()); | 1261 EXPECT_EQ("175,160 20x30", window_->bounds().ToString()); |
1272 | 1262 |
1273 // Move |window| one pixel above |window2|. Should snap to top and left. | 1263 // Move |window| one pixel above |window2|. Should snap to top and left. |
1274 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); | 1264 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); |
1275 EXPECT_EQ("150,130 20x30", window_->bounds().ToString()); | 1265 EXPECT_EQ("150,130 20x30", window_->bounds().ToString()); |
1276 | 1266 |
1277 // Move |window| one pixel above the bottom of |window2|. Should snap to | 1267 // Move |window| one pixel above the bottom of |window2|. Should snap to |
1278 // bottom and left. | 1268 // bottom and left. |
1279 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); | 1269 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); |
1280 EXPECT_EQ("150,180 20x30", window_->bounds().ToString()); | 1270 EXPECT_EQ("150,180 20x30", window_->bounds().ToString()); |
1281 } | 1271 } |
1282 | 1272 |
1283 // The following variants verify magnetic snapping during resize when dragging a | 1273 // The following variants verify magnetic snapping during resize when dragging a |
1284 // particular edge. | 1274 // particular edge. |
1285 TEST_P(WorkspaceWindowResizerTest, MagneticallyResize_TOP) { | 1275 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOP) { |
1286 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1276 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1287 window2_->SetBounds(gfx::Rect(99, 179, 10, 20)); | 1277 window2_->SetBounds(gfx::Rect(99, 179, 10, 20)); |
1288 window2_->Show(); | 1278 window2_->Show(); |
1289 | 1279 |
1290 std::unique_ptr<WindowResizer> resizer( | 1280 std::unique_ptr<WindowResizer> resizer( |
1291 CreateResizerForTest(window_.get(), gfx::Point(), HTTOP)); | 1281 CreateResizerForTest(window_.get(), gfx::Point(), HTTOP)); |
1292 ASSERT_TRUE(resizer.get()); | 1282 ASSERT_TRUE(resizer.get()); |
1293 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1283 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1294 EXPECT_EQ("100,199 20x31", window_->bounds().ToString()); | 1284 EXPECT_EQ("100,199 20x31", window_->bounds().ToString()); |
1295 } | 1285 } |
1296 | 1286 |
1297 TEST_P(WorkspaceWindowResizerTest, MagneticallyResize_TOPLEFT) { | 1287 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPLEFT) { |
1298 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1288 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1299 window2_->SetBounds(gfx::Rect(99, 179, 10, 20)); | 1289 window2_->SetBounds(gfx::Rect(99, 179, 10, 20)); |
1300 window2_->Show(); | 1290 window2_->Show(); |
1301 | 1291 |
1302 { | 1292 { |
1303 std::unique_ptr<WindowResizer> resizer( | 1293 std::unique_ptr<WindowResizer> resizer( |
1304 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT)); | 1294 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT)); |
1305 ASSERT_TRUE(resizer.get()); | 1295 ASSERT_TRUE(resizer.get()); |
1306 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1296 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1307 EXPECT_EQ("99,199 21x31", window_->bounds().ToString()); | 1297 EXPECT_EQ("99,199 21x31", window_->bounds().ToString()); |
1308 resizer->RevertDrag(); | 1298 resizer->RevertDrag(); |
1309 } | 1299 } |
1310 | 1300 |
1311 { | 1301 { |
1312 window2_->SetBounds(gfx::Rect(88, 201, 10, 20)); | 1302 window2_->SetBounds(gfx::Rect(88, 201, 10, 20)); |
1313 std::unique_ptr<WindowResizer> resizer( | 1303 std::unique_ptr<WindowResizer> resizer( |
1314 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT)); | 1304 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT)); |
1315 ASSERT_TRUE(resizer.get()); | 1305 ASSERT_TRUE(resizer.get()); |
1316 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1306 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1317 EXPECT_EQ("98,201 22x29", window_->bounds().ToString()); | 1307 EXPECT_EQ("98,201 22x29", window_->bounds().ToString()); |
1318 resizer->RevertDrag(); | 1308 resizer->RevertDrag(); |
1319 } | 1309 } |
1320 } | 1310 } |
1321 | 1311 |
1322 TEST_P(WorkspaceWindowResizerTest, MagneticallyResize_TOPRIGHT) { | 1312 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPRIGHT) { |
1323 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1313 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1324 window2_->Show(); | 1314 window2_->Show(); |
1325 | 1315 |
1326 { | 1316 { |
1327 window2_->SetBounds(gfx::Rect(111, 179, 10, 20)); | 1317 window2_->SetBounds(gfx::Rect(111, 179, 10, 20)); |
1328 std::unique_ptr<WindowResizer> resizer( | 1318 std::unique_ptr<WindowResizer> resizer( |
1329 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT)); | 1319 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT)); |
1330 ASSERT_TRUE(resizer.get()); | 1320 ASSERT_TRUE(resizer.get()); |
1331 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1321 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1332 EXPECT_EQ("100,199 21x31", window_->bounds().ToString()); | 1322 EXPECT_EQ("100,199 21x31", window_->bounds().ToString()); |
1333 resizer->RevertDrag(); | 1323 resizer->RevertDrag(); |
1334 } | 1324 } |
1335 | 1325 |
1336 { | 1326 { |
1337 window2_->SetBounds(gfx::Rect(121, 199, 10, 20)); | 1327 window2_->SetBounds(gfx::Rect(121, 199, 10, 20)); |
1338 std::unique_ptr<WindowResizer> resizer( | 1328 std::unique_ptr<WindowResizer> resizer( |
1339 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT)); | 1329 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT)); |
1340 ASSERT_TRUE(resizer.get()); | 1330 ASSERT_TRUE(resizer.get()); |
1341 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1331 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1342 EXPECT_EQ("100,199 21x31", window_->bounds().ToString()); | 1332 EXPECT_EQ("100,199 21x31", window_->bounds().ToString()); |
1343 resizer->RevertDrag(); | 1333 resizer->RevertDrag(); |
1344 } | 1334 } |
1345 } | 1335 } |
1346 | 1336 |
1347 TEST_P(WorkspaceWindowResizerTest, MagneticallyResize_RIGHT) { | 1337 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_RIGHT) { |
1348 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1338 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1349 window2_->SetBounds(gfx::Rect(121, 199, 10, 20)); | 1339 window2_->SetBounds(gfx::Rect(121, 199, 10, 20)); |
1350 window2_->Show(); | 1340 window2_->Show(); |
1351 | 1341 |
1352 std::unique_ptr<WindowResizer> resizer( | 1342 std::unique_ptr<WindowResizer> resizer( |
1353 CreateResizerForTest(window_.get(), gfx::Point(), HTRIGHT)); | 1343 CreateResizerForTest(window_.get(), gfx::Point(), HTRIGHT)); |
1354 ASSERT_TRUE(resizer.get()); | 1344 ASSERT_TRUE(resizer.get()); |
1355 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1345 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1356 EXPECT_EQ("100,200 21x30", window_->bounds().ToString()); | 1346 EXPECT_EQ("100,200 21x30", window_->bounds().ToString()); |
1357 } | 1347 } |
1358 | 1348 |
1359 TEST_P(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMRIGHT) { | 1349 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMRIGHT) { |
1360 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1350 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1361 window2_->Show(); | 1351 window2_->Show(); |
1362 | 1352 |
1363 { | 1353 { |
1364 window2_->SetBounds(gfx::Rect(122, 212, 10, 20)); | 1354 window2_->SetBounds(gfx::Rect(122, 212, 10, 20)); |
1365 std::unique_ptr<WindowResizer> resizer( | 1355 std::unique_ptr<WindowResizer> resizer( |
1366 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); | 1356 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
1367 ASSERT_TRUE(resizer.get()); | 1357 ASSERT_TRUE(resizer.get()); |
1368 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1358 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1369 EXPECT_EQ("100,200 22x32", window_->bounds().ToString()); | 1359 EXPECT_EQ("100,200 22x32", window_->bounds().ToString()); |
1370 resizer->RevertDrag(); | 1360 resizer->RevertDrag(); |
1371 } | 1361 } |
1372 | 1362 |
1373 { | 1363 { |
1374 window2_->SetBounds(gfx::Rect(111, 233, 10, 20)); | 1364 window2_->SetBounds(gfx::Rect(111, 233, 10, 20)); |
1375 std::unique_ptr<WindowResizer> resizer( | 1365 std::unique_ptr<WindowResizer> resizer( |
1376 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); | 1366 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
1377 ASSERT_TRUE(resizer.get()); | 1367 ASSERT_TRUE(resizer.get()); |
1378 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1368 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1379 EXPECT_EQ("100,200 21x33", window_->bounds().ToString()); | 1369 EXPECT_EQ("100,200 21x33", window_->bounds().ToString()); |
1380 resizer->RevertDrag(); | 1370 resizer->RevertDrag(); |
1381 } | 1371 } |
1382 } | 1372 } |
1383 | 1373 |
1384 TEST_P(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOM) { | 1374 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOM) { |
1385 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1375 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1386 window2_->SetBounds(gfx::Rect(111, 233, 10, 20)); | 1376 window2_->SetBounds(gfx::Rect(111, 233, 10, 20)); |
1387 window2_->Show(); | 1377 window2_->Show(); |
1388 | 1378 |
1389 std::unique_ptr<WindowResizer> resizer( | 1379 std::unique_ptr<WindowResizer> resizer( |
1390 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOM)); | 1380 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOM)); |
1391 ASSERT_TRUE(resizer.get()); | 1381 ASSERT_TRUE(resizer.get()); |
1392 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1382 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1393 EXPECT_EQ("100,200 20x33", window_->bounds().ToString()); | 1383 EXPECT_EQ("100,200 20x33", window_->bounds().ToString()); |
1394 } | 1384 } |
1395 | 1385 |
1396 TEST_P(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMLEFT) { | 1386 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMLEFT) { |
1397 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1387 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1398 window2_->Show(); | 1388 window2_->Show(); |
1399 | 1389 |
1400 { | 1390 { |
1401 window2_->SetBounds(gfx::Rect(99, 231, 10, 20)); | 1391 window2_->SetBounds(gfx::Rect(99, 231, 10, 20)); |
1402 std::unique_ptr<WindowResizer> resizer( | 1392 std::unique_ptr<WindowResizer> resizer( |
1403 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT)); | 1393 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT)); |
1404 ASSERT_TRUE(resizer.get()); | 1394 ASSERT_TRUE(resizer.get()); |
1405 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1395 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1406 EXPECT_EQ("99,200 21x31", window_->bounds().ToString()); | 1396 EXPECT_EQ("99,200 21x31", window_->bounds().ToString()); |
1407 resizer->RevertDrag(); | 1397 resizer->RevertDrag(); |
1408 } | 1398 } |
1409 | 1399 |
1410 { | 1400 { |
1411 window2_->SetBounds(gfx::Rect(89, 209, 10, 20)); | 1401 window2_->SetBounds(gfx::Rect(89, 209, 10, 20)); |
1412 std::unique_ptr<WindowResizer> resizer( | 1402 std::unique_ptr<WindowResizer> resizer( |
1413 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT)); | 1403 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT)); |
1414 ASSERT_TRUE(resizer.get()); | 1404 ASSERT_TRUE(resizer.get()); |
1415 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1405 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1416 EXPECT_EQ("99,200 21x29", window_->bounds().ToString()); | 1406 EXPECT_EQ("99,200 21x29", window_->bounds().ToString()); |
1417 resizer->RevertDrag(); | 1407 resizer->RevertDrag(); |
1418 } | 1408 } |
1419 } | 1409 } |
1420 | 1410 |
1421 TEST_P(WorkspaceWindowResizerTest, MagneticallyResize_LEFT) { | 1411 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_LEFT) { |
1422 window2_->SetBounds(gfx::Rect(89, 209, 10, 20)); | 1412 window2_->SetBounds(gfx::Rect(89, 209, 10, 20)); |
1423 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1413 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1424 window2_->Show(); | 1414 window2_->Show(); |
1425 | 1415 |
1426 std::unique_ptr<WindowResizer> resizer( | 1416 std::unique_ptr<WindowResizer> resizer( |
1427 CreateResizerForTest(window_.get(), gfx::Point(), HTLEFT)); | 1417 CreateResizerForTest(window_.get(), gfx::Point(), HTLEFT)); |
1428 ASSERT_TRUE(resizer.get()); | 1418 ASSERT_TRUE(resizer.get()); |
1429 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1419 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
1430 EXPECT_EQ("99,200 21x30", window_->bounds().ToString()); | 1420 EXPECT_EQ("99,200 21x30", window_->bounds().ToString()); |
1431 } | 1421 } |
1432 | 1422 |
1433 // Test that the user moved window flag is getting properly set. | 1423 // Test that the user moved window flag is getting properly set. |
1434 TEST_P(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) { | 1424 TEST_F(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) { |
1435 window_->SetBounds(gfx::Rect(0, 50, 400, 200)); | 1425 window_->SetBounds(gfx::Rect(0, 50, 400, 200)); |
1436 window_->SetProperty(aura::client::kResizeBehaviorKey, | 1426 window_->SetProperty(aura::client::kResizeBehaviorKey, |
1437 ui::mojom::kResizeBehaviorCanMaximize); | 1427 ui::mojom::kResizeBehaviorCanMaximize); |
1438 | 1428 |
1439 std::vector<aura::Window*> no_attached_windows; | 1429 std::vector<aura::Window*> no_attached_windows; |
1440 // Check that an abort doesn't change anything. | 1430 // Check that an abort doesn't change anything. |
1441 { | 1431 { |
1442 std::unique_ptr<WindowResizer> resizer( | 1432 std::unique_ptr<WindowResizer> resizer( |
1443 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 1433 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
1444 ASSERT_TRUE(resizer.get()); | 1434 ASSERT_TRUE(resizer.get()); |
(...skipping 12 matching lines...) Expand all Loading... |
1457 ASSERT_TRUE(resizer.get()); | 1447 ASSERT_TRUE(resizer.get()); |
1458 // Move it 100 to the bottom. | 1448 // Move it 100 to the bottom. |
1459 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); | 1449 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); |
1460 EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); | 1450 EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); |
1461 resizer->CompleteDrag(); | 1451 resizer->CompleteDrag(); |
1462 EXPECT_TRUE(wm::GetWindowState(window_.get())->bounds_changed_by_user()); | 1452 EXPECT_TRUE(wm::GetWindowState(window_.get())->bounds_changed_by_user()); |
1463 } | 1453 } |
1464 } | 1454 } |
1465 | 1455 |
1466 // Test that a window with a specified max size doesn't exceed it when dragged. | 1456 // Test that a window with a specified max size doesn't exceed it when dragged. |
1467 TEST_P(WorkspaceWindowResizerTest, TestMaxSizeEnforced) { | 1457 TEST_F(WorkspaceWindowResizerTest, TestMaxSizeEnforced) { |
1468 window_->SetBounds(gfx::Rect(0, 0, 400, 300)); | 1458 window_->SetBounds(gfx::Rect(0, 0, 400, 300)); |
1469 delegate_.set_max_size(gfx::Size(401, 301)); | 1459 delegate_.set_max_size(gfx::Size(401, 301)); |
1470 | 1460 |
1471 std::unique_ptr<WindowResizer> resizer( | 1461 std::unique_ptr<WindowResizer> resizer( |
1472 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); | 1462 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
1473 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); | 1463 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); |
1474 EXPECT_EQ(401, window_->bounds().width()); | 1464 EXPECT_EQ(401, window_->bounds().width()); |
1475 EXPECT_EQ(301, window_->bounds().height()); | 1465 EXPECT_EQ(301, window_->bounds().height()); |
1476 } | 1466 } |
1477 | 1467 |
1478 // Test that a window with a specified max width doesn't restrict its height. | 1468 // Test that a window with a specified max width doesn't restrict its height. |
1479 TEST_P(WorkspaceWindowResizerTest, TestPartialMaxSizeEnforced) { | 1469 TEST_F(WorkspaceWindowResizerTest, TestPartialMaxSizeEnforced) { |
1480 window_->SetBounds(gfx::Rect(0, 0, 400, 300)); | 1470 window_->SetBounds(gfx::Rect(0, 0, 400, 300)); |
1481 delegate_.set_max_size(gfx::Size(401, 0)); | 1471 delegate_.set_max_size(gfx::Size(401, 0)); |
1482 | 1472 |
1483 std::unique_ptr<WindowResizer> resizer( | 1473 std::unique_ptr<WindowResizer> resizer( |
1484 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); | 1474 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
1485 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); | 1475 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); |
1486 EXPECT_EQ(401, window_->bounds().width()); | 1476 EXPECT_EQ(401, window_->bounds().width()); |
1487 EXPECT_EQ(302, window_->bounds().height()); | 1477 EXPECT_EQ(302, window_->bounds().height()); |
1488 } | 1478 } |
1489 | 1479 |
1490 // Test that a window with a specified max size can't be snapped. | 1480 // Test that a window with a specified max size can't be snapped. |
1491 TEST_P(WorkspaceWindowResizerTest, PhantomSnapMaxSize) { | 1481 TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) { |
1492 // Make the window snappable by making it resizable and maximizable. | 1482 // Make the window snappable by making it resizable and maximizable. |
1493 window_->SetProperty(aura::client::kResizeBehaviorKey, | 1483 window_->SetProperty(aura::client::kResizeBehaviorKey, |
1494 ui::mojom::kResizeBehaviorCanResize | | 1484 ui::mojom::kResizeBehaviorCanResize | |
1495 ui::mojom::kResizeBehaviorCanMaximize); | 1485 ui::mojom::kResizeBehaviorCanMaximize); |
1496 | 1486 |
1497 // Enable docking for this test. | 1487 // Enable docking for this test. |
1498 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1488 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
1499 ash::switches::kAshEnableDockedWindows); | 1489 ash::switches::kAshEnableDockedWindows); |
1500 | 1490 |
1501 { | 1491 { |
(...skipping 29 matching lines...) Expand all Loading... |
1531 delegate_.set_min_size(gfx::Size(400, 200)); | 1521 delegate_.set_min_size(gfx::Size(400, 200)); |
1532 | 1522 |
1533 std::unique_ptr<WindowResizer> resizer( | 1523 std::unique_ptr<WindowResizer> resizer( |
1534 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 1524 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
1535 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); | 1525 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); |
1536 EXPECT_FALSE(snap_phantom_window_controller()); | 1526 EXPECT_FALSE(snap_phantom_window_controller()); |
1537 resizer->RevertDrag(); | 1527 resizer->RevertDrag(); |
1538 } | 1528 } |
1539 } | 1529 } |
1540 | 1530 |
1541 TEST_P(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { | 1531 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { |
1542 UpdateDisplay("600x800"); | 1532 UpdateDisplay("600x800"); |
1543 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1533 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1544 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1534 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1545 | 1535 |
1546 // Four 100x100 windows flush against eachother, starting at 100,100. | 1536 // Four 100x100 windows flush against eachother, starting at 100,100. |
1547 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1537 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
1548 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1538 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1549 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1539 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1550 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); | 1540 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); |
1551 delegate2_.set_max_size(gfx::Size(101, 0)); | 1541 delegate2_.set_max_size(gfx::Size(101, 0)); |
(...skipping 10 matching lines...) Expand all Loading... |
1562 // w2 will hit its max size straight away, and in doing so will leave extra | 1552 // w2 will hit its max size straight away, and in doing so will leave extra |
1563 // pixels that a naive implementation may award to the rightmost window. A | 1553 // pixels that a naive implementation may award to the rightmost window. A |
1564 // fair implementation will give 25 pixels to each of the other windows. | 1554 // fair implementation will give 25 pixels to each of the other windows. |
1565 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); | 1555 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); |
1566 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); | 1556 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); |
1567 EXPECT_EQ("149,100 101x100", window2_->bounds().ToString()); | 1557 EXPECT_EQ("149,100 101x100", window2_->bounds().ToString()); |
1568 EXPECT_EQ("250,100 125x100", window3_->bounds().ToString()); | 1558 EXPECT_EQ("250,100 125x100", window3_->bounds().ToString()); |
1569 EXPECT_EQ("375,100 125x100", window4_->bounds().ToString()); | 1559 EXPECT_EQ("375,100 125x100", window4_->bounds().ToString()); |
1570 } | 1560 } |
1571 | 1561 |
1572 TEST_P(WorkspaceWindowResizerTest, DontExceedMaxWidth) { | 1562 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxWidth) { |
1573 UpdateDisplay("600x800"); | 1563 UpdateDisplay("600x800"); |
1574 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1564 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1575 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1565 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1576 | 1566 |
1577 // Four 100x100 windows flush against eachother, starting at 100,100. | 1567 // Four 100x100 windows flush against eachother, starting at 100,100. |
1578 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1568 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
1579 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1569 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1580 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1570 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1581 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); | 1571 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); |
1582 delegate2_.set_max_size(gfx::Size(101, 0)); | 1572 delegate2_.set_max_size(gfx::Size(101, 0)); |
1583 delegate3_.set_max_size(gfx::Size(101, 0)); | 1573 delegate3_.set_max_size(gfx::Size(101, 0)); |
1584 | 1574 |
1585 std::vector<aura::Window*> windows; | 1575 std::vector<aura::Window*> windows; |
1586 windows.push_back(window2_.get()); | 1576 windows.push_back(window2_.get()); |
1587 windows.push_back(window3_.get()); | 1577 windows.push_back(window3_.get()); |
1588 windows.push_back(window4_.get()); | 1578 windows.push_back(window4_.get()); |
1589 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1579 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1590 window_.get(), gfx::Point(), HTRIGHT, | 1580 window_.get(), gfx::Point(), HTRIGHT, |
1591 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1581 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1592 ASSERT_TRUE(resizer.get()); | 1582 ASSERT_TRUE(resizer.get()); |
1593 // Move it 52 to the left, which should contract w1 and expand w2-4. | 1583 // Move it 52 to the left, which should contract w1 and expand w2-4. |
1594 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); | 1584 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); |
1595 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); | 1585 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); |
1596 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); | 1586 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); |
1597 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); | 1587 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); |
1598 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); | 1588 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); |
1599 } | 1589 } |
1600 | 1590 |
1601 TEST_P(WorkspaceWindowResizerTest, DontExceedMaxHeight) { | 1591 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) { |
1602 UpdateDisplay("600x800"); | 1592 UpdateDisplay("600x800"); |
1603 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1593 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1604 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1594 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1605 | 1595 |
1606 // Four 100x100 windows flush against eachother, starting at 100,100. | 1596 // Four 100x100 windows flush against eachother, starting at 100,100. |
1607 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1597 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
1608 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1598 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
1609 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1599 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
1610 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1600 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
1611 delegate2_.set_max_size(gfx::Size(0, 101)); | 1601 delegate2_.set_max_size(gfx::Size(0, 101)); |
1612 delegate3_.set_max_size(gfx::Size(0, 101)); | 1602 delegate3_.set_max_size(gfx::Size(0, 101)); |
1613 | 1603 |
1614 std::vector<aura::Window*> windows; | 1604 std::vector<aura::Window*> windows; |
1615 windows.push_back(window2_.get()); | 1605 windows.push_back(window2_.get()); |
1616 windows.push_back(window3_.get()); | 1606 windows.push_back(window3_.get()); |
1617 windows.push_back(window4_.get()); | 1607 windows.push_back(window4_.get()); |
1618 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1608 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1619 window_.get(), gfx::Point(), HTBOTTOM, | 1609 window_.get(), gfx::Point(), HTBOTTOM, |
1620 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1610 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1621 ASSERT_TRUE(resizer.get()); | 1611 ASSERT_TRUE(resizer.get()); |
1622 // Move it 52 up, which should contract w1 and expand w2-4. | 1612 // Move it 52 up, which should contract w1 and expand w2-4. |
1623 resizer->Drag(CalculateDragPoint(*resizer, 0, -52), 0); | 1613 resizer->Drag(CalculateDragPoint(*resizer, 0, -52), 0); |
1624 EXPECT_EQ("100,100 100x48", window_->bounds().ToString()); | 1614 EXPECT_EQ("100,100 100x48", window_->bounds().ToString()); |
1625 EXPECT_EQ("100,148 100x101", window2_->bounds().ToString()); | 1615 EXPECT_EQ("100,148 100x101", window2_->bounds().ToString()); |
1626 EXPECT_EQ("100,249 100x101", window3_->bounds().ToString()); | 1616 EXPECT_EQ("100,249 100x101", window3_->bounds().ToString()); |
1627 EXPECT_EQ("100,350 100x150", window4_->bounds().ToString()); | 1617 EXPECT_EQ("100,350 100x150", window4_->bounds().ToString()); |
1628 } | 1618 } |
1629 | 1619 |
1630 TEST_P(WorkspaceWindowResizerTest, DontExceedMinHeight) { | 1620 TEST_F(WorkspaceWindowResizerTest, DontExceedMinHeight) { |
1631 UpdateDisplay("600x500"); | 1621 UpdateDisplay("600x500"); |
1632 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1622 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1633 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1623 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1634 | 1624 |
1635 // Four 100x100 windows flush against eachother, starting at 100,100. | 1625 // Four 100x100 windows flush against eachother, starting at 100,100. |
1636 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1626 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
1637 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1627 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
1638 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1628 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
1639 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1629 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
1640 delegate2_.set_min_size(gfx::Size(0, 99)); | 1630 delegate2_.set_min_size(gfx::Size(0, 99)); |
1641 delegate3_.set_min_size(gfx::Size(0, 99)); | 1631 delegate3_.set_min_size(gfx::Size(0, 99)); |
1642 | 1632 |
1643 std::vector<aura::Window*> windows; | 1633 std::vector<aura::Window*> windows; |
1644 windows.push_back(window2_.get()); | 1634 windows.push_back(window2_.get()); |
1645 windows.push_back(window3_.get()); | 1635 windows.push_back(window3_.get()); |
1646 windows.push_back(window4_.get()); | 1636 windows.push_back(window4_.get()); |
1647 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1637 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1648 window_.get(), gfx::Point(), HTBOTTOM, | 1638 window_.get(), gfx::Point(), HTBOTTOM, |
1649 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1639 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1650 ASSERT_TRUE(resizer.get()); | 1640 ASSERT_TRUE(resizer.get()); |
1651 // Move it 52 down, which should expand w1 and contract w2-4. | 1641 // Move it 52 down, which should expand w1 and contract w2-4. |
1652 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); | 1642 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); |
1653 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); | 1643 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); |
1654 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); | 1644 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); |
1655 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); | 1645 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); |
1656 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); | 1646 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); |
1657 } | 1647 } |
1658 | 1648 |
1659 TEST_P(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { | 1649 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { |
1660 UpdateDisplay("600x800"); | 1650 UpdateDisplay("600x800"); |
1661 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1651 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1662 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1652 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1663 | 1653 |
1664 // Three 100x100 windows flush against eachother, starting at 100,100. | 1654 // Three 100x100 windows flush against eachother, starting at 100,100. |
1665 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1655 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
1666 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1656 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1667 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1657 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1668 delegate3_.set_max_size(gfx::Size(101, 0)); | 1658 delegate3_.set_max_size(gfx::Size(101, 0)); |
1669 | 1659 |
1670 std::vector<aura::Window*> windows; | 1660 std::vector<aura::Window*> windows; |
1671 windows.push_back(window2_.get()); | 1661 windows.push_back(window2_.get()); |
1672 windows.push_back(window3_.get()); | 1662 windows.push_back(window3_.get()); |
1673 windows.push_back(window4_.get()); | 1663 windows.push_back(window4_.get()); |
1674 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1664 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1675 window_.get(), gfx::Point(), HTRIGHT, | 1665 window_.get(), gfx::Point(), HTRIGHT, |
1676 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1666 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1677 ASSERT_TRUE(resizer.get()); | 1667 ASSERT_TRUE(resizer.get()); |
1678 // Move it 51 to the left, which should contract w1 and expand w2-3. | 1668 // Move it 51 to the left, which should contract w1 and expand w2-3. |
1679 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); | 1669 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); |
1680 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); | 1670 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); |
1681 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); | 1671 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); |
1682 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1672 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
1683 } | 1673 } |
1684 | 1674 |
1685 TEST_P(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { | 1675 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { |
1686 UpdateDisplay("600x800"); | 1676 UpdateDisplay("600x800"); |
1687 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1677 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1688 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1678 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1689 | 1679 |
1690 // Three 100x100 windows flush against eachother, starting at 100,100. | 1680 // Three 100x100 windows flush against eachother, starting at 100,100. |
1691 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1681 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
1692 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1682 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1693 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1683 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1694 delegate2_.set_max_size(gfx::Size(101, 0)); | 1684 delegate2_.set_max_size(gfx::Size(101, 0)); |
1695 delegate3_.set_max_size(gfx::Size(101, 0)); | 1685 delegate3_.set_max_size(gfx::Size(101, 0)); |
1696 | 1686 |
1697 std::vector<aura::Window*> windows; | 1687 std::vector<aura::Window*> windows; |
1698 windows.push_back(window2_.get()); | 1688 windows.push_back(window2_.get()); |
1699 windows.push_back(window3_.get()); | 1689 windows.push_back(window3_.get()); |
1700 windows.push_back(window4_.get()); | 1690 windows.push_back(window4_.get()); |
1701 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1691 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1702 window_.get(), gfx::Point(), HTRIGHT, | 1692 window_.get(), gfx::Point(), HTRIGHT, |
1703 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1693 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1704 ASSERT_TRUE(resizer.get()); | 1694 ASSERT_TRUE(resizer.get()); |
1705 // Move it 52 to the left, which should contract w1 and expand and move w2-3. | 1695 // Move it 52 to the left, which should contract w1 and expand and move w2-3. |
1706 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); | 1696 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); |
1707 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); | 1697 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); |
1708 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); | 1698 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); |
1709 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); | 1699 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); |
1710 } | 1700 } |
1711 | 1701 |
1712 TEST_P(WorkspaceWindowResizerTest, MainWindowHonoursMaxWidth) { | 1702 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMaxWidth) { |
1713 UpdateDisplay("400x800"); | 1703 UpdateDisplay("400x800"); |
1714 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1704 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1715 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1705 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1716 | 1706 |
1717 // Three 100x100 windows flush against eachother, starting at 100,100. | 1707 // Three 100x100 windows flush against eachother, starting at 100,100. |
1718 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1708 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
1719 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1709 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1720 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1710 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1721 delegate_.set_max_size(gfx::Size(102, 0)); | 1711 delegate_.set_max_size(gfx::Size(102, 0)); |
1722 | 1712 |
1723 std::vector<aura::Window*> windows; | 1713 std::vector<aura::Window*> windows; |
1724 windows.push_back(window2_.get()); | 1714 windows.push_back(window2_.get()); |
1725 windows.push_back(window3_.get()); | 1715 windows.push_back(window3_.get()); |
1726 windows.push_back(window4_.get()); | 1716 windows.push_back(window4_.get()); |
1727 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1717 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1728 window_.get(), gfx::Point(), HTRIGHT, | 1718 window_.get(), gfx::Point(), HTRIGHT, |
1729 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1719 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1730 ASSERT_TRUE(resizer.get()); | 1720 ASSERT_TRUE(resizer.get()); |
1731 // Move it 50 to the right, which should expand w1 and contract w2-3, as they | 1721 // Move it 50 to the right, which should expand w1 and contract w2-3, as they |
1732 // won't fit in the root window in their original sizes. | 1722 // won't fit in the root window in their original sizes. |
1733 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); | 1723 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); |
1734 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); | 1724 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); |
1735 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); | 1725 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); |
1736 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); | 1726 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); |
1737 } | 1727 } |
1738 | 1728 |
1739 TEST_P(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { | 1729 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { |
1740 UpdateDisplay("400x800"); | 1730 UpdateDisplay("400x800"); |
1741 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1731 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1742 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1732 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1743 | 1733 |
1744 // Three 100x100 windows flush against eachother, starting at 100,100. | 1734 // Three 100x100 windows flush against eachother, starting at 100,100. |
1745 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1735 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
1746 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1736 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1747 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1737 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1748 delegate_.set_min_size(gfx::Size(98, 0)); | 1738 delegate_.set_min_size(gfx::Size(98, 0)); |
1749 | 1739 |
1750 std::vector<aura::Window*> windows; | 1740 std::vector<aura::Window*> windows; |
1751 windows.push_back(window2_.get()); | 1741 windows.push_back(window2_.get()); |
1752 windows.push_back(window3_.get()); | 1742 windows.push_back(window3_.get()); |
1753 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1743 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1754 window_.get(), gfx::Point(), HTRIGHT, | 1744 window_.get(), gfx::Point(), HTRIGHT, |
1755 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1745 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1756 ASSERT_TRUE(resizer.get()); | 1746 ASSERT_TRUE(resizer.get()); |
1757 // Move it 50 to the left, which should contract w1 and expand w2-3. | 1747 // Move it 50 to the left, which should contract w1 and expand w2-3. |
1758 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); | 1748 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); |
1759 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); | 1749 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); |
1760 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); | 1750 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); |
1761 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1751 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
1762 } | 1752 } |
1763 | 1753 |
1764 // The following variants test that windows are resized correctly to the edges | 1754 // The following variants test that windows are resized correctly to the edges |
1765 // of the screen using touch, when touch point is off of the window border. | 1755 // of the screen using touch, when touch point is off of the window border. |
1766 TEST_P(WorkspaceWindowResizerTest, TouchResizeToEdge_RIGHT) { | 1756 TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_RIGHT) { |
1767 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1757 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
1768 | 1758 |
1769 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTRIGHT); | 1759 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTRIGHT); |
1770 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), | 1760 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), |
1771 touch_resize_window_->bounds().ToString()); | 1761 touch_resize_window_->bounds().ToString()); |
1772 | 1762 |
1773 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1763 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1774 touch_resize_window_.get()); | 1764 touch_resize_window_.get()); |
1775 | 1765 |
1776 // Drag out of the right border a bit and check if the border is aligned with | 1766 // Drag out of the right border a bit and check if the border is aligned with |
(...skipping 10 matching lines...) Expand all Loading... |
1787 EXPECT_EQ(gfx::Rect(100, 100, 660, kRootHeight - 200).ToString(), | 1777 EXPECT_EQ(gfx::Rect(100, 100, 660, kRootHeight - 200).ToString(), |
1788 touch_resize_window_->bounds().ToString()); | 1778 touch_resize_window_->bounds().ToString()); |
1789 // Drag even more to snap to the edge. | 1779 // Drag even more to snap to the edge. |
1790 generator.GestureScrollSequence(gfx::Point(760, kRootHeight / 2), | 1780 generator.GestureScrollSequence(gfx::Point(760, kRootHeight / 2), |
1791 gfx::Point(775, kRootHeight / 2), | 1781 gfx::Point(775, kRootHeight / 2), |
1792 base::TimeDelta::FromMilliseconds(10), 5); | 1782 base::TimeDelta::FromMilliseconds(10), 5); |
1793 EXPECT_EQ(gfx::Rect(100, 100, 700, kRootHeight - 200).ToString(), | 1783 EXPECT_EQ(gfx::Rect(100, 100, 700, kRootHeight - 200).ToString(), |
1794 touch_resize_window_->bounds().ToString()); | 1784 touch_resize_window_->bounds().ToString()); |
1795 } | 1785 } |
1796 | 1786 |
1797 TEST_P(WorkspaceWindowResizerTest, TouchResizeToEdge_LEFT) { | 1787 TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_LEFT) { |
1798 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1788 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
1799 | 1789 |
1800 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTLEFT); | 1790 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTLEFT); |
1801 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), | 1791 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), |
1802 touch_resize_window_->bounds().ToString()); | 1792 touch_resize_window_->bounds().ToString()); |
1803 | 1793 |
1804 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1794 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1805 touch_resize_window_.get()); | 1795 touch_resize_window_.get()); |
1806 | 1796 |
1807 // Drag out of the left border a bit and check if the border is aligned with | 1797 // Drag out of the left border a bit and check if the border is aligned with |
(...skipping 10 matching lines...) Expand all Loading... |
1818 EXPECT_EQ(gfx::Rect(40, 100, 660, kRootHeight - 200).ToString(), | 1808 EXPECT_EQ(gfx::Rect(40, 100, 660, kRootHeight - 200).ToString(), |
1819 touch_resize_window_->bounds().ToString()); | 1809 touch_resize_window_->bounds().ToString()); |
1820 // Drag even more to snap to the edge. | 1810 // Drag even more to snap to the edge. |
1821 generator.GestureScrollSequence(gfx::Point(40, kRootHeight / 2), | 1811 generator.GestureScrollSequence(gfx::Point(40, kRootHeight / 2), |
1822 gfx::Point(25, kRootHeight / 2), | 1812 gfx::Point(25, kRootHeight / 2), |
1823 base::TimeDelta::FromMilliseconds(10), 5); | 1813 base::TimeDelta::FromMilliseconds(10), 5); |
1824 EXPECT_EQ(gfx::Rect(0, 100, 700, kRootHeight - 200).ToString(), | 1814 EXPECT_EQ(gfx::Rect(0, 100, 700, kRootHeight - 200).ToString(), |
1825 touch_resize_window_->bounds().ToString()); | 1815 touch_resize_window_->bounds().ToString()); |
1826 } | 1816 } |
1827 | 1817 |
1828 TEST_P(WorkspaceWindowResizerTest, TouchResizeToEdge_TOP) { | 1818 TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_TOP) { |
1829 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1819 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
1830 | 1820 |
1831 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTTOP); | 1821 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTTOP); |
1832 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), | 1822 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), |
1833 touch_resize_window_->bounds().ToString()); | 1823 touch_resize_window_->bounds().ToString()); |
1834 | 1824 |
1835 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1825 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1836 touch_resize_window_.get()); | 1826 touch_resize_window_.get()); |
1837 | 1827 |
1838 // Drag out of the top border a bit and check if the border is aligned with | 1828 // Drag out of the top border a bit and check if the border is aligned with |
1839 // the touch point. | 1829 // the touch point. |
1840 generator.GestureScrollSequence(gfx::Point(400, 85), gfx::Point(400, 75), | 1830 generator.GestureScrollSequence(gfx::Point(400, 85), gfx::Point(400, 75), |
1841 base::TimeDelta::FromMilliseconds(10), 5); | 1831 base::TimeDelta::FromMilliseconds(10), 5); |
1842 EXPECT_EQ(gfx::Rect(100, 75, 600, kRootHeight - 175).ToString(), | 1832 EXPECT_EQ(gfx::Rect(100, 75, 600, kRootHeight - 175).ToString(), |
1843 touch_resize_window_->bounds().ToString()); | 1833 touch_resize_window_->bounds().ToString()); |
1844 // Drag more, but stop before being snapped to the edge. | 1834 // Drag more, but stop before being snapped to the edge. |
1845 generator.GestureScrollSequence(gfx::Point(400, 75), gfx::Point(400, 40), | 1835 generator.GestureScrollSequence(gfx::Point(400, 75), gfx::Point(400, 40), |
1846 base::TimeDelta::FromMilliseconds(10), 5); | 1836 base::TimeDelta::FromMilliseconds(10), 5); |
1847 EXPECT_EQ(gfx::Rect(100, 40, 600, kRootHeight - 140).ToString(), | 1837 EXPECT_EQ(gfx::Rect(100, 40, 600, kRootHeight - 140).ToString(), |
1848 touch_resize_window_->bounds().ToString()); | 1838 touch_resize_window_->bounds().ToString()); |
1849 // Drag even more to snap to the edge. | 1839 // Drag even more to snap to the edge. |
1850 generator.GestureScrollSequence(gfx::Point(400, 40), gfx::Point(400, 25), | 1840 generator.GestureScrollSequence(gfx::Point(400, 40), gfx::Point(400, 25), |
1851 base::TimeDelta::FromMilliseconds(10), 5); | 1841 base::TimeDelta::FromMilliseconds(10), 5); |
1852 EXPECT_EQ(gfx::Rect(100, 0, 600, kRootHeight - 100).ToString(), | 1842 EXPECT_EQ(gfx::Rect(100, 0, 600, kRootHeight - 100).ToString(), |
1853 touch_resize_window_->bounds().ToString()); | 1843 touch_resize_window_->bounds().ToString()); |
1854 } | 1844 } |
1855 | 1845 |
1856 TEST_P(WorkspaceWindowResizerTest, TouchResizeToEdge_BOTTOM) { | 1846 TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_BOTTOM) { |
1857 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1847 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
1858 | 1848 |
1859 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTBOTTOM); | 1849 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTBOTTOM); |
1860 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), | 1850 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), |
1861 touch_resize_window_->bounds().ToString()); | 1851 touch_resize_window_->bounds().ToString()); |
1862 | 1852 |
1863 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1853 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1864 touch_resize_window_.get()); | 1854 touch_resize_window_.get()); |
1865 | 1855 |
1866 // Drag out of the bottom border a bit and check if the border is aligned with | 1856 // Drag out of the bottom border a bit and check if the border is aligned with |
(...skipping 11 matching lines...) Expand all Loading... |
1878 touch_resize_window_->bounds().ToString()); | 1868 touch_resize_window_->bounds().ToString()); |
1879 // Drag even more to snap to the edge. | 1869 // Drag even more to snap to the edge. |
1880 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), | 1870 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), |
1881 gfx::Point(400, kRootHeight - 25), | 1871 gfx::Point(400, kRootHeight - 25), |
1882 base::TimeDelta::FromMilliseconds(10), 5); | 1872 base::TimeDelta::FromMilliseconds(10), 5); |
1883 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), | 1873 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), |
1884 touch_resize_window_->bounds().ToString()); | 1874 touch_resize_window_->bounds().ToString()); |
1885 } | 1875 } |
1886 | 1876 |
1887 } // namespace ash | 1877 } // namespace ash |
OLD | NEW |