| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/wm/split_view_controller.h" | 5 #include "athena/wm/split_view_controller.h" |
| 6 | 6 |
| 7 #include "athena/common/fill_layout_manager.h" | |
| 8 #include "athena/test/athena_test_base.h" | 7 #include "athena/test/athena_test_base.h" |
| 9 #include "athena/wm/window_list_provider_impl.h" | 8 #include "athena/wm/public/window_list_provider.h" |
| 9 #include "athena/wm/window_manager_impl_test_api.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "ui/aura/test/test_window_delegate.h" | 11 #include "ui/aura/test/test_window_delegate.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 | 13 |
| 14 namespace athena { | 14 namespace athena { |
| 15 | 15 |
| 16 typedef test::AthenaTestBase SplitViewControllerTest; | 16 typedef test::AthenaTestBase SplitViewControllerTest; |
| 17 | 17 |
| 18 // Tests that when split mode is activated, the windows on the left and right | 18 // Tests that when split mode is activated, the windows on the left and right |
| 19 // are selected correctly. | 19 // are selected correctly. |
| 20 TEST_F(SplitViewControllerTest, SplitModeActivation) { | 20 TEST_F(SplitViewControllerTest, SplitModeActivation) { |
| 21 aura::test::TestWindowDelegate delegate; | 21 aura::test::TestWindowDelegate delegate; |
| 22 ScopedVector<aura::Window> windows; | 22 ScopedVector<aura::Window> windows; |
| 23 const int kNumWindows = 6; | 23 const int kNumWindows = 6; |
| 24 for (size_t i = 0; i < kNumWindows; ++i) { | 24 for (size_t i = 0; i < kNumWindows; ++i) { |
| 25 aura::Window* window = new aura::Window(&delegate); | 25 scoped_ptr<aura::Window> window = CreateTestWindow(NULL, gfx::Rect()); |
| 26 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 26 windows.push_back(window.release()); |
| 27 window->Init(aura::WINDOW_LAYER_SOLID_COLOR); | |
| 28 root_window()->AddChild(window); | |
| 29 windows.push_back(window); | |
| 30 } | 27 } |
| 31 | 28 |
| 32 scoped_ptr<WindowListProvider> list_provider( | 29 WindowManagerImplTestApi api; |
| 33 new WindowListProviderImpl(root_window())); | 30 SplitViewController* controller = api.GetSplitViewController(); |
| 34 SplitViewController controller(root_window(), list_provider.get()); | 31 WindowListProvider* list_provider = api.GetWindowListProvider(); |
| 35 ASSERT_FALSE(controller.IsSplitViewModeActive()); | 32 ASSERT_FALSE(controller->IsSplitViewModeActive()); |
| 36 | 33 |
| 37 controller.ActivateSplitMode(NULL, NULL); | 34 controller->ActivateSplitMode(NULL, NULL); |
| 38 ASSERT_TRUE(controller.IsSplitViewModeActive()); | 35 ASSERT_TRUE(controller->IsSplitViewModeActive()); |
| 39 // The last two windows should be on the left and right, respectively. | 36 // The last two windows should be on the left and right, respectively. |
| 40 EXPECT_EQ(windows[kNumWindows - 1], controller.left_window()); | 37 EXPECT_EQ(windows[kNumWindows - 1], controller->left_window()); |
| 41 EXPECT_EQ(windows[kNumWindows - 2], controller.right_window()); | 38 EXPECT_EQ(windows[kNumWindows - 2], controller->right_window()); |
| 42 | 39 |
| 43 // Select the window that is currently on the left for the right panel. The | 40 // Select the window that is currently on the left for the right panel. The |
| 44 // windows should switch. | 41 // windows should switch. |
| 45 controller.ActivateSplitMode(NULL, windows[kNumWindows - 1]); | 42 controller->ActivateSplitMode(NULL, windows[kNumWindows - 1]); |
| 46 EXPECT_EQ(windows[kNumWindows - 2], controller.left_window()); | 43 EXPECT_EQ(windows[kNumWindows - 2], controller->left_window()); |
| 47 EXPECT_EQ(windows[kNumWindows - 1], controller.right_window()); | 44 EXPECT_EQ(windows[kNumWindows - 1], controller->right_window()); |
| 48 | 45 |
| 49 controller.ActivateSplitMode(windows[kNumWindows - 1], NULL); | 46 controller->ActivateSplitMode(windows[kNumWindows - 1], NULL); |
| 50 EXPECT_EQ(windows[kNumWindows - 1], controller.left_window()); | 47 EXPECT_EQ(windows[kNumWindows - 1], controller->left_window()); |
| 51 EXPECT_EQ(windows[kNumWindows - 2], controller.right_window()); | 48 EXPECT_EQ(windows[kNumWindows - 2], controller->right_window()); |
| 52 | 49 |
| 53 // Select one of the windows behind the stacks for the right panel. The window | 50 // Select one of the windows behind the stacks for the right panel. The window |
| 54 // on the left should remain unchanged. | 51 // on the left should remain unchanged. |
| 55 controller.ActivateSplitMode(NULL, windows[0]); | 52 controller->ActivateSplitMode(NULL, windows[0]); |
| 56 EXPECT_EQ(windows[kNumWindows - 1], controller.left_window()); | 53 EXPECT_EQ(windows[kNumWindows - 1], controller->left_window()); |
| 57 EXPECT_EQ(windows[0], controller.right_window()); | 54 EXPECT_EQ(windows[0], controller->right_window()); |
| 58 EXPECT_EQ(windows[0], *list_provider->GetWindowList().rbegin()); | 55 EXPECT_EQ(windows[0], *list_provider->GetWindowList().rbegin()); |
| 59 | 56 |
| 60 controller.ActivateSplitMode(windows[1], NULL); | 57 controller->ActivateSplitMode(windows[1], NULL); |
| 61 EXPECT_EQ(windows[1], controller.left_window()); | 58 EXPECT_EQ(windows[1], controller->left_window()); |
| 62 EXPECT_EQ(windows[0], controller.right_window()); | 59 EXPECT_EQ(windows[0], controller->right_window()); |
| 63 EXPECT_EQ(windows[1], *list_provider->GetWindowList().rbegin()); | 60 EXPECT_EQ(windows[1], *list_provider->GetWindowList().rbegin()); |
| 64 | 61 |
| 65 controller.ActivateSplitMode(windows[4], windows[5]); | 62 controller->ActivateSplitMode(windows[4], windows[5]); |
| 66 EXPECT_EQ(windows[4], controller.left_window()); | 63 EXPECT_EQ(windows[4], controller->left_window()); |
| 67 EXPECT_EQ(windows[5], controller.right_window()); | 64 EXPECT_EQ(windows[5], controller->right_window()); |
| 68 EXPECT_EQ(windows[4], *list_provider->GetWindowList().rbegin()); | 65 EXPECT_EQ(windows[4], *list_provider->GetWindowList().rbegin()); |
| 69 EXPECT_EQ(windows[5], *(list_provider->GetWindowList().rbegin() + 1)); | 66 EXPECT_EQ(windows[5], *(list_provider->GetWindowList().rbegin() + 1)); |
| 70 } | 67 } |
| 71 | 68 |
| 72 } // namespace athena | 69 } // namespace athena |
| OLD | NEW |