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