Chromium Code Reviews| 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<const char*> { | |
| 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 { | |
| 1413 return (strstr(GetParam(), "docked") != NULL); | |
| 1414 } | |
| 1415 | |
| 1416 private: | |
| 1417 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging); | |
| 1418 }; | |
| 1419 | |
| 1420 } // namespace | |
| 1421 | |
| 1422 // Verifies that when dragging a window over the shelf overlap is detected | |
| 1423 // during and after the drag. | |
| 1424 TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { | |
| 1425 aura::test::TestWindowDelegate delegate; | |
| 1426 delegate.set_window_component(HTCAPTION); | |
| 1427 scoped_ptr<Window> w1( | |
| 1428 aura::test::CreateTestWindowWithDelegate(&delegate, | |
| 1429 aura::client::WINDOW_TYPE_NORMAL, | |
| 1430 gfx::Rect(5, 5, 100, 50), | |
| 1431 NULL)); | |
| 1432 ParentWindowInPrimaryRootWindow(w1.get()); | |
| 1433 | |
| 1434 ShelfLayoutManager* shelf = shelf_layout_manager(); | |
| 1435 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | |
| 1436 | |
| 1437 // Drag near the shelf | |
| 1438 aura::test::EventGenerator generator( | |
| 1439 Shell::GetPrimaryRootWindow(), gfx::Point()); | |
| 1440 generator.MoveMouseTo(10, 10); | |
| 1441 generator.PressLeftButton(); | |
| 1442 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 20); | |
| 1443 | |
| 1444 // Shelf should detect overlap. Overlap state stays after mouse is released. | |
| 1445 EXPECT_TRUE(GetWindowOverlapsShelf()); | |
| 1446 generator.ReleaseLeftButton(); | |
| 1447 EXPECT_TRUE(GetWindowOverlapsShelf()); | |
| 1448 } | |
| 1449 | |
| 1450 INSTANTIATE_TEST_CASE_P(DockedOrNot, | |
| 1451 WorkspaceControllerTestDragging, | |
| 1452 ::testing::Values("mouse", "mouse docked")); | |
|
oshima
2013/12/03 17:31:28
why not just boolean? Is this recommended pattern?
varkha
2013/12/03 18:01:27
I used this elsewhere where there were more cases
oshima
2013/12/03 18:08:49
I'd just use local enum rather than string. Bool i
varkha
2013/12/03 18:14:45
There (tab_drag_controller_interactive_uitest.cc)
| |
| 1392 } // namespace internal | 1453 } // namespace internal |
| 1393 } // namespace ash | 1454 } // namespace ash |
| OLD | NEW |