| 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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/shell_window_ids.h" | 8 #include "ash/common/shell_window_ids.h" |
| 9 #include "ash/common/wm/window_positioning_utils.h" | 9 #include "ash/common/wm/window_positioning_utils.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 const int kRootHeight = 600; | 39 const int kRootHeight = 600; |
| 40 | 40 |
| 41 Shelf* GetShelf() { | 41 Shelf* GetShelf() { |
| 42 return Shelf::ForPrimaryDisplay(); | 42 return Shelf::ForPrimaryDisplay(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // A simple window delegate that returns the specified min size. | 45 // A simple window delegate that returns the specified min size. |
| 46 class TestWindowDelegate : public aura::test::TestWindowDelegate { | 46 class TestWindowDelegate : public aura::test::TestWindowDelegate { |
| 47 public: | 47 public: |
| 48 TestWindowDelegate() { | 48 TestWindowDelegate() {} |
| 49 } | |
| 50 ~TestWindowDelegate() override {} | 49 ~TestWindowDelegate() override {} |
| 51 | 50 |
| 52 void set_min_size(const gfx::Size& size) { | 51 void set_min_size(const gfx::Size& size) { min_size_ = size; } |
| 53 min_size_ = size; | |
| 54 } | |
| 55 | 52 |
| 56 void set_max_size(const gfx::Size& size) { | 53 void set_max_size(const gfx::Size& size) { max_size_ = size; } |
| 57 max_size_ = size; | |
| 58 } | |
| 59 | 54 |
| 60 private: | 55 private: |
| 61 // Overridden from aura::Test::TestWindowDelegate: | 56 // Overridden from aura::Test::TestWindowDelegate: |
| 62 gfx::Size GetMinimumSize() const override { return min_size_; } | 57 gfx::Size GetMinimumSize() const override { return min_size_; } |
| 63 | 58 |
| 64 gfx::Size GetMaximumSize() const override { return max_size_; } | 59 gfx::Size GetMaximumSize() const override { return max_size_; } |
| 65 | 60 |
| 66 gfx::Size min_size_; | 61 gfx::Size min_size_; |
| 67 gfx::Size max_size_; | 62 gfx::Size max_size_; |
| 68 | 63 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 if (*i == window_.get() || *i == window2_.get() || *i == window3_.get()) { | 132 if (*i == window_.get() || *i == window2_.get() || *i == window3_.get()) { |
| 138 if (!result.empty()) | 133 if (!result.empty()) |
| 139 result += " "; | 134 result += " "; |
| 140 result += base::IntToString((*i)->id()); | 135 result += base::IntToString((*i)->id()); |
| 141 } | 136 } |
| 142 } | 137 } |
| 143 return result; | 138 return result; |
| 144 } | 139 } |
| 145 | 140 |
| 146 protected: | 141 protected: |
| 147 WindowResizer* CreateResizerForTest( | 142 WindowResizer* CreateResizerForTest(aura::Window* window, |
| 148 aura::Window* window, | 143 const gfx::Point& point_in_parent, |
| 149 const gfx::Point& point_in_parent, | 144 int window_component) { |
| 150 int window_component) { | |
| 151 WindowResizer* resizer = | 145 WindowResizer* resizer = |
| 152 CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, | 146 CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, |
| 153 window_component, | 147 window_component, |
| 154 aura::client::WINDOW_MOVE_SOURCE_MOUSE) | 148 aura::client::WINDOW_MOVE_SOURCE_MOUSE) |
| 155 .release(); | 149 .release(); |
| 156 workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest(); | 150 workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest(); |
| 157 return resizer; | 151 return resizer; |
| 158 } | 152 } |
| 159 WorkspaceWindowResizer* CreateWorkspaceResizerForTest( | 153 WorkspaceWindowResizer* CreateWorkspaceResizerForTest( |
| 160 aura::Window* window, | 154 aura::Window* window, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 180 location.set_y(location.y() + delta_y); | 174 location.set_y(location.y() + delta_y); |
| 181 return location; | 175 return location; |
| 182 } | 176 } |
| 183 | 177 |
| 184 std::vector<aura::Window*> empty_windows() const { | 178 std::vector<aura::Window*> empty_windows() const { |
| 185 return std::vector<aura::Window*>(); | 179 return std::vector<aura::Window*>(); |
| 186 } | 180 } |
| 187 | 181 |
| 188 void InitTouchResizeWindow(const gfx::Rect& bounds, int window_component) { | 182 void InitTouchResizeWindow(const gfx::Rect& bounds, int window_component) { |
| 189 touch_resize_delegate_.set_window_component(window_component); | 183 touch_resize_delegate_.set_window_component(window_component); |
| 190 touch_resize_window_.reset( | 184 touch_resize_window_.reset(CreateTestWindowInShellWithDelegate( |
| 191 CreateTestWindowInShellWithDelegate(&touch_resize_delegate_, 0, | 185 &touch_resize_delegate_, 0, bounds)); |
| 192 bounds)); | |
| 193 } | 186 } |
| 194 | 187 |
| 195 TestWindowDelegate delegate_; | 188 TestWindowDelegate delegate_; |
| 196 TestWindowDelegate delegate2_; | 189 TestWindowDelegate delegate2_; |
| 197 TestWindowDelegate delegate3_; | 190 TestWindowDelegate delegate3_; |
| 198 TestWindowDelegate delegate4_; | 191 TestWindowDelegate delegate4_; |
| 199 std::unique_ptr<aura::Window> window_; | 192 std::unique_ptr<aura::Window> window_; |
| 200 std::unique_ptr<aura::Window> window2_; | 193 std::unique_ptr<aura::Window> window2_; |
| 201 std::unique_ptr<aura::Window> window3_; | 194 std::unique_ptr<aura::Window> window3_; |
| 202 std::unique_ptr<aura::Window> window4_; | 195 std::unique_ptr<aura::Window> window4_; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 232 |
| 240 // Revert and make sure everything moves back. | 233 // Revert and make sure everything moves back. |
| 241 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0); | 234 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0); |
| 242 resizer->RevertDrag(); | 235 resizer->RevertDrag(); |
| 243 EXPECT_EQ("0,300 400x300", window_->bounds().ToString()); | 236 EXPECT_EQ("0,300 400x300", window_->bounds().ToString()); |
| 244 EXPECT_EQ("400,200 100x200", window2_->bounds().ToString()); | 237 EXPECT_EQ("400,200 100x200", window2_->bounds().ToString()); |
| 245 } | 238 } |
| 246 | 239 |
| 247 // Assertions around collapsing and expanding. | 240 // Assertions around collapsing and expanding. |
| 248 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_Compress) { | 241 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_Compress) { |
| 249 window_->SetBounds(gfx::Rect( 0, 300, 400, 300)); | 242 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); |
| 250 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); | 243 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); |
| 251 | 244 |
| 252 std::vector<aura::Window*> windows; | 245 std::vector<aura::Window*> windows; |
| 253 windows.push_back(window2_.get()); | 246 windows.push_back(window2_.get()); |
| 254 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 247 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 255 window_.get(), gfx::Point(), HTRIGHT, | 248 window_.get(), gfx::Point(), HTRIGHT, |
| 256 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 249 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 257 ASSERT_TRUE(resizer.get()); | 250 ASSERT_TRUE(resizer.get()); |
| 258 // Move it 100 to the left, which should expand w2 and collapse w1. | 251 // Move it 100 to the left, which should expand w2 and collapse w1. |
| 259 resizer->Drag(CalculateDragPoint(*resizer, -100, 10), 0); | 252 resizer->Drag(CalculateDragPoint(*resizer, -100, 10), 0); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 278 | 271 |
| 279 // Back to -100. | 272 // Back to -100. |
| 280 resizer->Drag(CalculateDragPoint(*resizer, -100, 20), 0); | 273 resizer->Drag(CalculateDragPoint(*resizer, -100, 20), 0); |
| 281 EXPECT_EQ("0,300 300x300", window_->bounds().ToString()); | 274 EXPECT_EQ("0,300 300x300", window_->bounds().ToString()); |
| 282 EXPECT_EQ("300,200 200x200", window2_->bounds().ToString()); | 275 EXPECT_EQ("300,200 200x200", window2_->bounds().ToString()); |
| 283 } | 276 } |
| 284 | 277 |
| 285 // Assertions around attached window resize dragging from the right with 3 | 278 // Assertions around attached window resize dragging from the right with 3 |
| 286 // windows. | 279 // windows. |
| 287 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3) { | 280 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3) { |
| 288 window_->SetBounds(gfx::Rect( 100, 300, 200, 300)); | 281 window_->SetBounds(gfx::Rect(100, 300, 200, 300)); |
| 289 window2_->SetBounds(gfx::Rect(300, 300, 150, 200)); | 282 window2_->SetBounds(gfx::Rect(300, 300, 150, 200)); |
| 290 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); | 283 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); |
| 291 delegate2_.set_min_size(gfx::Size(52, 50)); | 284 delegate2_.set_min_size(gfx::Size(52, 50)); |
| 292 delegate3_.set_min_size(gfx::Size(38, 50)); | 285 delegate3_.set_min_size(gfx::Size(38, 50)); |
| 293 | 286 |
| 294 std::vector<aura::Window*> windows; | 287 std::vector<aura::Window*> windows; |
| 295 windows.push_back(window2_.get()); | 288 windows.push_back(window2_.get()); |
| 296 windows.push_back(window3_.get()); | 289 windows.push_back(window3_.get()); |
| 297 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 290 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 298 window_.get(), gfx::Point(), HTRIGHT, | 291 window_.get(), gfx::Point(), HTRIGHT, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 319 // Revert and make sure everything moves back. | 312 // Revert and make sure everything moves back. |
| 320 resizer->RevertDrag(); | 313 resizer->RevertDrag(); |
| 321 EXPECT_EQ("100,300 200x300", window_->bounds().ToString()); | 314 EXPECT_EQ("100,300 200x300", window_->bounds().ToString()); |
| 322 EXPECT_EQ("300,300 150x200", window2_->bounds().ToString()); | 315 EXPECT_EQ("300,300 150x200", window2_->bounds().ToString()); |
| 323 EXPECT_EQ("450,300 100x200", window3_->bounds().ToString()); | 316 EXPECT_EQ("450,300 100x200", window3_->bounds().ToString()); |
| 324 } | 317 } |
| 325 | 318 |
| 326 // Assertions around attached window resizing (collapsing and expanding) with | 319 // Assertions around attached window resizing (collapsing and expanding) with |
| 327 // 3 windows. | 320 // 3 windows. |
| 328 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3_Compress) { | 321 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3_Compress) { |
| 329 window_->SetBounds(gfx::Rect( 100, 300, 200, 300)); | 322 window_->SetBounds(gfx::Rect(100, 300, 200, 300)); |
| 330 window2_->SetBounds(gfx::Rect(300, 300, 200, 200)); | 323 window2_->SetBounds(gfx::Rect(300, 300, 200, 200)); |
| 331 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); | 324 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); |
| 332 delegate2_.set_min_size(gfx::Size(52, 50)); | 325 delegate2_.set_min_size(gfx::Size(52, 50)); |
| 333 delegate3_.set_min_size(gfx::Size(38, 50)); | 326 delegate3_.set_min_size(gfx::Size(38, 50)); |
| 334 | 327 |
| 335 std::vector<aura::Window*> windows; | 328 std::vector<aura::Window*> windows; |
| 336 windows.push_back(window2_.get()); | 329 windows.push_back(window2_.get()); |
| 337 windows.push_back(window3_.get()); | 330 windows.push_back(window3_.get()); |
| 338 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 331 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 339 window_.get(), gfx::Point(), HTRIGHT, | 332 window_.get(), gfx::Point(), HTRIGHT, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 353 | 346 |
| 354 // 100 to the left again. | 347 // 100 to the left again. |
| 355 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0); | 348 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0); |
| 356 EXPECT_EQ("100,300 100x300", window_->bounds().ToString()); | 349 EXPECT_EQ("100,300 100x300", window_->bounds().ToString()); |
| 357 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString()); | 350 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString()); |
| 358 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString()); | 351 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString()); |
| 359 } | 352 } |
| 360 | 353 |
| 361 // Assertions around collapsing and expanding from the bottom. | 354 // Assertions around collapsing and expanding from the bottom. |
| 362 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_Compress) { | 355 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_Compress) { |
| 363 window_->SetBounds(gfx::Rect( 0, 100, 400, 300)); | 356 window_->SetBounds(gfx::Rect(0, 100, 400, 300)); |
| 364 window2_->SetBounds(gfx::Rect(400, 400, 100, 200)); | 357 window2_->SetBounds(gfx::Rect(400, 400, 100, 200)); |
| 365 | 358 |
| 366 std::vector<aura::Window*> windows; | 359 std::vector<aura::Window*> windows; |
| 367 windows.push_back(window2_.get()); | 360 windows.push_back(window2_.get()); |
| 368 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 361 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 369 window_.get(), gfx::Point(), HTBOTTOM, | 362 window_.get(), gfx::Point(), HTBOTTOM, |
| 370 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 363 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 371 ASSERT_TRUE(resizer.get()); | 364 ASSERT_TRUE(resizer.get()); |
| 372 // Move it up 100, which should expand w2 and collapse w1. | 365 // Move it up 100, which should expand w2 and collapse w1. |
| 373 resizer->Drag(CalculateDragPoint(*resizer, 10, -100), 0); | 366 resizer->Drag(CalculateDragPoint(*resizer, 10, -100), 0); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 387 | 380 |
| 388 // Back to -100. | 381 // Back to -100. |
| 389 resizer->Drag(CalculateDragPoint(*resizer, 20, -100), 0); | 382 resizer->Drag(CalculateDragPoint(*resizer, 20, -100), 0); |
| 390 EXPECT_EQ("0,100 400x200", window_->bounds().ToString()); | 383 EXPECT_EQ("0,100 400x200", window_->bounds().ToString()); |
| 391 EXPECT_EQ("400,300 100x300", window2_->bounds().ToString()); | 384 EXPECT_EQ("400,300 100x300", window2_->bounds().ToString()); |
| 392 } | 385 } |
| 393 | 386 |
| 394 // Assertions around attached window resize dragging from the bottom with 2 | 387 // Assertions around attached window resize dragging from the bottom with 2 |
| 395 // windows. | 388 // windows. |
| 396 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) { | 389 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) { |
| 397 window_->SetBounds(gfx::Rect( 0, 50, 400, 200)); | 390 window_->SetBounds(gfx::Rect(0, 50, 400, 200)); |
| 398 window2_->SetBounds(gfx::Rect(0, 250, 200, 100)); | 391 window2_->SetBounds(gfx::Rect(0, 250, 200, 100)); |
| 399 | 392 |
| 400 std::vector<aura::Window*> windows; | 393 std::vector<aura::Window*> windows; |
| 401 windows.push_back(window2_.get()); | 394 windows.push_back(window2_.get()); |
| 402 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 395 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 403 window_.get(), gfx::Point(), HTBOTTOM, | 396 window_.get(), gfx::Point(), HTBOTTOM, |
| 404 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 397 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 405 ASSERT_TRUE(resizer.get()); | 398 ASSERT_TRUE(resizer.get()); |
| 406 // Move it 100 to the bottom, which should expand w1 and push w2. | 399 // Move it 100 to the bottom, which should expand w1 and push w2. |
| 407 resizer->Drag(CalculateDragPoint(*resizer, 10, 100), 0); | 400 resizer->Drag(CalculateDragPoint(*resizer, 10, 100), 0); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 433 #define MAYBE_AttachedResize_BOTTOM_3 AttachedResize_BOTTOM_3 | 426 #define MAYBE_AttachedResize_BOTTOM_3 AttachedResize_BOTTOM_3 |
| 434 #endif | 427 #endif |
| 435 | 428 |
| 436 // Assertions around attached window resize dragging from the bottom with 3 | 429 // Assertions around attached window resize dragging from the bottom with 3 |
| 437 // windows. | 430 // windows. |
| 438 TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) { | 431 TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) { |
| 439 UpdateDisplay("600x800"); | 432 UpdateDisplay("600x800"); |
| 440 aura::Window* root = Shell::GetPrimaryRootWindow(); | 433 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 441 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 434 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 442 | 435 |
| 443 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); | 436 window_->SetBounds(gfx::Rect(300, 100, 300, 200)); |
| 444 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); | 437 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); |
| 445 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); | 438 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); |
| 446 delegate2_.set_min_size(gfx::Size(50, 52)); | 439 delegate2_.set_min_size(gfx::Size(50, 52)); |
| 447 delegate3_.set_min_size(gfx::Size(50, 38)); | 440 delegate3_.set_min_size(gfx::Size(50, 38)); |
| 448 | 441 |
| 449 std::vector<aura::Window*> windows; | 442 std::vector<aura::Window*> windows; |
| 450 windows.push_back(window2_.get()); | 443 windows.push_back(window2_.get()); |
| 451 windows.push_back(window3_.get()); | 444 windows.push_back(window3_.get()); |
| 452 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 445 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 453 window_.get(), gfx::Point(), HTBOTTOM, | 446 window_.get(), gfx::Point(), HTBOTTOM, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 474 // Revert and make sure everything moves back. | 467 // Revert and make sure everything moves back. |
| 475 resizer->RevertDrag(); | 468 resizer->RevertDrag(); |
| 476 EXPECT_EQ("300,100 300x200", window_->bounds().ToString()); | 469 EXPECT_EQ("300,100 300x200", window_->bounds().ToString()); |
| 477 EXPECT_EQ("300,300 200x150", window2_->bounds().ToString()); | 470 EXPECT_EQ("300,300 200x150", window2_->bounds().ToString()); |
| 478 EXPECT_EQ("300,450 200x100", window3_->bounds().ToString()); | 471 EXPECT_EQ("300,450 200x100", window3_->bounds().ToString()); |
| 479 } | 472 } |
| 480 | 473 |
| 481 // Assertions around attached window resizing (collapsing and expanding) with | 474 // Assertions around attached window resizing (collapsing and expanding) with |
| 482 // 3 windows. | 475 // 3 windows. |
| 483 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3_Compress) { | 476 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3_Compress) { |
| 484 window_->SetBounds(gfx::Rect( 0, 0, 200, 200)); | 477 window_->SetBounds(gfx::Rect(0, 0, 200, 200)); |
| 485 window2_->SetBounds(gfx::Rect(10, 200, 200, 200)); | 478 window2_->SetBounds(gfx::Rect(10, 200, 200, 200)); |
| 486 window3_->SetBounds(gfx::Rect(20, 400, 100, 100)); | 479 window3_->SetBounds(gfx::Rect(20, 400, 100, 100)); |
| 487 delegate2_.set_min_size(gfx::Size(52, 50)); | 480 delegate2_.set_min_size(gfx::Size(52, 50)); |
| 488 delegate3_.set_min_size(gfx::Size(38, 50)); | 481 delegate3_.set_min_size(gfx::Size(38, 50)); |
| 489 | 482 |
| 490 std::vector<aura::Window*> windows; | 483 std::vector<aura::Window*> windows; |
| 491 windows.push_back(window2_.get()); | 484 windows.push_back(window2_.get()); |
| 492 windows.push_back(window3_.get()); | 485 windows.push_back(window3_.get()); |
| 493 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 486 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 494 window_.get(), gfx::Point(), HTBOTTOM, | 487 window_.get(), gfx::Point(), HTBOTTOM, |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, window_state->GetStateType()); | 749 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, window_state->GetStateType()); |
| 757 gfx::Rect expected_bounds(snapped_bounds); | 750 gfx::Rect expected_bounds(snapped_bounds); |
| 758 expected_bounds.Inset(0, 0, 0, 10); | 751 expected_bounds.Inset(0, 0, 0, 10); |
| 759 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString()); | 752 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString()); |
| 760 EXPECT_FALSE(window_state->HasRestoreBounds()); | 753 EXPECT_FALSE(window_state->HasRestoreBounds()); |
| 761 } | 754 } |
| 762 } | 755 } |
| 763 | 756 |
| 764 // Verifies windows are correctly restacked when reordering multiple windows. | 757 // Verifies windows are correctly restacked when reordering multiple windows. |
| 765 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { | 758 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { |
| 766 window_->SetBounds(gfx::Rect( 0, 0, 200, 300)); | 759 window_->SetBounds(gfx::Rect(0, 0, 200, 300)); |
| 767 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); | 760 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); |
| 768 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); | 761 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); |
| 769 | 762 |
| 770 { | 763 { |
| 771 std::vector<aura::Window*> windows; | 764 std::vector<aura::Window*> windows; |
| 772 windows.push_back(window2_.get()); | 765 windows.push_back(window2_.get()); |
| 773 std::unique_ptr<WorkspaceWindowResizer> resizer( | 766 std::unique_ptr<WorkspaceWindowResizer> resizer( |
| 774 CreateWorkspaceResizerForTest(window_.get(), gfx::Point(), HTRIGHT, | 767 CreateWorkspaceResizerForTest(window_.get(), gfx::Point(), HTRIGHT, |
| 775 aura::client::WINDOW_MOVE_SOURCE_MOUSE, | 768 aura::client::WINDOW_MOVE_SOURCE_MOUSE, |
| 776 windows)); | 769 windows)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 793 // Move it 100 to the right, which should expand w1 and push w2 and w3. | 786 // Move it 100 to the right, which should expand w1 and push w2 and w3. |
| 794 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); | 787 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); |
| 795 | 788 |
| 796 // 2 should be topmost since it's initially the highest in the stack. | 789 // 2 should be topmost since it's initially the highest in the stack. |
| 797 EXPECT_EQ("2 3 1", WindowOrderAsString(window_->parent())); | 790 EXPECT_EQ("2 3 1", WindowOrderAsString(window_->parent())); |
| 798 } | 791 } |
| 799 } | 792 } |
| 800 | 793 |
| 801 // Makes sure we don't allow dragging below the work area. | 794 // Makes sure we don't allow dragging below the work area. |
| 802 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { | 795 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { |
| 803 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 796 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 804 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 797 gfx::Insets(0, 0, 10, 0)); |
| 805 | 798 |
| 806 ASSERT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); | 799 ASSERT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); |
| 807 | 800 |
| 808 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 801 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
| 809 std::unique_ptr<WindowResizer> resizer( | 802 std::unique_ptr<WindowResizer> resizer( |
| 810 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 803 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
| 811 ASSERT_TRUE(resizer.get()); | 804 ASSERT_TRUE(resizer.get()); |
| 812 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); | 805 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); |
| 813 int expected_y = | 806 int expected_y = |
| 814 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 807 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
| 815 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", | 808 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", |
| 816 window_->bounds().ToString()); | 809 window_->bounds().ToString()); |
| 817 } | 810 } |
| 818 | 811 |
| 819 // Makes sure we don't allow dragging on the work area with multidisplay. | 812 // Makes sure we don't allow dragging on the work area with multidisplay. |
| 820 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { | 813 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { |
| 821 if (!SupportsMultipleDisplays()) | 814 if (!SupportsMultipleDisplays()) |
| 822 return; | 815 return; |
| 823 | 816 |
| 824 UpdateDisplay("800x600,800x600"); | 817 UpdateDisplay("800x600,800x600"); |
| 825 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); | 818 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); |
| 826 | 819 |
| 827 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 820 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 828 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 821 gfx::Insets(0, 0, 10, 0)); |
| 829 | 822 |
| 830 // Positions the secondary display at the bottom the primary display. | 823 // Positions the secondary display at the bottom the primary display. |
| 831 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 824 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 832 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 0)); | 825 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 0)); |
| 833 | 826 |
| 834 { | 827 { |
| 835 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); | 828 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); |
| 836 DCHECK_LT(window_->bounds().height(), | 829 DCHECK_LT(window_->bounds().height(), |
| 837 WorkspaceWindowResizer::kMinOnscreenHeight); | 830 WorkspaceWindowResizer::kMinOnscreenHeight); |
| 838 // Drag down avoiding dragging along the edge as that would side-snap. | 831 // Drag down avoiding dragging along the edge as that would side-snap. |
| 839 std::unique_ptr<WindowResizer> resizer( | 832 std::unique_ptr<WindowResizer> resizer( |
| 840 CreateResizerForTest(window_.get(), gfx::Point(10, 0), HTCAPTION)); | 833 CreateResizerForTest(window_.get(), gfx::Point(10, 0), HTCAPTION)); |
| 841 ASSERT_TRUE(resizer.get()); | 834 ASSERT_TRUE(resizer.get()); |
| 842 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 835 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
| 843 int expected_y = kRootHeight - window_->bounds().height() - 10; | 836 int expected_y = kRootHeight - window_->bounds().height() - 10; |
| 844 // When the mouse cursor is in the primary display, the window cannot move | 837 // When the mouse cursor is in the primary display, the window cannot move |
| 845 // on non-work area but can get all the way towards the bottom, | 838 // on non-work area but can get all the way towards the bottom, |
| 846 // restricted only by the window height. | 839 // restricted only by the window height. |
| 847 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", | 840 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", |
| 848 window_->bounds().ToString()); | 841 window_->bounds().ToString()); |
| 849 // Revert the drag in order to not remember the restore bounds. | 842 // Revert the drag in order to not remember the restore bounds. |
| 850 resizer->RevertDrag(); | 843 resizer->RevertDrag(); |
| 851 } | 844 } |
| 852 | 845 |
| 853 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 846 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 854 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 847 gfx::Insets(0, 0, 10, 0)); |
| 855 { | 848 { |
| 856 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 849 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
| 857 std::unique_ptr<WindowResizer> resizer( | 850 std::unique_ptr<WindowResizer> resizer( |
| 858 CreateResizerForTest(window_.get(), gfx::Point(10, 0), HTCAPTION)); | 851 CreateResizerForTest(window_.get(), gfx::Point(10, 0), HTCAPTION)); |
| 859 ASSERT_TRUE(resizer.get()); | 852 ASSERT_TRUE(resizer.get()); |
| 860 // Drag down avoiding dragging along the edge as that would side-snap. | 853 // Drag down avoiding dragging along the edge as that would side-snap. |
| 861 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 854 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
| 862 int expected_y = | 855 int expected_y = |
| 863 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 856 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
| 864 // When the mouse cursor is in the primary display, the window cannot move | 857 // When the mouse cursor is in the primary display, the window cannot move |
| (...skipping 12 matching lines...) Expand all Loading... |
| 877 resizer->Drag(CalculateDragPoint(*resizer, 0, 500), 0); | 870 resizer->Drag(CalculateDragPoint(*resizer, 0, 500), 0); |
| 878 // The window can move to the secondary display beyond non-work area of | 871 // The window can move to the secondary display beyond non-work area of |
| 879 // the primary display. | 872 // the primary display. |
| 880 EXPECT_EQ("100,700 300x400", window_->bounds().ToString()); | 873 EXPECT_EQ("100,700 300x400", window_->bounds().ToString()); |
| 881 resizer->CompleteDrag(); | 874 resizer->CompleteDrag(); |
| 882 } | 875 } |
| 883 } | 876 } |
| 884 | 877 |
| 885 // Makes sure we don't allow dragging off the top of the work area. | 878 // Makes sure we don't allow dragging off the top of the work area. |
| 886 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { | 879 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { |
| 887 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 880 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 888 Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0)); | 881 gfx::Insets(10, 0, 0, 0)); |
| 889 | 882 |
| 890 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 883 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
| 891 std::unique_ptr<WindowResizer> resizer( | 884 std::unique_ptr<WindowResizer> resizer( |
| 892 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 885 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
| 893 ASSERT_TRUE(resizer.get()); | 886 ASSERT_TRUE(resizer.get()); |
| 894 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0); | 887 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0); |
| 895 EXPECT_EQ("100,10 300x400", window_->bounds().ToString()); | 888 EXPECT_EQ("100,10 300x400", window_->bounds().ToString()); |
| 896 } | 889 } |
| 897 | 890 |
| 898 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { | 891 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { |
| 899 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 892 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 900 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 893 gfx::Insets(0, 0, 50, 0)); |
| 901 | 894 |
| 902 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); | 895 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); |
| 903 std::unique_ptr<WindowResizer> resizer( | 896 std::unique_ptr<WindowResizer> resizer( |
| 904 CreateResizerForTest(window_.get(), gfx::Point(), HTTOP)); | 897 CreateResizerForTest(window_.get(), gfx::Point(), HTTOP)); |
| 905 ASSERT_TRUE(resizer.get()); | 898 ASSERT_TRUE(resizer.get()); |
| 906 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); | 899 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); |
| 907 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); | 900 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); |
| 908 } | 901 } |
| 909 | 902 |
| 910 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { | 903 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { |
| 911 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 904 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 912 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 905 gfx::Insets(0, 0, 50, 0)); |
| 913 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); | 906 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); |
| 914 int pixels_to_left_border = 50; | 907 int pixels_to_left_border = 50; |
| 915 int window_width = 300; | 908 int window_width = 300; |
| 916 int window_x = left - window_width + pixels_to_left_border; | 909 int window_x = left - window_width + pixels_to_left_border; |
| 917 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 910 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 918 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( | 911 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 919 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); | 912 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); |
| 920 ASSERT_TRUE(resizer.get()); | 913 ASSERT_TRUE(resizer.get()); |
| 921 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); | 914 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); |
| 922 EXPECT_EQ(base::IntToString(window_x) + ",100 " + | 915 EXPECT_EQ(base::IntToString(window_x) + ",100 " + |
| 923 base::IntToString(wm::kMinimumOnScreenArea - window_x) + "x380", | 916 base::IntToString(wm::kMinimumOnScreenArea - window_x) + "x380", |
| 924 window_->bounds().ToString()); | 917 window_->bounds().ToString()); |
| 925 } | 918 } |
| 926 | 919 |
| 927 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { | 920 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { |
| 928 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 921 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 929 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 922 gfx::Insets(0, 0, 50, 0)); |
| 930 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 923 int right = |
| 931 window_.get()).right(); | 924 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).right(); |
| 932 int pixels_to_right_border = 50; | 925 int pixels_to_right_border = 50; |
| 933 int window_width = 300; | 926 int window_width = 300; |
| 934 int window_x = right - pixels_to_right_border; | 927 int window_x = right - pixels_to_right_border; |
| 935 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 928 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 936 std::unique_ptr<WindowResizer> resizer( | 929 std::unique_ptr<WindowResizer> resizer( |
| 937 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTLEFT)); | 930 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTLEFT)); |
| 938 ASSERT_TRUE(resizer.get()); | 931 ASSERT_TRUE(resizer.get()); |
| 939 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 932 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
| 940 EXPECT_EQ(base::IntToString(right - wm::kMinimumOnScreenArea) + ",100 " + | 933 EXPECT_EQ(base::IntToString(right - wm::kMinimumOnScreenArea) + ",100 " + |
| 941 base::IntToString(window_width - pixels_to_right_border + | 934 base::IntToString(window_width - pixels_to_right_border + |
| 942 wm::kMinimumOnScreenArea) + | 935 wm::kMinimumOnScreenArea) + |
| 943 "x380", | 936 "x380", |
| 944 window_->bounds().ToString()); | 937 window_->bounds().ToString()); |
| 945 } | 938 } |
| 946 | 939 |
| 947 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { | 940 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { |
| 948 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 941 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 949 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 942 gfx::Insets(0, 0, 50, 0)); |
| 950 int bottom = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 943 int bottom = |
| 951 window_.get()).bottom(); | 944 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
| 952 int delta_to_bottom = 50; | 945 int delta_to_bottom = 50; |
| 953 int height = 380; | 946 int height = 380; |
| 954 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); | 947 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); |
| 955 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( | 948 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 956 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); | 949 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); |
| 957 ASSERT_TRUE(resizer.get()); | 950 ASSERT_TRUE(resizer.get()); |
| 958 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); | 951 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); |
| 959 EXPECT_EQ("100," + base::IntToString(bottom - wm::kMinimumOnScreenArea) + | 952 EXPECT_EQ("100," + base::IntToString(bottom - wm::kMinimumOnScreenArea) + |
| 960 " 300x" + | 953 " 300x" + |
| 961 base::IntToString(height - | 954 base::IntToString(height - |
| 962 (delta_to_bottom - wm::kMinimumOnScreenArea)), | 955 (delta_to_bottom - wm::kMinimumOnScreenArea)), |
| 963 window_->bounds().ToString()); | 956 window_->bounds().ToString()); |
| 964 } | 957 } |
| 965 | 958 |
| 966 // Verifies that 'outside' check of the resizer take into account the extended | 959 // Verifies that 'outside' check of the resizer take into account the extended |
| 967 // desktop in case of repositions. | 960 // desktop in case of repositions. |
| 968 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { | 961 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { |
| 969 // Only primary display. Changes the window position to fit within the | 962 // Only primary display. Changes the window position to fit within the |
| 970 // display. | 963 // display. |
| 971 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 964 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 972 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 965 gfx::Insets(0, 0, 50, 0)); |
| 973 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 966 int right = |
| 974 window_.get()).right(); | 967 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).right(); |
| 975 int pixels_to_right_border = 50; | 968 int pixels_to_right_border = 50; |
| 976 int window_width = 300; | 969 int window_width = 300; |
| 977 int window_x = right - pixels_to_right_border; | 970 int window_x = right - pixels_to_right_border; |
| 978 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 971 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 979 std::unique_ptr<WindowResizer> resizer( | 972 std::unique_ptr<WindowResizer> resizer( |
| 980 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTCAPTION)); | 973 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTCAPTION)); |
| 981 ASSERT_TRUE(resizer.get()); | 974 ASSERT_TRUE(resizer.get()); |
| 982 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 975 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
| 983 EXPECT_EQ(base::IntToString(right - wm::kMinimumOnScreenArea) + ",100 " + | 976 EXPECT_EQ(base::IntToString(right - wm::kMinimumOnScreenArea) + ",100 " + |
| 984 base::IntToString(window_width) + "x380", | 977 base::IntToString(window_width) + "x380", |
| 985 window_->bounds().ToString()); | 978 window_->bounds().ToString()); |
| 986 | 979 |
| 987 if (!SupportsMultipleDisplays()) | 980 if (!SupportsMultipleDisplays()) |
| 988 return; | 981 return; |
| 989 | 982 |
| 990 // With secondary display. Operation itself is same but doesn't change | 983 // With secondary display. Operation itself is same but doesn't change |
| 991 // the position because the window is still within the secondary display. | 984 // the position because the window is still within the secondary display. |
| 992 UpdateDisplay("1000x600,600x400"); | 985 UpdateDisplay("1000x600,600x400"); |
| 993 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 986 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 994 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 987 gfx::Insets(0, 0, 50, 0)); |
| 995 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 988 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 996 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 989 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
| 997 EXPECT_EQ(base::IntToString(window_x + window_width) + | 990 EXPECT_EQ(base::IntToString(window_x + window_width) + ",100 " + |
| 998 ",100 " + | 991 base::IntToString(window_width) + "x380", |
| 999 base::IntToString(window_width) + | 992 window_->bounds().ToString()); |
| 1000 "x380", window_->bounds().ToString()); | |
| 1001 } | 993 } |
| 1002 | 994 |
| 1003 // Verifies snapping to edges works. | 995 // Verifies snapping to edges works. |
| 1004 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { | 996 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { |
| 1005 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 997 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1006 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 998 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
| 1007 // Click 50px to the right so that the mouse pointer does not leave the | 999 // Click 50px to the right so that the mouse pointer does not leave the |
| 1008 // workspace ensuring sticky behavior. | 1000 // workspace ensuring sticky behavior. |
| 1009 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( | 1001 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 1010 window_.get(), window_->bounds().origin() + gfx::Vector2d(50, 0), | 1002 window_.get(), window_->bounds().origin() + gfx::Vector2d(50, 0), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 resizer->Drag(CalculateDragPoint(*resizer, 0, 600 - 160 - 112 - 2 + 33), 0); | 1038 resizer->Drag(CalculateDragPoint(*resizer, 0, 600 - 160 - 112 - 2 + 33), 0); |
| 1047 EXPECT_EQ("96,471 320x160", window_->bounds().ToString()); | 1039 EXPECT_EQ("96,471 320x160", window_->bounds().ToString()); |
| 1048 | 1040 |
| 1049 // And the top should snap too. | 1041 // And the top should snap too. |
| 1050 resizer->Drag(CalculateDragPoint(*resizer, 0, -112 + 20), 0); | 1042 resizer->Drag(CalculateDragPoint(*resizer, 0, -112 + 20), 0); |
| 1051 EXPECT_EQ("96,20 320x160", window_->bounds().ToString()); | 1043 EXPECT_EQ("96,20 320x160", window_->bounds().ToString()); |
| 1052 resizer->Drag(CalculateDragPoint(*resizer, 0, -112 + 7), 0); | 1044 resizer->Drag(CalculateDragPoint(*resizer, 0, -112 + 7), 0); |
| 1053 EXPECT_EQ("96,0 320x160", window_->bounds().ToString()); | 1045 EXPECT_EQ("96,0 320x160", window_->bounds().ToString()); |
| 1054 | 1046 |
| 1055 // And bottom/left should snap too. | 1047 // And bottom/left should snap too. |
| 1056 resizer->Drag( | 1048 resizer->Drag(CalculateDragPoint(*resizer, 7 - 96, 600 - 160 - 112 - 3 - 7), |
| 1057 CalculateDragPoint(*resizer, 7 - 96, 600 - 160 - 112 - 3 - 7), 0); | 1049 0); |
| 1058 EXPECT_EQ("0,437 320x160", window_->bounds().ToString()); | 1050 EXPECT_EQ("0,437 320x160", window_->bounds().ToString()); |
| 1059 resizer->Drag( | 1051 resizer->Drag( |
| 1060 CalculateDragPoint(*resizer, -15 - 96, 600 - 160 - 112 - 3 + 15), 0); | 1052 CalculateDragPoint(*resizer, -15 - 96, 600 - 160 - 112 - 3 + 15), 0); |
| 1061 EXPECT_EQ("0,437 320x160", window_->bounds().ToString()); | 1053 EXPECT_EQ("0,437 320x160", window_->bounds().ToString()); |
| 1062 // should move past snap points. | 1054 // should move past snap points. |
| 1063 resizer->Drag( | 1055 resizer->Drag( |
| 1064 CalculateDragPoint(*resizer, -32 - 96, 600 - 160 - 112 - 2 + 32), 0); | 1056 CalculateDragPoint(*resizer, -32 - 96, 600 - 160 - 112 - 2 + 32), 0); |
| 1065 EXPECT_EQ("-32,470 320x160", window_->bounds().ToString()); | 1057 EXPECT_EQ("-32,470 320x160", window_->bounds().ToString()); |
| 1066 resizer->Drag( | 1058 resizer->Drag( |
| 1067 CalculateDragPoint(*resizer, -33 - 96, 600 - 160 - 112 - 2 + 33), 0); | 1059 CalculateDragPoint(*resizer, -33 - 96, 600 - 160 - 112 - 2 + 33), 0); |
| 1068 EXPECT_EQ("-33,471 320x160", window_->bounds().ToString()); | 1060 EXPECT_EQ("-33,471 320x160", window_->bounds().ToString()); |
| 1069 | 1061 |
| 1070 // No need to test dragging < 0 as we force that to 0. | 1062 // No need to test dragging < 0 as we force that to 0. |
| 1071 } | 1063 } |
| 1072 | 1064 |
| 1073 // Verifies a resize snap when dragging TOPLEFT. | 1065 // Verifies a resize snap when dragging TOPLEFT. |
| 1074 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPLEFT) { | 1066 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPLEFT) { |
| 1075 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1067 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1076 std::unique_ptr<WindowResizer> resizer( | 1068 std::unique_ptr<WindowResizer> resizer( |
| 1077 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT)); | 1069 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT)); |
| 1078 ASSERT_TRUE(resizer.get()); | 1070 ASSERT_TRUE(resizer.get()); |
| 1079 resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0); | 1071 resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0); |
| 1080 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); | 1072 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); |
| 1081 } | 1073 } |
| 1082 | 1074 |
| 1083 // Verifies a resize snap when dragging TOPRIGHT. | 1075 // Verifies a resize snap when dragging TOPRIGHT. |
| 1084 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { | 1076 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { |
| 1085 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1077 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1086 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 1078 gfx::Rect work_area( |
| 1087 window_.get())); | 1079 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get())); |
| 1088 std::unique_ptr<WindowResizer> resizer( | 1080 std::unique_ptr<WindowResizer> resizer( |
| 1089 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT)); | 1081 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT)); |
| 1090 ASSERT_TRUE(resizer.get()); | 1082 ASSERT_TRUE(resizer.get()); |
| 1091 resizer->Drag( | 1083 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), |
| 1092 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), 0); | 1084 0); |
| 1093 EXPECT_EQ(100, window_->bounds().x()); | 1085 EXPECT_EQ(100, window_->bounds().x()); |
| 1094 EXPECT_EQ(work_area.y(), window_->bounds().y()); | 1086 EXPECT_EQ(work_area.y(), window_->bounds().y()); |
| 1095 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1087 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
| 1096 EXPECT_EQ(230, window_->bounds().height()); | 1088 EXPECT_EQ(230, window_->bounds().height()); |
| 1097 } | 1089 } |
| 1098 | 1090 |
| 1099 // Verifies a resize snap when dragging BOTTOMRIGHT. | 1091 // Verifies a resize snap when dragging BOTTOMRIGHT. |
| 1100 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { | 1092 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { |
| 1101 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1093 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1102 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 1094 gfx::Rect work_area( |
| 1103 window_.get())); | 1095 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get())); |
| 1104 std::unique_ptr<WindowResizer> resizer( | 1096 std::unique_ptr<WindowResizer> resizer( |
| 1105 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); | 1097 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
| 1106 ASSERT_TRUE(resizer.get()); | 1098 ASSERT_TRUE(resizer.get()); |
| 1107 resizer->Drag( | 1099 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 120 - 1, |
| 1108 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, | 1100 work_area.bottom() - 220 - 2), |
| 1109 work_area.bottom() - 220 - 2), 0); | 1101 0); |
| 1110 EXPECT_EQ(100, window_->bounds().x()); | 1102 EXPECT_EQ(100, window_->bounds().x()); |
| 1111 EXPECT_EQ(200, window_->bounds().y()); | 1103 EXPECT_EQ(200, window_->bounds().y()); |
| 1112 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1104 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
| 1113 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1105 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
| 1114 } | 1106 } |
| 1115 | 1107 |
| 1116 // Verifies a resize snap when dragging BOTTOMLEFT. | 1108 // Verifies a resize snap when dragging BOTTOMLEFT. |
| 1117 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) { | 1109 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) { |
| 1118 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1110 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
| 1119 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 1111 gfx::Rect work_area( |
| 1120 window_.get())); | 1112 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get())); |
| 1121 std::unique_ptr<WindowResizer> resizer( | 1113 std::unique_ptr<WindowResizer> resizer( |
| 1122 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT)); | 1114 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT)); |
| 1123 ASSERT_TRUE(resizer.get()); | 1115 ASSERT_TRUE(resizer.get()); |
| 1124 resizer->Drag( | 1116 resizer->Drag(CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), |
| 1125 CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), 0); | 1117 0); |
| 1126 EXPECT_EQ(0, window_->bounds().x()); | 1118 EXPECT_EQ(0, window_->bounds().x()); |
| 1127 EXPECT_EQ(200, window_->bounds().y()); | 1119 EXPECT_EQ(200, window_->bounds().y()); |
| 1128 EXPECT_EQ(120, window_->bounds().width()); | 1120 EXPECT_EQ(120, window_->bounds().width()); |
| 1129 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1121 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
| 1130 } | 1122 } |
| 1131 | 1123 |
| 1132 // Verifies window sticks to both window and work area. | 1124 // Verifies window sticks to both window and work area. |
| 1133 TEST_F(WorkspaceWindowResizerTest, StickToBothEdgeAndWindow) { | 1125 TEST_F(WorkspaceWindowResizerTest, StickToBothEdgeAndWindow) { |
| 1134 window_->SetBounds(gfx::Rect(10, 10, 20, 50)); | 1126 window_->SetBounds(gfx::Rect(10, 10, 20, 50)); |
| 1135 window_->Show(); | 1127 window_->Show(); |
| 1136 window2_->SetBounds(gfx::Rect(150, 160, 25, 1000)); | 1128 window2_->SetBounds(gfx::Rect(150, 160, 25, 1000)); |
| 1137 window2_->Show(); | 1129 window2_->Show(); |
| 1138 | 1130 |
| 1139 std::unique_ptr<WindowResizer> resizer( | 1131 std::unique_ptr<WindowResizer> resizer( |
| 1140 CreateResizerForTest(window_.get(), gfx::Point(10, 10), HTCAPTION)); | 1132 CreateResizerForTest(window_.get(), gfx::Point(10, 10), HTCAPTION)); |
| 1141 ASSERT_TRUE(resizer.get()); | 1133 ASSERT_TRUE(resizer.get()); |
| 1142 | 1134 |
| 1143 // Move |window| one pixel to the left of |window2|. Should snap to right. | 1135 // Move |window| one pixel to the left of |window2|. Should snap to right. |
| 1144 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0); | 1136 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0); |
| 1145 gfx::Rect expected(130, 160, 20, 50); | 1137 gfx::Rect expected(130, 160, 20, 50); |
| 1146 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); | 1138 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); |
| 1147 | 1139 |
| 1148 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 1140 gfx::Rect work_area( |
| 1149 window_.get())); | 1141 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get())); |
| 1150 | 1142 |
| 1151 // The initial y position of |window_|. | 1143 // The initial y position of |window_|. |
| 1152 int initial_y = 10; | 1144 int initial_y = 10; |
| 1153 // The drag position where the window is exactly attached to the bottom. | 1145 // The drag position where the window is exactly attached to the bottom. |
| 1154 int attach_y = work_area.bottom() - window_->bounds().height() - initial_y; | 1146 int attach_y = work_area.bottom() - window_->bounds().height() - initial_y; |
| 1155 | 1147 |
| 1156 // Dragging 10px above should not attach to the bottom. | 1148 // Dragging 10px above should not attach to the bottom. |
| 1157 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y - 10), 0); | 1149 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y - 10), 0); |
| 1158 expected.set_y(attach_y + initial_y - 10); | 1150 expected.set_y(attach_y + initial_y - 10); |
| 1159 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); | 1151 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 | 1406 |
| 1415 std::unique_ptr<WindowResizer> resizer( | 1407 std::unique_ptr<WindowResizer> resizer( |
| 1416 CreateResizerForTest(window_.get(), gfx::Point(), HTLEFT)); | 1408 CreateResizerForTest(window_.get(), gfx::Point(), HTLEFT)); |
| 1417 ASSERT_TRUE(resizer.get()); | 1409 ASSERT_TRUE(resizer.get()); |
| 1418 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); | 1410 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); |
| 1419 EXPECT_EQ("99,200 21x30", window_->bounds().ToString()); | 1411 EXPECT_EQ("99,200 21x30", window_->bounds().ToString()); |
| 1420 } | 1412 } |
| 1421 | 1413 |
| 1422 // Test that the user user moved window flag is getting properly set. | 1414 // Test that the user user moved window flag is getting properly set. |
| 1423 TEST_F(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) { | 1415 TEST_F(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) { |
| 1424 window_->SetBounds(gfx::Rect( 0, 50, 400, 200)); | 1416 window_->SetBounds(gfx::Rect(0, 50, 400, 200)); |
| 1425 window_->SetProperty(aura::client::kCanMaximizeKey, true); | 1417 window_->SetProperty(aura::client::kCanMaximizeKey, true); |
| 1426 | 1418 |
| 1427 std::vector<aura::Window*> no_attached_windows; | 1419 std::vector<aura::Window*> no_attached_windows; |
| 1428 // Check that an abort doesn't change anything. | 1420 // Check that an abort doesn't change anything. |
| 1429 { | 1421 { |
| 1430 std::unique_ptr<WindowResizer> resizer( | 1422 std::unique_ptr<WindowResizer> resizer( |
| 1431 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 1423 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
| 1432 ASSERT_TRUE(resizer.get()); | 1424 ASSERT_TRUE(resizer.get()); |
| 1433 // Move it 100 to the bottom. | 1425 // Move it 100 to the bottom. |
| 1434 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); | 1426 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 resizer->RevertDrag(); | 1508 resizer->RevertDrag(); |
| 1517 } | 1509 } |
| 1518 } | 1510 } |
| 1519 | 1511 |
| 1520 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { | 1512 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { |
| 1521 UpdateDisplay("600x800"); | 1513 UpdateDisplay("600x800"); |
| 1522 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1514 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1523 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1515 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1524 | 1516 |
| 1525 // Four 100x100 windows flush against eachother, starting at 100,100. | 1517 // Four 100x100 windows flush against eachother, starting at 100,100. |
| 1526 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1518 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1527 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1519 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
| 1528 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1520 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
| 1529 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); | 1521 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); |
| 1530 delegate2_.set_max_size(gfx::Size(101, 0)); | 1522 delegate2_.set_max_size(gfx::Size(101, 0)); |
| 1531 | 1523 |
| 1532 std::vector<aura::Window*> windows; | 1524 std::vector<aura::Window*> windows; |
| 1533 windows.push_back(window2_.get()); | 1525 windows.push_back(window2_.get()); |
| 1534 windows.push_back(window3_.get()); | 1526 windows.push_back(window3_.get()); |
| 1535 windows.push_back(window4_.get()); | 1527 windows.push_back(window4_.get()); |
| 1536 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1528 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1547 EXPECT_EQ("250,100 125x100", window3_->bounds().ToString()); | 1539 EXPECT_EQ("250,100 125x100", window3_->bounds().ToString()); |
| 1548 EXPECT_EQ("375,100 125x100", window4_->bounds().ToString()); | 1540 EXPECT_EQ("375,100 125x100", window4_->bounds().ToString()); |
| 1549 } | 1541 } |
| 1550 | 1542 |
| 1551 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxWidth) { | 1543 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxWidth) { |
| 1552 UpdateDisplay("600x800"); | 1544 UpdateDisplay("600x800"); |
| 1553 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1545 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1554 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1546 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1555 | 1547 |
| 1556 // Four 100x100 windows flush against eachother, starting at 100,100. | 1548 // Four 100x100 windows flush against eachother, starting at 100,100. |
| 1557 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1549 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1558 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1550 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
| 1559 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1551 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
| 1560 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); | 1552 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); |
| 1561 delegate2_.set_max_size(gfx::Size(101, 0)); | 1553 delegate2_.set_max_size(gfx::Size(101, 0)); |
| 1562 delegate3_.set_max_size(gfx::Size(101, 0)); | 1554 delegate3_.set_max_size(gfx::Size(101, 0)); |
| 1563 | 1555 |
| 1564 std::vector<aura::Window*> windows; | 1556 std::vector<aura::Window*> windows; |
| 1565 windows.push_back(window2_.get()); | 1557 windows.push_back(window2_.get()); |
| 1566 windows.push_back(window3_.get()); | 1558 windows.push_back(window3_.get()); |
| 1567 windows.push_back(window4_.get()); | 1559 windows.push_back(window4_.get()); |
| 1568 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1560 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 1569 window_.get(), gfx::Point(), HTRIGHT, | 1561 window_.get(), gfx::Point(), HTRIGHT, |
| 1570 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1562 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 1571 ASSERT_TRUE(resizer.get()); | 1563 ASSERT_TRUE(resizer.get()); |
| 1572 // Move it 52 to the left, which should contract w1 and expand w2-4. | 1564 // Move it 52 to the left, which should contract w1 and expand w2-4. |
| 1573 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); | 1565 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); |
| 1574 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); | 1566 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); |
| 1575 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); | 1567 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); |
| 1576 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); | 1568 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); |
| 1577 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); | 1569 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); |
| 1578 } | 1570 } |
| 1579 | 1571 |
| 1580 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) { | 1572 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) { |
| 1581 UpdateDisplay("600x800"); | 1573 UpdateDisplay("600x800"); |
| 1582 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1574 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1583 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1575 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1584 | 1576 |
| 1585 // Four 100x100 windows flush against eachother, starting at 100,100. | 1577 // Four 100x100 windows flush against eachother, starting at 100,100. |
| 1586 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1578 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1587 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1579 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
| 1588 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1580 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
| 1589 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1581 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
| 1590 delegate2_.set_max_size(gfx::Size(0, 101)); | 1582 delegate2_.set_max_size(gfx::Size(0, 101)); |
| 1591 delegate3_.set_max_size(gfx::Size(0, 101)); | 1583 delegate3_.set_max_size(gfx::Size(0, 101)); |
| 1592 | 1584 |
| 1593 std::vector<aura::Window*> windows; | 1585 std::vector<aura::Window*> windows; |
| 1594 windows.push_back(window2_.get()); | 1586 windows.push_back(window2_.get()); |
| 1595 windows.push_back(window3_.get()); | 1587 windows.push_back(window3_.get()); |
| 1596 windows.push_back(window4_.get()); | 1588 windows.push_back(window4_.get()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1612 #else | 1604 #else |
| 1613 #define MAYBE_DontExceedMinHeight DontExceedMinHeight | 1605 #define MAYBE_DontExceedMinHeight DontExceedMinHeight |
| 1614 #endif | 1606 #endif |
| 1615 | 1607 |
| 1616 TEST_F(WorkspaceWindowResizerTest, MAYBE_DontExceedMinHeight) { | 1608 TEST_F(WorkspaceWindowResizerTest, MAYBE_DontExceedMinHeight) { |
| 1617 UpdateDisplay("600x500"); | 1609 UpdateDisplay("600x500"); |
| 1618 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1610 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1619 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1611 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1620 | 1612 |
| 1621 // Four 100x100 windows flush against eachother, starting at 100,100. | 1613 // Four 100x100 windows flush against eachother, starting at 100,100. |
| 1622 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1614 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1623 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1615 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
| 1624 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1616 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
| 1625 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1617 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
| 1626 delegate2_.set_min_size(gfx::Size(0, 99)); | 1618 delegate2_.set_min_size(gfx::Size(0, 99)); |
| 1627 delegate3_.set_min_size(gfx::Size(0, 99)); | 1619 delegate3_.set_min_size(gfx::Size(0, 99)); |
| 1628 | 1620 |
| 1629 std::vector<aura::Window*> windows; | 1621 std::vector<aura::Window*> windows; |
| 1630 windows.push_back(window2_.get()); | 1622 windows.push_back(window2_.get()); |
| 1631 windows.push_back(window3_.get()); | 1623 windows.push_back(window3_.get()); |
| 1632 windows.push_back(window4_.get()); | 1624 windows.push_back(window4_.get()); |
| 1633 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1625 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 1634 window_.get(), gfx::Point(), HTBOTTOM, | 1626 window_.get(), gfx::Point(), HTBOTTOM, |
| 1635 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1627 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 1636 ASSERT_TRUE(resizer.get()); | 1628 ASSERT_TRUE(resizer.get()); |
| 1637 // Move it 52 down, which should expand w1 and contract w2-4. | 1629 // Move it 52 down, which should expand w1 and contract w2-4. |
| 1638 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); | 1630 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); |
| 1639 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); | 1631 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); |
| 1640 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); | 1632 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); |
| 1641 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); | 1633 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); |
| 1642 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); | 1634 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); |
| 1643 } | 1635 } |
| 1644 | 1636 |
| 1645 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { | 1637 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { |
| 1646 UpdateDisplay("600x800"); | 1638 UpdateDisplay("600x800"); |
| 1647 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1639 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1648 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1640 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1649 | 1641 |
| 1650 // Three 100x100 windows flush against eachother, starting at 100,100. | 1642 // Three 100x100 windows flush against eachother, starting at 100,100. |
| 1651 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1643 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1652 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1644 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
| 1653 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1645 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
| 1654 delegate3_.set_max_size(gfx::Size(101, 0)); | 1646 delegate3_.set_max_size(gfx::Size(101, 0)); |
| 1655 | 1647 |
| 1656 std::vector<aura::Window*> windows; | 1648 std::vector<aura::Window*> windows; |
| 1657 windows.push_back(window2_.get()); | 1649 windows.push_back(window2_.get()); |
| 1658 windows.push_back(window3_.get()); | 1650 windows.push_back(window3_.get()); |
| 1659 windows.push_back(window4_.get()); | 1651 windows.push_back(window4_.get()); |
| 1660 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1652 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 1661 window_.get(), gfx::Point(), HTRIGHT, | 1653 window_.get(), gfx::Point(), HTRIGHT, |
| 1662 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1654 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 1663 ASSERT_TRUE(resizer.get()); | 1655 ASSERT_TRUE(resizer.get()); |
| 1664 // Move it 51 to the left, which should contract w1 and expand w2-3. | 1656 // Move it 51 to the left, which should contract w1 and expand w2-3. |
| 1665 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); | 1657 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); |
| 1666 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); | 1658 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); |
| 1667 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); | 1659 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); |
| 1668 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1660 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
| 1669 } | 1661 } |
| 1670 | 1662 |
| 1671 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { | 1663 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { |
| 1672 UpdateDisplay("600x800"); | 1664 UpdateDisplay("600x800"); |
| 1673 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1665 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1674 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1666 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1675 | 1667 |
| 1676 // Three 100x100 windows flush against eachother, starting at 100,100. | 1668 // Three 100x100 windows flush against eachother, starting at 100,100. |
| 1677 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1669 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1678 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1670 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
| 1679 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1671 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
| 1680 delegate2_.set_max_size(gfx::Size(101, 0)); | 1672 delegate2_.set_max_size(gfx::Size(101, 0)); |
| 1681 delegate3_.set_max_size(gfx::Size(101, 0)); | 1673 delegate3_.set_max_size(gfx::Size(101, 0)); |
| 1682 | 1674 |
| 1683 std::vector<aura::Window*> windows; | 1675 std::vector<aura::Window*> windows; |
| 1684 windows.push_back(window2_.get()); | 1676 windows.push_back(window2_.get()); |
| 1685 windows.push_back(window3_.get()); | 1677 windows.push_back(window3_.get()); |
| 1686 windows.push_back(window4_.get()); | 1678 windows.push_back(window4_.get()); |
| 1687 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1679 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1701 #else | 1693 #else |
| 1702 #define MAYBE_MainWindowHonoursMaxWidth MainWindowHonoursMaxWidth | 1694 #define MAYBE_MainWindowHonoursMaxWidth MainWindowHonoursMaxWidth |
| 1703 #endif | 1695 #endif |
| 1704 | 1696 |
| 1705 TEST_F(WorkspaceWindowResizerTest, MAYBE_MainWindowHonoursMaxWidth) { | 1697 TEST_F(WorkspaceWindowResizerTest, MAYBE_MainWindowHonoursMaxWidth) { |
| 1706 UpdateDisplay("400x800"); | 1698 UpdateDisplay("400x800"); |
| 1707 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1699 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1708 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1700 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1709 | 1701 |
| 1710 // Three 100x100 windows flush against eachother, starting at 100,100. | 1702 // Three 100x100 windows flush against eachother, starting at 100,100. |
| 1711 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1703 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1712 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1704 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
| 1713 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1705 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
| 1714 delegate_.set_max_size(gfx::Size(102, 0)); | 1706 delegate_.set_max_size(gfx::Size(102, 0)); |
| 1715 | 1707 |
| 1716 std::vector<aura::Window*> windows; | 1708 std::vector<aura::Window*> windows; |
| 1717 windows.push_back(window2_.get()); | 1709 windows.push_back(window2_.get()); |
| 1718 windows.push_back(window3_.get()); | 1710 windows.push_back(window3_.get()); |
| 1719 windows.push_back(window4_.get()); | 1711 windows.push_back(window4_.get()); |
| 1720 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1712 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 1721 window_.get(), gfx::Point(), HTRIGHT, | 1713 window_.get(), gfx::Point(), HTRIGHT, |
| 1722 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1714 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 1723 ASSERT_TRUE(resizer.get()); | 1715 ASSERT_TRUE(resizer.get()); |
| 1724 // Move it 50 to the right, which should expand w1 and contract w2-3, as they | 1716 // Move it 50 to the right, which should expand w1 and contract w2-3, as they |
| 1725 // won't fit in the root window in their original sizes. | 1717 // won't fit in the root window in their original sizes. |
| 1726 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); | 1718 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); |
| 1727 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); | 1719 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); |
| 1728 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); | 1720 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); |
| 1729 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); | 1721 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); |
| 1730 } | 1722 } |
| 1731 | 1723 |
| 1732 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { | 1724 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { |
| 1733 UpdateDisplay("400x800"); | 1725 UpdateDisplay("400x800"); |
| 1734 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1726 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1735 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1727 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1736 | 1728 |
| 1737 // Three 100x100 windows flush against eachother, starting at 100,100. | 1729 // Three 100x100 windows flush against eachother, starting at 100,100. |
| 1738 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1730 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1739 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1731 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
| 1740 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1732 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
| 1741 delegate_.set_min_size(gfx::Size(98, 0)); | 1733 delegate_.set_min_size(gfx::Size(98, 0)); |
| 1742 | 1734 |
| 1743 std::vector<aura::Window*> windows; | 1735 std::vector<aura::Window*> windows; |
| 1744 windows.push_back(window2_.get()); | 1736 windows.push_back(window2_.get()); |
| 1745 windows.push_back(window3_.get()); | 1737 windows.push_back(window3_.get()); |
| 1746 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1738 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 1747 window_.get(), gfx::Point(), HTRIGHT, | 1739 window_.get(), gfx::Point(), HTRIGHT, |
| 1748 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1740 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1763 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), | 1755 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), |
| 1764 touch_resize_window_->bounds().ToString()); | 1756 touch_resize_window_->bounds().ToString()); |
| 1765 | 1757 |
| 1766 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1758 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 1767 touch_resize_window_.get()); | 1759 touch_resize_window_.get()); |
| 1768 | 1760 |
| 1769 // Drag out of the right border a bit and check if the border is aligned with | 1761 // Drag out of the right border a bit and check if the border is aligned with |
| 1770 // the touch point. | 1762 // the touch point. |
| 1771 generator.GestureScrollSequence(gfx::Point(715, kRootHeight / 2), | 1763 generator.GestureScrollSequence(gfx::Point(715, kRootHeight / 2), |
| 1772 gfx::Point(725, kRootHeight / 2), | 1764 gfx::Point(725, kRootHeight / 2), |
| 1773 base::TimeDelta::FromMilliseconds(10), | 1765 base::TimeDelta::FromMilliseconds(10), 5); |
| 1774 5); | |
| 1775 EXPECT_EQ(gfx::Rect(100, 100, 625, kRootHeight - 200).ToString(), | 1766 EXPECT_EQ(gfx::Rect(100, 100, 625, kRootHeight - 200).ToString(), |
| 1776 touch_resize_window_->bounds().ToString()); | 1767 touch_resize_window_->bounds().ToString()); |
| 1777 // Drag more, but stop before being snapped to the edge. | 1768 // Drag more, but stop before being snapped to the edge. |
| 1778 generator.GestureScrollSequence(gfx::Point(725, kRootHeight / 2), | 1769 generator.GestureScrollSequence(gfx::Point(725, kRootHeight / 2), |
| 1779 gfx::Point(760, kRootHeight / 2), | 1770 gfx::Point(760, kRootHeight / 2), |
| 1780 base::TimeDelta::FromMilliseconds(10), | 1771 base::TimeDelta::FromMilliseconds(10), 5); |
| 1781 5); | |
| 1782 EXPECT_EQ(gfx::Rect(100, 100, 660, kRootHeight - 200).ToString(), | 1772 EXPECT_EQ(gfx::Rect(100, 100, 660, kRootHeight - 200).ToString(), |
| 1783 touch_resize_window_->bounds().ToString()); | 1773 touch_resize_window_->bounds().ToString()); |
| 1784 // Drag even more to snap to the edge. | 1774 // Drag even more to snap to the edge. |
| 1785 generator.GestureScrollSequence(gfx::Point(760, kRootHeight / 2), | 1775 generator.GestureScrollSequence(gfx::Point(760, kRootHeight / 2), |
| 1786 gfx::Point(775, kRootHeight / 2), | 1776 gfx::Point(775, kRootHeight / 2), |
| 1787 base::TimeDelta::FromMilliseconds(10), | 1777 base::TimeDelta::FromMilliseconds(10), 5); |
| 1788 5); | |
| 1789 EXPECT_EQ(gfx::Rect(100, 100, 700, kRootHeight - 200).ToString(), | 1778 EXPECT_EQ(gfx::Rect(100, 100, 700, kRootHeight - 200).ToString(), |
| 1790 touch_resize_window_->bounds().ToString()); | 1779 touch_resize_window_->bounds().ToString()); |
| 1791 } | 1780 } |
| 1792 | 1781 |
| 1793 TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_LEFT) { | 1782 TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_LEFT) { |
| 1794 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1783 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1795 | 1784 |
| 1796 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTLEFT); | 1785 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTLEFT); |
| 1797 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), | 1786 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), |
| 1798 touch_resize_window_->bounds().ToString()); | 1787 touch_resize_window_->bounds().ToString()); |
| 1799 | 1788 |
| 1800 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1789 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 1801 touch_resize_window_.get()); | 1790 touch_resize_window_.get()); |
| 1802 | 1791 |
| 1803 // Drag out of the left border a bit and check if the border is aligned with | 1792 // Drag out of the left border a bit and check if the border is aligned with |
| 1804 // the touch point. | 1793 // the touch point. |
| 1805 generator.GestureScrollSequence(gfx::Point(85, kRootHeight / 2), | 1794 generator.GestureScrollSequence(gfx::Point(85, kRootHeight / 2), |
| 1806 gfx::Point(75, kRootHeight / 2), | 1795 gfx::Point(75, kRootHeight / 2), |
| 1807 base::TimeDelta::FromMilliseconds(10), | 1796 base::TimeDelta::FromMilliseconds(10), 5); |
| 1808 5); | |
| 1809 EXPECT_EQ(gfx::Rect(75, 100, 625, kRootHeight - 200).ToString(), | 1797 EXPECT_EQ(gfx::Rect(75, 100, 625, kRootHeight - 200).ToString(), |
| 1810 touch_resize_window_->bounds().ToString()); | 1798 touch_resize_window_->bounds().ToString()); |
| 1811 // Drag more, but stop before being snapped to the edge. | 1799 // Drag more, but stop before being snapped to the edge. |
| 1812 generator.GestureScrollSequence(gfx::Point(75, kRootHeight / 2), | 1800 generator.GestureScrollSequence(gfx::Point(75, kRootHeight / 2), |
| 1813 gfx::Point(40, kRootHeight / 2), | 1801 gfx::Point(40, kRootHeight / 2), |
| 1814 base::TimeDelta::FromMilliseconds(10), | 1802 base::TimeDelta::FromMilliseconds(10), 5); |
| 1815 5); | |
| 1816 EXPECT_EQ(gfx::Rect(40, 100, 660, kRootHeight - 200).ToString(), | 1803 EXPECT_EQ(gfx::Rect(40, 100, 660, kRootHeight - 200).ToString(), |
| 1817 touch_resize_window_->bounds().ToString()); | 1804 touch_resize_window_->bounds().ToString()); |
| 1818 // Drag even more to snap to the edge. | 1805 // Drag even more to snap to the edge. |
| 1819 generator.GestureScrollSequence(gfx::Point(40, kRootHeight / 2), | 1806 generator.GestureScrollSequence(gfx::Point(40, kRootHeight / 2), |
| 1820 gfx::Point(25, kRootHeight / 2), | 1807 gfx::Point(25, kRootHeight / 2), |
| 1821 base::TimeDelta::FromMilliseconds(10), | 1808 base::TimeDelta::FromMilliseconds(10), 5); |
| 1822 5); | |
| 1823 EXPECT_EQ(gfx::Rect(0, 100, 700, kRootHeight - 200).ToString(), | 1809 EXPECT_EQ(gfx::Rect(0, 100, 700, kRootHeight - 200).ToString(), |
| 1824 touch_resize_window_->bounds().ToString()); | 1810 touch_resize_window_->bounds().ToString()); |
| 1825 } | 1811 } |
| 1826 | 1812 |
| 1827 TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_TOP) { | 1813 TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_TOP) { |
| 1828 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1814 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1829 | 1815 |
| 1830 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTTOP); | 1816 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTTOP); |
| 1831 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), | 1817 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), |
| 1832 touch_resize_window_->bounds().ToString()); | 1818 touch_resize_window_->bounds().ToString()); |
| 1833 | 1819 |
| 1834 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1820 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 1835 touch_resize_window_.get()); | 1821 touch_resize_window_.get()); |
| 1836 | 1822 |
| 1837 // Drag out of the top border a bit and check if the border is aligned with | 1823 // Drag out of the top border a bit and check if the border is aligned with |
| 1838 // the touch point. | 1824 // the touch point. |
| 1839 generator.GestureScrollSequence(gfx::Point(400, 85), | 1825 generator.GestureScrollSequence(gfx::Point(400, 85), gfx::Point(400, 75), |
| 1840 gfx::Point(400, 75), | 1826 base::TimeDelta::FromMilliseconds(10), 5); |
| 1841 base::TimeDelta::FromMilliseconds(10), | |
| 1842 5); | |
| 1843 EXPECT_EQ(gfx::Rect(100, 75, 600, kRootHeight - 175).ToString(), | 1827 EXPECT_EQ(gfx::Rect(100, 75, 600, kRootHeight - 175).ToString(), |
| 1844 touch_resize_window_->bounds().ToString()); | 1828 touch_resize_window_->bounds().ToString()); |
| 1845 // Drag more, but stop before being snapped to the edge. | 1829 // Drag more, but stop before being snapped to the edge. |
| 1846 generator.GestureScrollSequence(gfx::Point(400, 75), | 1830 generator.GestureScrollSequence(gfx::Point(400, 75), gfx::Point(400, 40), |
| 1847 gfx::Point(400, 40), | 1831 base::TimeDelta::FromMilliseconds(10), 5); |
| 1848 base::TimeDelta::FromMilliseconds(10), | |
| 1849 5); | |
| 1850 EXPECT_EQ(gfx::Rect(100, 40, 600, kRootHeight - 140).ToString(), | 1832 EXPECT_EQ(gfx::Rect(100, 40, 600, kRootHeight - 140).ToString(), |
| 1851 touch_resize_window_->bounds().ToString()); | 1833 touch_resize_window_->bounds().ToString()); |
| 1852 // Drag even more to snap to the edge. | 1834 // Drag even more to snap to the edge. |
| 1853 generator.GestureScrollSequence(gfx::Point(400, 40), | 1835 generator.GestureScrollSequence(gfx::Point(400, 40), gfx::Point(400, 25), |
| 1854 gfx::Point(400, 25), | 1836 base::TimeDelta::FromMilliseconds(10), 5); |
| 1855 base::TimeDelta::FromMilliseconds(10), | |
| 1856 5); | |
| 1857 EXPECT_EQ(gfx::Rect(100, 0, 600, kRootHeight - 100).ToString(), | 1837 EXPECT_EQ(gfx::Rect(100, 0, 600, kRootHeight - 100).ToString(), |
| 1858 touch_resize_window_->bounds().ToString()); | 1838 touch_resize_window_->bounds().ToString()); |
| 1859 } | 1839 } |
| 1860 | 1840 |
| 1861 TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_BOTTOM) { | 1841 TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_BOTTOM) { |
| 1862 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1842 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1863 | 1843 |
| 1864 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTBOTTOM); | 1844 InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTBOTTOM); |
| 1865 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), | 1845 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(), |
| 1866 touch_resize_window_->bounds().ToString()); | 1846 touch_resize_window_->bounds().ToString()); |
| 1867 | 1847 |
| 1868 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1848 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 1869 touch_resize_window_.get()); | 1849 touch_resize_window_.get()); |
| 1870 | 1850 |
| 1871 // Drag out of the bottom border a bit and check if the border is aligned with | 1851 // Drag out of the bottom border a bit and check if the border is aligned with |
| 1872 // the touch point. | 1852 // the touch point. |
| 1873 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 85), | 1853 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 85), |
| 1874 gfx::Point(400, kRootHeight - 75), | 1854 gfx::Point(400, kRootHeight - 75), |
| 1875 base::TimeDelta::FromMilliseconds(10), | 1855 base::TimeDelta::FromMilliseconds(10), 5); |
| 1876 5); | |
| 1877 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 175).ToString(), | 1856 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 175).ToString(), |
| 1878 touch_resize_window_->bounds().ToString()); | 1857 touch_resize_window_->bounds().ToString()); |
| 1879 // Drag more, but stop before being snapped to the edge. | 1858 // Drag more, but stop before being snapped to the edge. |
| 1880 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 75), | 1859 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 75), |
| 1881 gfx::Point(400, kRootHeight - 40), | 1860 gfx::Point(400, kRootHeight - 40), |
| 1882 base::TimeDelta::FromMilliseconds(10), | 1861 base::TimeDelta::FromMilliseconds(10), 5); |
| 1883 5); | |
| 1884 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 140).ToString(), | 1862 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 140).ToString(), |
| 1885 touch_resize_window_->bounds().ToString()); | 1863 touch_resize_window_->bounds().ToString()); |
| 1886 // Drag even more to snap to the edge. | 1864 // Drag even more to snap to the edge. |
| 1887 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), | 1865 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), |
| 1888 gfx::Point(400, kRootHeight - 25), | 1866 gfx::Point(400, kRootHeight - 25), |
| 1889 base::TimeDelta::FromMilliseconds(10), | 1867 base::TimeDelta::FromMilliseconds(10), 5); |
| 1890 5); | |
| 1891 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), | 1868 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), |
| 1892 touch_resize_window_->bounds().ToString()); | 1869 touch_resize_window_->bounds().ToString()); |
| 1893 } | 1870 } |
| 1894 | 1871 |
| 1895 } // namespace ash | 1872 } // namespace ash |
| OLD | NEW |