OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_controller.h" | 5 #include "ash/wm/workspace_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { | 1273 TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { |
1274 aura::test::TestWindowDelegate delegate; | 1274 aura::test::TestWindowDelegate delegate; |
1275 delegate.set_window_component(HTCAPTION); | 1275 delegate.set_window_component(HTCAPTION); |
1276 scoped_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( | 1276 scoped_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( |
1277 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); | 1277 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); |
1278 ParentWindowInPrimaryRootWindow(w1.get()); | 1278 ParentWindowInPrimaryRootWindow(w1.get()); |
1279 | 1279 |
1280 ShelfLayoutManager* shelf = shelf_layout_manager(); | 1280 ShelfLayoutManager* shelf = shelf_layout_manager(); |
1281 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1281 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1282 | 1282 |
1283 // Drag near the shelf | 1283 // Drag near the shelf. |
1284 aura::test::EventGenerator generator( | 1284 aura::test::EventGenerator generator( |
1285 Shell::GetPrimaryRootWindow(), gfx::Point()); | 1285 Shell::GetPrimaryRootWindow(), gfx::Point()); |
1286 generator.MoveMouseTo(10, 10); | 1286 generator.MoveMouseTo(10, 10); |
1287 generator.PressLeftButton(); | 1287 generator.PressLeftButton(); |
1288 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 70); | 1288 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 70); |
1289 | 1289 |
1290 // Shelf should not be in overlapped state. | 1290 // Shelf should not be in overlapped state. |
1291 EXPECT_FALSE(GetWindowOverlapsShelf()); | 1291 EXPECT_FALSE(GetWindowOverlapsShelf()); |
1292 | 1292 |
1293 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 20); | 1293 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 20); |
1294 | 1294 |
1295 // Shelf should detect overlap. Overlap state stays after mouse is released. | 1295 // Shelf should detect overlap. Overlap state stays after mouse is released. |
1296 EXPECT_TRUE(GetWindowOverlapsShelf()); | 1296 EXPECT_TRUE(GetWindowOverlapsShelf()); |
1297 generator.ReleaseLeftButton(); | 1297 generator.ReleaseLeftButton(); |
1298 EXPECT_TRUE(GetWindowOverlapsShelf()); | 1298 EXPECT_TRUE(GetWindowOverlapsShelf()); |
1299 } | 1299 } |
1300 | 1300 |
| 1301 // Verifies that when dragging a window autohidden shelf stays hidden during |
| 1302 // and after the drag. |
| 1303 TEST_P(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) { |
| 1304 aura::test::TestWindowDelegate delegate; |
| 1305 delegate.set_window_component(HTCAPTION); |
| 1306 scoped_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( |
| 1307 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); |
| 1308 ParentWindowInPrimaryRootWindow(w1.get()); |
| 1309 |
| 1310 ShelfLayoutManager* shelf = shelf_layout_manager(); |
| 1311 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1312 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1313 |
| 1314 // Drag very little. |
| 1315 aura::test::EventGenerator generator( |
| 1316 Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 1317 generator.MoveMouseTo(10, 10); |
| 1318 generator.PressLeftButton(); |
| 1319 generator.MoveMouseTo(12, 12); |
| 1320 |
| 1321 // Shelf should be hidden during and after the drag. |
| 1322 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1323 generator.ReleaseLeftButton(); |
| 1324 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1325 } |
| 1326 |
1301 INSTANTIATE_TEST_CASE_P(DockedOrNot, WorkspaceControllerTestDragging, | 1327 INSTANTIATE_TEST_CASE_P(DockedOrNot, WorkspaceControllerTestDragging, |
1302 ::testing::Bool()); | 1328 ::testing::Bool()); |
1303 | 1329 |
1304 // Verifies that events are targeted properly just outside the window edges. | 1330 // Verifies that events are targeted properly just outside the window edges. |
1305 TEST_F(WorkspaceControllerTest, WindowEdgeHitTest) { | 1331 TEST_F(WorkspaceControllerTest, WindowEdgeHitTest) { |
1306 aura::test::TestWindowDelegate d_first, d_second; | 1332 aura::test::TestWindowDelegate d_first, d_second; |
1307 scoped_ptr<Window> first(aura::test::CreateTestWindowWithDelegate(&d_first, | 1333 scoped_ptr<Window> first(aura::test::CreateTestWindowWithDelegate(&d_first, |
1308 123, gfx::Rect(20, 10, 100, 50), NULL)); | 1334 123, gfx::Rect(20, 10, 100, 50), NULL)); |
1309 ParentWindowInPrimaryRootWindow(first.get()); | 1335 ParentWindowInPrimaryRootWindow(first.get()); |
1310 first->Show(); | 1336 first->Show(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 // Apply a transform on |second|. After the transform is applied, the window | 1379 // Apply a transform on |second|. After the transform is applied, the window |
1354 // should no longer be targetted. | 1380 // should no longer be targetted. |
1355 gfx::Transform transform; | 1381 gfx::Transform transform; |
1356 transform.Translate(70, 40); | 1382 transform.Translate(70, 40); |
1357 second->SetTransform(transform); | 1383 second->SetTransform(transform); |
1358 } | 1384 } |
1359 } | 1385 } |
1360 | 1386 |
1361 } // namespace internal | 1387 } // namespace internal |
1362 } // namespace ash | 1388 } // namespace ash |
OLD | NEW |