Chromium Code Reviews| Index: athena/wm/window_manager_unittest.cc |
| diff --git a/athena/wm/window_manager_unittest.cc b/athena/wm/window_manager_unittest.cc |
| index 9641c4854ca98d7c4fcce0fc8426487af6fafb79..6575b12e7d7570170491d22983d7f96a4b05e2b2 100644 |
| --- a/athena/wm/window_manager_unittest.cc |
| +++ b/athena/wm/window_manager_unittest.cc |
| @@ -19,21 +19,22 @@ |
| #include "ui/gfx/screen.h" |
| #include "ui/wm/core/window_util.h" |
| -namespace { |
| - |
| -scoped_ptr<aura::Window> CreateWindow(aura::WindowDelegate* delegate) { |
| - scoped_ptr<aura::Window> window(new aura::Window(delegate)); |
| - window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| - window->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| - window->Show(); |
| - return window.Pass(); |
| -} |
| +namespace athena { |
| -} // namespace |
| +class WindowManagerTest : public test::AthenaTestBase { |
| + public: |
| + WindowManagerTest() {} |
| + virtual ~WindowManagerTest() {} |
| -namespace athena { |
| + scoped_ptr<aura::Window> CreateWindow(aura::WindowDelegate* delegate) { |
|
oshima
2014/09/17 22:07:30
CreateAndShowWindow?
pkotwicz
2014/09/17 22:24:16
Done.
|
| + scoped_ptr<aura::Window> window(CreateTestWindow(delegate, gfx::Rect())); |
| + window->Show(); |
| + return window.Pass(); |
| + } |
| -typedef test::AthenaTestBase WindowManagerTest; |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); |
| +}; |
| TEST_F(WindowManagerTest, OverviewModeBasics) { |
| aura::test::TestWindowDelegate delegate; |
| @@ -41,10 +42,6 @@ TEST_F(WindowManagerTest, OverviewModeBasics) { |
| scoped_ptr<aura::Window> second(CreateWindow(&delegate)); |
| test::WindowManagerImplTestApi wm_api; |
| - aura::client::ParentWindowWithContext( |
| - first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| - aura::client::ParentWindowWithContext( |
| - second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| wm::ActivateWindow(second.get()); |
| ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| @@ -82,9 +79,9 @@ TEST_F(WindowManagerTest, OverviewToSplitViewMode) { |
| test::WindowManagerImplTestApi wm_api; |
| aura::test::TestWindowDelegate delegate; |
| - scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); |
| - scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); |
| - scoped_ptr<aura::Window> w3(CreateTestWindow(&delegate, gfx::Rect())); |
| + scoped_ptr<aura::Window> w1(CreateWindow(&delegate)); |
| + scoped_ptr<aura::Window> w2(CreateWindow(&delegate)); |
| + scoped_ptr<aura::Window> w3(CreateWindow(&delegate)); |
| wm::ActivateWindow(w3.get()); |
| WindowManager::GetInstance()->ToggleOverview(); |
| @@ -94,12 +91,32 @@ TEST_F(WindowManagerTest, OverviewToSplitViewMode) { |
| // Go into split-view mode. |
| WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); |
| - overview_delegate->OnSplitViewMode(NULL, w2.get()); |
| + overview_delegate->OnSelectSplitViewWindow(w3.get(), NULL, w3.get()); |
| EXPECT_TRUE(w3->IsVisible()); |
| EXPECT_TRUE(w2->IsVisible()); |
| EXPECT_FALSE(w1->IsVisible()); |
| } |
| +TEST_F(WindowManagerTest, NewWindowFromOverview) { |
| + aura::test::TestWindowDelegate delegate; |
| + scoped_ptr<aura::Window> w1(CreateWindow(&delegate)); |
| + scoped_ptr<aura::Window> w2(CreateWindow(&delegate)); |
| + |
| + WindowManager::GetInstance()->ToggleOverview(); |
| + EXPECT_TRUE(w1->IsVisible()); |
| + EXPECT_TRUE(w2->IsVisible()); |
| + |
| + // Test that opening a new window exits overview mode. The new window could |
| + // have been opened by JavaScript or by the home card. |
| + scoped_ptr<aura::Window> w3(CreateWindow(&delegate)); |
| + |
| + ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| + EXPECT_TRUE(w3->IsVisible()); |
| + EXPECT_TRUE(wm::IsActiveWindow(w3.get())); |
| + EXPECT_FALSE(w1->IsVisible()); |
| + EXPECT_FALSE(w2->IsVisible()); |
| +} |
| + |
| TEST_F(WindowManagerTest, BezelGestureToSplitViewMode) { |
| aura::test::TestWindowDelegate delegate; |
| scoped_ptr<aura::Window> first(CreateWindow(&delegate)); |
| @@ -107,12 +124,6 @@ TEST_F(WindowManagerTest, BezelGestureToSplitViewMode) { |
| scoped_ptr<aura::Window> third(CreateWindow(&delegate)); |
| test::WindowManagerImplTestApi wm_api; |
| - aura::client::ParentWindowWithContext( |
| - first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| - aura::client::ParentWindowWithContext( |
| - second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| - aura::client::ParentWindowWithContext( |
| - third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| // Test that going into split-view mode with two-finger gesture selects the |
| // correct windows on left and right splits. |
| @@ -140,12 +151,6 @@ TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) { |
| second->Hide(); |
| test::WindowManagerImplTestApi wm_api; |
| - aura::client::ParentWindowWithContext( |
| - first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| - aura::client::ParentWindowWithContext( |
| - second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| - aura::client::ParentWindowWithContext( |
| - third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| EXPECT_EQ(third.get(), |
| wm_api.GetWindowListProvider()->GetWindowList().back()); |
| @@ -172,12 +177,6 @@ TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { |
| scoped_ptr<aura::Window> third(CreateWindow(&delegate)); |
| test::WindowManagerImplTestApi wm_api; |
| - aura::client::ParentWindowWithContext( |
| - first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| - aura::client::ParentWindowWithContext( |
| - second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| - aura::client::ParentWindowWithContext( |
| - third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| EXPECT_EQ(third.get(), |
| wm_api.GetWindowListProvider()->GetWindowList().back()); |
| @@ -226,14 +225,6 @@ TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) { |
| scoped_ptr<aura::Window> fourth(CreateWindow(&delegate)); |
| test::WindowManagerImplTestApi wm_api; |
| - aura::client::ParentWindowWithContext( |
| - first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| - aura::client::ParentWindowWithContext( |
| - second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| - aura::client::ParentWindowWithContext( |
| - third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| - aura::client::ParentWindowWithContext( |
| - fourth.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| // Test that going into split-view mode with two-finger gesture selects the |
| // correct windows on left and right splits. |
| @@ -280,8 +271,6 @@ TEST_F(WindowManagerTest, NewWindowBounds) { |
| scoped_ptr<aura::Window> first(CreateWindow(&delegate)); |
| test::WindowManagerImplTestApi wm_api; |
| - aura::client::ParentWindowWithContext( |
| - first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| // The window should have the same size as the container. |
| const gfx::Size work_area = |
| gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
| @@ -291,8 +280,6 @@ TEST_F(WindowManagerTest, NewWindowBounds) { |
| // A second window should have the same bounds as the first one. |
| scoped_ptr<aura::Window> second(CreateWindow(&delegate)); |
| - aura::client::ParentWindowWithContext( |
| - second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); |
| // Get into split view. |
| @@ -304,8 +291,6 @@ TEST_F(WindowManagerTest, NewWindowBounds) { |
| // A new window should replace the left window when in split view. |
| scoped_ptr<aura::Window> third(CreateWindow(&delegate)); |
| - aura::client::ParentWindowWithContext( |
| - third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); |
| EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get()); |
| EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); |
| } |
| @@ -324,7 +309,7 @@ TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { |
| generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); |
| EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| - scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); |
| + scoped_ptr<aura::Window> w2(CreateWindow(&delegate)); |
| w2->Show(); |
| generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); |
| @@ -349,9 +334,9 @@ TEST_F(WindowManagerTest, OverviewModeFromSplitMode) { |
| test::WindowManagerImplTestApi wm_api; |
| aura::test::TestWindowDelegate delegate; |
| - scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); |
| - scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); |
| - scoped_ptr<aura::Window> w3(CreateTestWindow(&delegate, gfx::Rect())); |
| + scoped_ptr<aura::Window> w1(CreateWindow(&delegate)); |
| + scoped_ptr<aura::Window> w2(CreateWindow(&delegate)); |
| + scoped_ptr<aura::Window> w3(CreateWindow(&delegate)); |
| // Get into split-view mode, and then turn on overview mode. |
| wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL); |