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/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 #if defined(OS_WIN) | 373 #if defined(OS_WIN) |
374 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 374 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
375 #define MAYBE_AttachedResize_BOTTOM_3 DISABLED_AttachedResize_BOTTOM_3 | 375 #define MAYBE_AttachedResize_BOTTOM_3 DISABLED_AttachedResize_BOTTOM_3 |
376 #else | 376 #else |
377 #define MAYBE_AttachedResize_BOTTOM_3 AttachedResize_BOTTOM_3 | 377 #define MAYBE_AttachedResize_BOTTOM_3 AttachedResize_BOTTOM_3 |
378 #endif | 378 #endif |
379 | 379 |
380 // Assertions around attached window resize dragging from the bottom with 3 | 380 // Assertions around attached window resize dragging from the bottom with 3 |
381 // windows. | 381 // windows. |
382 TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) { | 382 TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) { |
| 383 UpdateDisplay("600x800"); |
383 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 384 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
384 root->SetHostSize(gfx::Size(600, 800)); | |
385 | |
386 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 385 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
387 | 386 |
388 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); | 387 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); |
389 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); | 388 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); |
390 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); | 389 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); |
391 delegate2_.set_min_size(gfx::Size(50, 52)); | 390 delegate2_.set_min_size(gfx::Size(50, 52)); |
392 delegate3_.set_min_size(gfx::Size(50, 38)); | 391 delegate3_.set_min_size(gfx::Size(50, 38)); |
393 | 392 |
394 std::vector<aura::Window*> windows; | 393 std::vector<aura::Window*> windows; |
395 windows.push_back(window2_.get()); | 394 windows.push_back(window2_.get()); |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 delegate_.set_max_size(gfx::Size(300, 200)); | 1256 delegate_.set_max_size(gfx::Size(300, 200)); |
1258 | 1257 |
1259 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1258 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
1260 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 1259 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
1261 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); | 1260 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); |
1262 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | 1261 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); |
1263 } | 1262 } |
1264 } | 1263 } |
1265 | 1264 |
1266 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { | 1265 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { |
| 1266 UpdateDisplay("600x800"); |
1267 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 1267 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
1268 root->SetHostSize(gfx::Size(600, 800)); | |
1269 | |
1270 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1268 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1271 | 1269 |
1272 // Four 100x100 windows flush against eachother, starting at 100,100. | 1270 // Four 100x100 windows flush against eachother, starting at 100,100. |
1273 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1271 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1274 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1272 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1275 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1273 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1276 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); | 1274 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); |
1277 delegate2_.set_max_size(gfx::Size(101, 0)); | 1275 delegate2_.set_max_size(gfx::Size(101, 0)); |
1278 | 1276 |
1279 std::vector<aura::Window*> windows; | 1277 std::vector<aura::Window*> windows; |
1280 windows.push_back(window2_.get()); | 1278 windows.push_back(window2_.get()); |
1281 windows.push_back(window3_.get()); | 1279 windows.push_back(window3_.get()); |
1282 windows.push_back(window4_.get()); | 1280 windows.push_back(window4_.get()); |
1283 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1281 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
1284 window_.get(), gfx::Point(), HTRIGHT, windows)); | 1282 window_.get(), gfx::Point(), HTRIGHT, windows)); |
1285 ASSERT_TRUE(resizer.get()); | 1283 ASSERT_TRUE(resizer.get()); |
1286 // Move it 51 to the left, which should contract w1 and expand w2-4. | 1284 // Move it 51 to the left, which should contract w1 and expand w2-4. |
1287 // w2 will hit its max size straight away, and in doing so will leave extra | 1285 // w2 will hit its max size straight away, and in doing so will leave extra |
1288 // pixels that a naive implementation may award to the rightmost window. A | 1286 // pixels that a naive implementation may award to the rightmost window. A |
1289 // fair implementation will give 25 pixels to each of the other windows. | 1287 // fair implementation will give 25 pixels to each of the other windows. |
1290 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); | 1288 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); |
1291 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); | 1289 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); |
1292 EXPECT_EQ("149,100 101x100", window2_->bounds().ToString()); | 1290 EXPECT_EQ("149,100 101x100", window2_->bounds().ToString()); |
1293 EXPECT_EQ("250,100 125x100", window3_->bounds().ToString()); | 1291 EXPECT_EQ("250,100 125x100", window3_->bounds().ToString()); |
1294 EXPECT_EQ("375,100 125x100", window4_->bounds().ToString()); | 1292 EXPECT_EQ("375,100 125x100", window4_->bounds().ToString()); |
1295 } | 1293 } |
1296 | 1294 |
1297 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxWidth) { | 1295 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxWidth) { |
| 1296 UpdateDisplay("600x800"); |
1298 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 1297 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
1299 root->SetHostSize(gfx::Size(600, 800)); | |
1300 | |
1301 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1298 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1302 | 1299 |
1303 // Four 100x100 windows flush against eachother, starting at 100,100. | 1300 // Four 100x100 windows flush against eachother, starting at 100,100. |
1304 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1301 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1305 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1302 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1306 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1303 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1307 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); | 1304 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); |
1308 delegate2_.set_max_size(gfx::Size(101, 0)); | 1305 delegate2_.set_max_size(gfx::Size(101, 0)); |
1309 delegate3_.set_max_size(gfx::Size(101, 0)); | 1306 delegate3_.set_max_size(gfx::Size(101, 0)); |
1310 | 1307 |
1311 std::vector<aura::Window*> windows; | 1308 std::vector<aura::Window*> windows; |
1312 windows.push_back(window2_.get()); | 1309 windows.push_back(window2_.get()); |
1313 windows.push_back(window3_.get()); | 1310 windows.push_back(window3_.get()); |
1314 windows.push_back(window4_.get()); | 1311 windows.push_back(window4_.get()); |
1315 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1312 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
1316 window_.get(), gfx::Point(), HTRIGHT, windows)); | 1313 window_.get(), gfx::Point(), HTRIGHT, windows)); |
1317 ASSERT_TRUE(resizer.get()); | 1314 ASSERT_TRUE(resizer.get()); |
1318 // Move it 52 to the left, which should contract w1 and expand w2-4. | 1315 // Move it 52 to the left, which should contract w1 and expand w2-4. |
1319 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); | 1316 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); |
1320 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); | 1317 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); |
1321 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); | 1318 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); |
1322 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); | 1319 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); |
1323 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); | 1320 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); |
1324 } | 1321 } |
1325 | 1322 |
1326 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) { | 1323 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) { |
| 1324 UpdateDisplay("600x800"); |
1327 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 1325 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
1328 root->SetHostSize(gfx::Size(600, 800)); | |
1329 | |
1330 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1326 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1331 | 1327 |
1332 // Four 100x100 windows flush against eachother, starting at 100,100. | 1328 // Four 100x100 windows flush against eachother, starting at 100,100. |
1333 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1329 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1334 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1330 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
1335 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1331 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
1336 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1332 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
1337 delegate2_.set_max_size(gfx::Size(0, 101)); | 1333 delegate2_.set_max_size(gfx::Size(0, 101)); |
1338 delegate3_.set_max_size(gfx::Size(0, 101)); | 1334 delegate3_.set_max_size(gfx::Size(0, 101)); |
1339 | 1335 |
(...skipping 13 matching lines...) Expand all Loading... |
1353 } | 1349 } |
1354 | 1350 |
1355 #if defined(OS_WIN) | 1351 #if defined(OS_WIN) |
1356 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 1352 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
1357 #define MAYBE_DontExceedMinHeight DISABLED_DontExceedMinHeight | 1353 #define MAYBE_DontExceedMinHeight DISABLED_DontExceedMinHeight |
1358 #else | 1354 #else |
1359 #define MAYBE_DontExceedMinHeight DontExceedMinHeight | 1355 #define MAYBE_DontExceedMinHeight DontExceedMinHeight |
1360 #endif | 1356 #endif |
1361 | 1357 |
1362 TEST_F(WorkspaceWindowResizerTest, MAYBE_DontExceedMinHeight) { | 1358 TEST_F(WorkspaceWindowResizerTest, MAYBE_DontExceedMinHeight) { |
| 1359 UpdateDisplay("600x500"); |
1363 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 1360 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
1364 root->SetHostSize(gfx::Size(600, 500)); | |
1365 | |
1366 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1361 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1367 | 1362 |
1368 // Four 100x100 windows flush against eachother, starting at 100,100. | 1363 // Four 100x100 windows flush against eachother, starting at 100,100. |
1369 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1364 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1370 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1365 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
1371 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1366 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
1372 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1367 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
1373 delegate2_.set_min_size(gfx::Size(0, 99)); | 1368 delegate2_.set_min_size(gfx::Size(0, 99)); |
1374 delegate3_.set_min_size(gfx::Size(0, 99)); | 1369 delegate3_.set_min_size(gfx::Size(0, 99)); |
1375 | 1370 |
1376 std::vector<aura::Window*> windows; | 1371 std::vector<aura::Window*> windows; |
1377 windows.push_back(window2_.get()); | 1372 windows.push_back(window2_.get()); |
1378 windows.push_back(window3_.get()); | 1373 windows.push_back(window3_.get()); |
1379 windows.push_back(window4_.get()); | 1374 windows.push_back(window4_.get()); |
1380 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1375 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
1381 window_.get(), gfx::Point(), HTBOTTOM, windows)); | 1376 window_.get(), gfx::Point(), HTBOTTOM, windows)); |
1382 ASSERT_TRUE(resizer.get()); | 1377 ASSERT_TRUE(resizer.get()); |
1383 // Move it 52 down, which should expand w1 and contract w2-4. | 1378 // Move it 52 down, which should expand w1 and contract w2-4. |
1384 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); | 1379 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); |
1385 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); | 1380 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); |
1386 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); | 1381 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); |
1387 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); | 1382 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); |
1388 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); | 1383 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); |
1389 } | 1384 } |
1390 | 1385 |
1391 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { | 1386 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { |
| 1387 UpdateDisplay("600x800"); |
1392 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 1388 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
1393 root->SetHostSize(gfx::Size(600, 800)); | |
1394 | |
1395 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1389 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1396 | 1390 |
1397 // Three 100x100 windows flush against eachother, starting at 100,100. | 1391 // Three 100x100 windows flush against eachother, starting at 100,100. |
1398 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1392 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1399 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1393 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1400 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1394 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1401 delegate3_.set_max_size(gfx::Size(101, 0)); | 1395 delegate3_.set_max_size(gfx::Size(101, 0)); |
1402 | 1396 |
1403 std::vector<aura::Window*> windows; | 1397 std::vector<aura::Window*> windows; |
1404 windows.push_back(window2_.get()); | 1398 windows.push_back(window2_.get()); |
1405 windows.push_back(window3_.get()); | 1399 windows.push_back(window3_.get()); |
1406 windows.push_back(window4_.get()); | 1400 windows.push_back(window4_.get()); |
1407 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1401 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
1408 window_.get(), gfx::Point(), HTRIGHT, windows)); | 1402 window_.get(), gfx::Point(), HTRIGHT, windows)); |
1409 ASSERT_TRUE(resizer.get()); | 1403 ASSERT_TRUE(resizer.get()); |
1410 // Move it 51 to the left, which should contract w1 and expand w2-3. | 1404 // Move it 51 to the left, which should contract w1 and expand w2-3. |
1411 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); | 1405 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); |
1412 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); | 1406 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); |
1413 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); | 1407 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); |
1414 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1408 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
1415 } | 1409 } |
1416 | 1410 |
1417 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { | 1411 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { |
| 1412 UpdateDisplay("600x800"); |
1418 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 1413 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
1419 root->SetHostSize(gfx::Size(600, 800)); | |
1420 | |
1421 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1414 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1422 | 1415 |
1423 // Three 100x100 windows flush against eachother, starting at 100,100. | 1416 // Three 100x100 windows flush against eachother, starting at 100,100. |
1424 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1417 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1425 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1418 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1426 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1419 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1427 delegate2_.set_max_size(gfx::Size(101, 0)); | 1420 delegate2_.set_max_size(gfx::Size(101, 0)); |
1428 delegate3_.set_max_size(gfx::Size(101, 0)); | 1421 delegate3_.set_max_size(gfx::Size(101, 0)); |
1429 | 1422 |
1430 std::vector<aura::Window*> windows; | 1423 std::vector<aura::Window*> windows; |
(...skipping 11 matching lines...) Expand all Loading... |
1442 } | 1435 } |
1443 | 1436 |
1444 #if defined(OS_WIN) | 1437 #if defined(OS_WIN) |
1445 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 1438 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
1446 #define MAYBE_MainWindowHonoursMaxWidth DISABLED_MainWindowHonoursMaxWidth | 1439 #define MAYBE_MainWindowHonoursMaxWidth DISABLED_MainWindowHonoursMaxWidth |
1447 #else | 1440 #else |
1448 #define MAYBE_MainWindowHonoursMaxWidth MainWindowHonoursMaxWidth | 1441 #define MAYBE_MainWindowHonoursMaxWidth MainWindowHonoursMaxWidth |
1449 #endif | 1442 #endif |
1450 | 1443 |
1451 TEST_F(WorkspaceWindowResizerTest, MAYBE_MainWindowHonoursMaxWidth) { | 1444 TEST_F(WorkspaceWindowResizerTest, MAYBE_MainWindowHonoursMaxWidth) { |
| 1445 UpdateDisplay("400x800"); |
1452 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 1446 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
1453 root->SetHostSize(gfx::Size(400, 800)); | |
1454 | |
1455 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1447 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1456 | 1448 |
1457 // Three 100x100 windows flush against eachother, starting at 100,100. | 1449 // Three 100x100 windows flush against eachother, starting at 100,100. |
1458 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1450 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1459 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1451 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1460 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1452 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1461 delegate_.set_max_size(gfx::Size(102, 0)); | 1453 delegate_.set_max_size(gfx::Size(102, 0)); |
1462 | 1454 |
1463 std::vector<aura::Window*> windows; | 1455 std::vector<aura::Window*> windows; |
1464 windows.push_back(window2_.get()); | 1456 windows.push_back(window2_.get()); |
1465 windows.push_back(window3_.get()); | 1457 windows.push_back(window3_.get()); |
1466 windows.push_back(window4_.get()); | 1458 windows.push_back(window4_.get()); |
1467 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1459 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
1468 window_.get(), gfx::Point(), HTRIGHT, windows)); | 1460 window_.get(), gfx::Point(), HTRIGHT, windows)); |
1469 ASSERT_TRUE(resizer.get()); | 1461 ASSERT_TRUE(resizer.get()); |
1470 // Move it 50 to the right, which should expand w1 and contract w2-3, as they | 1462 // Move it 50 to the right, which should expand w1 and contract w2-3, as they |
1471 // won't fit in the root window in their original sizes. | 1463 // won't fit in the root window in their original sizes. |
1472 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); | 1464 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); |
1473 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); | 1465 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); |
1474 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); | 1466 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); |
1475 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); | 1467 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); |
1476 } | 1468 } |
1477 | 1469 |
1478 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { | 1470 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { |
| 1471 UpdateDisplay("400x800"); |
1479 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 1472 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
1480 root->SetHostSize(gfx::Size(400, 800)); | |
1481 | |
1482 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1473 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
1483 | 1474 |
1484 // Three 100x100 windows flush against eachother, starting at 100,100. | 1475 // Three 100x100 windows flush against eachother, starting at 100,100. |
1485 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1476 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1486 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1477 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1487 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1478 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1488 delegate_.set_min_size(gfx::Size(98, 0)); | 1479 delegate_.set_min_size(gfx::Size(98, 0)); |
1489 | 1480 |
1490 std::vector<aura::Window*> windows; | 1481 std::vector<aura::Window*> windows; |
1491 windows.push_back(window2_.get()); | 1482 windows.push_back(window2_.get()); |
1492 windows.push_back(window3_.get()); | 1483 windows.push_back(window3_.get()); |
1493 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 1484 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
1494 window_.get(), gfx::Point(), HTRIGHT, windows)); | 1485 window_.get(), gfx::Point(), HTRIGHT, windows)); |
1495 ASSERT_TRUE(resizer.get()); | 1486 ASSERT_TRUE(resizer.get()); |
1496 // Move it 50 to the left, which should contract w1 and expand w2-3. | 1487 // Move it 50 to the left, which should contract w1 and expand w2-3. |
1497 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); | 1488 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); |
1498 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); | 1489 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); |
1499 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); | 1490 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); |
1500 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1491 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
1501 } | 1492 } |
1502 | 1493 |
1503 } // namespace internal | 1494 } // namespace internal |
1504 } // namespace ash | 1495 } // namespace ash |
OLD | NEW |