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 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 wm::ActivateWindow(modal_window.get()); | 1382 wm::ActivateWindow(modal_window.get()); |
1383 | 1383 |
1384 scoped_ptr<Window> maximized_window(CreateTestWindow()); | 1384 scoped_ptr<Window> maximized_window(CreateTestWindow()); |
1385 maximized_window->SetProperty( | 1385 maximized_window->SetProperty( |
1386 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1386 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
1387 maximized_window->Show(); | 1387 maximized_window->Show(); |
1388 wm::ActivateWindow(maximized_window.get()); | 1388 wm::ActivateWindow(maximized_window.get()); |
1389 EXPECT_TRUE(maximized_window->IsVisible()); | 1389 EXPECT_TRUE(maximized_window->IsVisible()); |
1390 } | 1390 } |
1391 | 1391 |
| 1392 namespace { |
| 1393 |
| 1394 // Subclass of WorkspaceControllerTest that runs tests with docked windows |
| 1395 // enabled and disabled. |
| 1396 class WorkspaceControllerTestDragging |
| 1397 : public WorkspaceControllerTest, |
| 1398 public testing::WithParamInterface<bool> { |
| 1399 public: |
| 1400 WorkspaceControllerTestDragging() {} |
| 1401 virtual ~WorkspaceControllerTestDragging() {} |
| 1402 |
| 1403 // testing::Test: |
| 1404 virtual void SetUp() OVERRIDE { |
| 1405 WorkspaceControllerTest::SetUp(); |
| 1406 if (!docked_windows_enabled()) { |
| 1407 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1408 ash::switches::kAshDisableDockedWindows); |
| 1409 } |
| 1410 } |
| 1411 |
| 1412 bool docked_windows_enabled() const { return GetParam(); } |
| 1413 |
| 1414 private: |
| 1415 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging); |
| 1416 }; |
| 1417 |
| 1418 } // namespace |
| 1419 |
| 1420 // Verifies that when dragging a window over the shelf overlap is detected |
| 1421 // during and after the drag. |
| 1422 TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { |
| 1423 aura::test::TestWindowDelegate delegate; |
| 1424 delegate.set_window_component(HTCAPTION); |
| 1425 scoped_ptr<Window> w1( |
| 1426 aura::test::CreateTestWindowWithDelegate(&delegate, |
| 1427 aura::client::WINDOW_TYPE_NORMAL, |
| 1428 gfx::Rect(5, 5, 100, 50), |
| 1429 NULL)); |
| 1430 ParentWindowInPrimaryRootWindow(w1.get()); |
| 1431 |
| 1432 ShelfLayoutManager* shelf = shelf_layout_manager(); |
| 1433 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1434 |
| 1435 // Drag near the shelf |
| 1436 aura::test::EventGenerator generator( |
| 1437 Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 1438 generator.MoveMouseTo(10, 10); |
| 1439 generator.PressLeftButton(); |
| 1440 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 20); |
| 1441 |
| 1442 // Shelf should detect overlap. Overlap state stays after mouse is released. |
| 1443 EXPECT_TRUE(GetWindowOverlapsShelf()); |
| 1444 generator.ReleaseLeftButton(); |
| 1445 EXPECT_TRUE(GetWindowOverlapsShelf()); |
| 1446 } |
| 1447 |
| 1448 INSTANTIATE_TEST_CASE_P(DockedOrNot, WorkspaceControllerTestDragging, |
| 1449 ::testing::Bool()); |
| 1450 |
1392 } // namespace internal | 1451 } // namespace internal |
1393 } // namespace ash | 1452 } // namespace ash |
OLD | NEW |