| 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/wm/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 public: | 67 public: |
| 68 WorkspaceWindowResizerTest() : window_(NULL) {} | 68 WorkspaceWindowResizerTest() : window_(NULL) {} |
| 69 virtual ~WorkspaceWindowResizerTest() {} | 69 virtual ~WorkspaceWindowResizerTest() {} |
| 70 | 70 |
| 71 virtual void SetUp() OVERRIDE { | 71 virtual void SetUp() OVERRIDE { |
| 72 AshTestBase::SetUp(); | 72 AshTestBase::SetUp(); |
| 73 UpdateDisplay(StringPrintf("800x%d", kRootHeight)); | 73 UpdateDisplay(StringPrintf("800x%d", kRootHeight)); |
| 74 | 74 |
| 75 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 75 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
| 76 gfx::Rect root_bounds(root->bounds()); | 76 gfx::Rect root_bounds(root->bounds()); |
| 77 #if defined(OS_WIN) |
| 78 // RootWindow and Display can't resize on Windows Ash. |
| 79 // http://crbug.com/165962 |
| 77 EXPECT_EQ(kRootHeight, root_bounds.height()); | 80 EXPECT_EQ(kRootHeight, root_bounds.height()); |
| 81 #endif |
| 78 EXPECT_EQ(800, root_bounds.width()); | 82 EXPECT_EQ(800, root_bounds.width()); |
| 79 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 83 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 80 window_.reset(new aura::Window(&delegate_)); | 84 window_.reset(new aura::Window(&delegate_)); |
| 81 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); | 85 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); |
| 82 window_->Init(ui::LAYER_NOT_DRAWN); | 86 window_->Init(ui::LAYER_NOT_DRAWN); |
| 83 SetDefaultParentByPrimaryRootWindow(window_.get()); | 87 SetDefaultParentByPrimaryRootWindow(window_.get()); |
| 84 window_->set_id(1); | 88 window_->set_id(1); |
| 85 | 89 |
| 86 window2_.reset(new aura::Window(&delegate2_)); | 90 window2_.reset(new aura::Window(&delegate2_)); |
| 87 window2_->SetType(aura::client::WINDOW_TYPE_NORMAL); | 91 window2_->SetType(aura::client::WINDOW_TYPE_NORMAL); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 EXPECT_EQ("0,50 400x300", window_->bounds().ToString()); | 363 EXPECT_EQ("0,50 400x300", window_->bounds().ToString()); |
| 360 EXPECT_EQ("0,350 200x100", window2_->bounds().ToString()); | 364 EXPECT_EQ("0,350 200x100", window2_->bounds().ToString()); |
| 361 | 365 |
| 362 // Revert and make sure everything moves back. | 366 // Revert and make sure everything moves back. |
| 363 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0); | 367 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0); |
| 364 resizer->RevertDrag(); | 368 resizer->RevertDrag(); |
| 365 EXPECT_EQ("0,50 400x200", window_->bounds().ToString()); | 369 EXPECT_EQ("0,50 400x200", window_->bounds().ToString()); |
| 366 EXPECT_EQ("0,250 200x100", window2_->bounds().ToString()); | 370 EXPECT_EQ("0,250 200x100", window2_->bounds().ToString()); |
| 367 } | 371 } |
| 368 | 372 |
| 373 #if defined(OS_WIN) |
| 374 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 375 #define MAYBE_AttachedResize_BOTTOM_3 DISABLED_AttachedResize_BOTTOM_3 |
| 376 #else |
| 377 #define MAYBE_AttachedResize_BOTTOM_3 AttachedResize_BOTTOM_3 |
| 378 #endif |
| 379 |
| 369 // Assertions around attached window resize dragging from the bottom with 3 | 380 // Assertions around attached window resize dragging from the bottom with 3 |
| 370 // windows. | 381 // windows. |
| 371 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) { | 382 TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) { |
| 372 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 383 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
| 373 root->SetHostSize(gfx::Size(600, 800)); | 384 root->SetHostSize(gfx::Size(600, 800)); |
| 374 | 385 |
| 375 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 386 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 376 | 387 |
| 377 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); | 388 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); |
| 378 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); | 389 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); |
| 379 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); | 390 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); |
| 380 delegate2_.set_min_size(gfx::Size(50, 52)); | 391 delegate2_.set_min_size(gfx::Size(50, 52)); |
| 381 delegate3_.set_min_size(gfx::Size(50, 38)); | 392 delegate3_.set_min_size(gfx::Size(50, 38)); |
| 382 | 393 |
| 383 std::vector<aura::Window*> windows; | 394 std::vector<aura::Window*> windows; |
| 384 windows.push_back(window2_.get()); | 395 windows.push_back(window2_.get()); |
| 385 windows.push_back(window3_.get()); | 396 windows.push_back(window3_.get()); |
| 386 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 397 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 387 window_.get(), gfx::Point(), HTBOTTOM, windows)); | 398 window_.get(), gfx::Point(), HTBOTTOM, windows)); |
| 388 ASSERT_TRUE(resizer.get()); | 399 ASSERT_TRUE(resizer.get()); |
| 389 // Move it 100 to the right, which should expand w1 and push w2 and w3. | 400 // Move it 100 down, which should expand w1 and push w2 and w3. |
| 390 resizer->Drag(CalculateDragPoint(*resizer, -10, 100), 0); | 401 resizer->Drag(CalculateDragPoint(*resizer, -10, 100), 0); |
| 391 EXPECT_EQ("300,100 300x300", window_->bounds().ToString()); | 402 EXPECT_EQ("300,100 300x300", window_->bounds().ToString()); |
| 392 EXPECT_EQ("300,400 200x150", window2_->bounds().ToString()); | 403 EXPECT_EQ("300,400 200x150", window2_->bounds().ToString()); |
| 393 EXPECT_EQ("300,550 200x100", window3_->bounds().ToString()); | 404 EXPECT_EQ("300,550 200x100", window3_->bounds().ToString()); |
| 394 | 405 |
| 395 // Move it 296 things should compress. | 406 // Move it 296 things should compress. |
| 396 resizer->Drag(CalculateDragPoint(*resizer, -10, 296), 0); | 407 resizer->Drag(CalculateDragPoint(*resizer, -10, 296), 0); |
| 397 EXPECT_EQ("300,100 300x496", window_->bounds().ToString()); | 408 EXPECT_EQ("300,100 300x496", window_->bounds().ToString()); |
| 398 EXPECT_EQ("300,596 200x123", window2_->bounds().ToString()); | 409 EXPECT_EQ("300,596 200x123", window2_->bounds().ToString()); |
| 399 EXPECT_EQ("300,719 200x81", window3_->bounds().ToString()); | 410 EXPECT_EQ("300,719 200x81", window3_->bounds().ToString()); |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 window_.get(), gfx::Point(), HTBOTTOM, windows)); | 1311 window_.get(), gfx::Point(), HTBOTTOM, windows)); |
| 1301 ASSERT_TRUE(resizer.get()); | 1312 ASSERT_TRUE(resizer.get()); |
| 1302 // Move it 52 up, which should contract w1 and expand w2-4. | 1313 // Move it 52 up, which should contract w1 and expand w2-4. |
| 1303 resizer->Drag(CalculateDragPoint(*resizer, 0, -52), 0); | 1314 resizer->Drag(CalculateDragPoint(*resizer, 0, -52), 0); |
| 1304 EXPECT_EQ("100,100 100x48", window_->bounds().ToString()); | 1315 EXPECT_EQ("100,100 100x48", window_->bounds().ToString()); |
| 1305 EXPECT_EQ("100,148 100x101", window2_->bounds().ToString()); | 1316 EXPECT_EQ("100,148 100x101", window2_->bounds().ToString()); |
| 1306 EXPECT_EQ("100,249 100x101", window3_->bounds().ToString()); | 1317 EXPECT_EQ("100,249 100x101", window3_->bounds().ToString()); |
| 1307 EXPECT_EQ("100,350 100x150", window4_->bounds().ToString()); | 1318 EXPECT_EQ("100,350 100x150", window4_->bounds().ToString()); |
| 1308 } | 1319 } |
| 1309 | 1320 |
| 1310 TEST_F(WorkspaceWindowResizerTest, DontExceedMinHeight) { | 1321 #if defined(OS_WIN) |
| 1322 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 1323 #define MAYBE_DontExceedMinHeight DISABLED_DontExceedMinHeight |
| 1324 #else |
| 1325 #define MAYBE_DontExceedMinHeight DontExceedMinHeight |
| 1326 #endif |
| 1327 |
| 1328 TEST_F(WorkspaceWindowResizerTest, MAYBE_DontExceedMinHeight) { |
| 1311 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 1329 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
| 1312 root->SetHostSize(gfx::Size(600, 500)); | 1330 root->SetHostSize(gfx::Size(600, 500)); |
| 1313 | 1331 |
| 1314 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1332 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1315 | 1333 |
| 1316 // Four 100x100 windows flush against eachother, starting at 100,100. | 1334 // Four 100x100 windows flush against eachother, starting at 100,100. |
| 1317 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1335 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
| 1318 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1336 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
| 1319 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1337 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
| 1320 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1338 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1400 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 1383 window_.get(), gfx::Point(), HTRIGHT, windows)); | 1401 window_.get(), gfx::Point(), HTRIGHT, windows)); |
| 1384 ASSERT_TRUE(resizer.get()); | 1402 ASSERT_TRUE(resizer.get()); |
| 1385 // Move it 52 to the left, which should contract w1 and expand and move w2-3. | 1403 // Move it 52 to the left, which should contract w1 and expand and move w2-3. |
| 1386 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); | 1404 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); |
| 1387 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); | 1405 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); |
| 1388 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); | 1406 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); |
| 1389 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); | 1407 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); |
| 1390 } | 1408 } |
| 1391 | 1409 |
| 1392 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMaxWidth) { | 1410 #if defined(OS_WIN) |
| 1411 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 1412 #define MAYBE_MainWindowHonoursMaxWidth DISABLED_MainWindowHonoursMaxWidth |
| 1413 #else |
| 1414 #define MAYBE_MainWindowHonoursMaxWidth MainWindowHonoursMaxWidth |
| 1415 #endif |
| 1416 |
| 1417 TEST_F(WorkspaceWindowResizerTest, MAYBE_MainWindowHonoursMaxWidth) { |
| 1393 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 1418 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
| 1394 root->SetHostSize(gfx::Size(400, 800)); | 1419 root->SetHostSize(gfx::Size(400, 800)); |
| 1395 | 1420 |
| 1396 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1421 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1397 | 1422 |
| 1398 // Three 100x100 windows flush against eachother, starting at 100,100. | 1423 // Three 100x100 windows flush against eachother, starting at 100,100. |
| 1399 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1424 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
| 1400 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1425 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
| 1401 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1426 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
| 1402 delegate_.set_max_size(gfx::Size(102, 0)); | 1427 delegate_.set_max_size(gfx::Size(102, 0)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 ASSERT_TRUE(resizer.get()); | 1461 ASSERT_TRUE(resizer.get()); |
| 1437 // Move it 50 to the left, which should contract w1 and expand w2-3. | 1462 // Move it 50 to the left, which should contract w1 and expand w2-3. |
| 1438 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); | 1463 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); |
| 1439 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); | 1464 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); |
| 1440 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); | 1465 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); |
| 1441 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1466 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
| 1442 } | 1467 } |
| 1443 | 1468 |
| 1444 } // namespace internal | 1469 } // namespace internal |
| 1445 } // namespace ash | 1470 } // namespace ash |
| OLD | NEW |