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" | 7 #include "athena/screen/public/screen_manager.h" |
8 #include "athena/test/athena_test_base.h" | 8 #include "athena/test/athena_test_base.h" |
9 #include "athena/wm/window_list_provider_impl.h" | 9 #include "athena/wm/window_list_provider_impl.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::Window* container = ScreenManager::Get()->CreateContainer( | |
22 ScreenManager::ContainerParams("Test", 0)); | |
23 | |
21 aura::test::TestWindowDelegate delegate; | 24 aura::test::TestWindowDelegate delegate; |
22 ScopedVector<aura::Window> windows; | 25 ScopedVector<aura::Window> windows; |
23 const int kNumWindows = 6; | 26 const int kNumWindows = 6; |
24 for (size_t i = 0; i < kNumWindows; ++i) { | 27 for (size_t i = 0; i < kNumWindows; ++i) { |
25 aura::Window* window = new aura::Window(&delegate); | 28 aura::Window* window = new aura::Window(&delegate); |
26 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 29 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
27 window->Init(aura::WINDOW_LAYER_SOLID_COLOR); | 30 window->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
28 root_window()->AddChild(window); | 31 container->AddChild(window); |
sadrul
2014/08/21 16:04:04
There's now a AthenaTestBase::CreateTestWindow().
| |
29 windows.push_back(window); | 32 windows.push_back(window); |
30 } | 33 } |
31 | 34 |
32 scoped_ptr<WindowListProvider> list_provider( | 35 scoped_ptr<WindowListProvider> list_provider( |
33 new WindowListProviderImpl(root_window())); | 36 new WindowListProviderImpl(container)); |
34 SplitViewController controller(root_window(), list_provider.get()); | 37 SplitViewController controller(container, list_provider.get()); |
sadrul
2014/08/21 16:04:04
Instead of creating this new SVC here, perhaps you
| |
35 ASSERT_FALSE(controller.IsSplitViewModeActive()); | 38 ASSERT_FALSE(controller.IsSplitViewModeActive()); |
36 | 39 |
37 controller.ActivateSplitMode(NULL, NULL); | 40 controller.ActivateSplitMode(NULL, NULL); |
38 ASSERT_TRUE(controller.IsSplitViewModeActive()); | 41 ASSERT_TRUE(controller.IsSplitViewModeActive()); |
39 // The last two windows should be on the left and right, respectively. | 42 // The last two windows should be on the left and right, respectively. |
40 EXPECT_EQ(windows[kNumWindows - 1], controller.left_window()); | 43 EXPECT_EQ(windows[kNumWindows - 1], controller.left_window()); |
41 EXPECT_EQ(windows[kNumWindows - 2], controller.right_window()); | 44 EXPECT_EQ(windows[kNumWindows - 2], controller.right_window()); |
42 | 45 |
43 // Select the window that is currently on the left for the right panel. The | 46 // Select the window that is currently on the left for the right panel. The |
44 // windows should switch. | 47 // windows should switch. |
(...skipping 18 matching lines...) Expand all Loading... | |
63 EXPECT_EQ(windows[1], *list_provider->GetWindowList().rbegin()); | 66 EXPECT_EQ(windows[1], *list_provider->GetWindowList().rbegin()); |
64 | 67 |
65 controller.ActivateSplitMode(windows[4], windows[5]); | 68 controller.ActivateSplitMode(windows[4], windows[5]); |
66 EXPECT_EQ(windows[4], controller.left_window()); | 69 EXPECT_EQ(windows[4], controller.left_window()); |
67 EXPECT_EQ(windows[5], controller.right_window()); | 70 EXPECT_EQ(windows[5], controller.right_window()); |
68 EXPECT_EQ(windows[4], *list_provider->GetWindowList().rbegin()); | 71 EXPECT_EQ(windows[4], *list_provider->GetWindowList().rbegin()); |
69 EXPECT_EQ(windows[5], *(list_provider->GetWindowList().rbegin() + 1)); | 72 EXPECT_EQ(windows[5], *(list_provider->GetWindowList().rbegin() + 1)); |
70 } | 73 } |
71 | 74 |
72 } // namespace athena | 75 } // namespace athena |
OLD | NEW |