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/screen/public/screen_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/public/window_list_provider.h" | 9 #include "athena/wm/public/window_list_provider.h" |
10 #include "athena/wm/test/window_manager_impl_test_api.h" | 10 #include "athena/wm/test/window_manager_impl_test_api.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 virtual void SetUp() OVERRIDE { | 25 virtual void SetUp() OVERRIDE { |
26 test::AthenaTestBase::SetUp(); | 26 test::AthenaTestBase::SetUp(); |
27 api_.reset(new test::WindowManagerImplTestApi); | 27 api_.reset(new test::WindowManagerImplTestApi); |
28 } | 28 } |
29 | 29 |
30 virtual void TearDown() OVERRIDE { | 30 virtual void TearDown() OVERRIDE { |
31 api_.reset(); | 31 api_.reset(); |
32 test::AthenaTestBase::TearDown(); | 32 test::AthenaTestBase::TearDown(); |
33 } | 33 } |
34 | 34 |
35 // Returns whether the split view windows are topmost. | |
36 bool SplitViewWindowsTopmost() const { | |
37 SplitViewController* controller = api_->GetSplitViewController(); | |
38 DCHECK(controller->IsSplitViewModeActive()); | |
39 aura::Window::Windows list = | |
40 api_->GetWindowListProvider()->GetWindowList(); | |
41 aura::Window* topmost = *list.rbegin(); | |
42 aura::Window* second_topmost = *(list.rbegin() + 1); | |
43 return (topmost == controller->left_window() || | |
44 topmost == controller->right_window()) && | |
45 (second_topmost == controller->left_window() || | |
46 second_topmost == controller->right_window()); | |
47 } | |
48 | |
35 bool IsSplitViewAllowed() const { | 49 bool IsSplitViewAllowed() const { |
36 return api_->GetSplitViewController()->CanScroll(); | 50 return api_->GetSplitViewController()->CanScroll(); |
37 } | 51 } |
38 | 52 |
39 test::WindowManagerImplTestApi* api() { | 53 test::WindowManagerImplTestApi* api() { |
40 return api_.get(); | 54 return api_.get(); |
41 } | 55 } |
42 | 56 |
43 private: | 57 private: |
44 scoped_ptr<test::WindowManagerImplTestApi> api_; | 58 scoped_ptr<test::WindowManagerImplTestApi> api_; |
45 | 59 |
46 DISALLOW_COPY_AND_ASSIGN(SplitViewControllerTest); | 60 DISALLOW_COPY_AND_ASSIGN(SplitViewControllerTest); |
47 }; | 61 }; |
48 | 62 |
49 // Tests that when split mode is activated, the windows on the left and right | 63 // Tests that when split mode is activated, the windows on the left and right |
50 // are selected correctly. | 64 // are selected correctly. |
51 TEST_F(SplitViewControllerTest, SplitModeActivation) { | 65 TEST_F(SplitViewControllerTest, SplitModeActivation) { |
52 aura::test::TestWindowDelegate delegate; | 66 aura::test::TestWindowDelegate delegate; |
53 ScopedVector<aura::Window> windows; | 67 ScopedVector<aura::Window> windows; |
54 const int kNumWindows = 6; | 68 const int kNumWindows = 6; |
55 for (size_t i = 0; i < kNumWindows; ++i) { | 69 for (size_t i = 0; i < kNumWindows; ++i) { |
56 scoped_ptr<aura::Window> window = CreateTestWindow(NULL, gfx::Rect()); | 70 scoped_ptr<aura::Window> window = CreateTestWindow(NULL, gfx::Rect()); |
57 windows.push_back(window.release()); | 71 windows.push_back(window.release()); |
58 } | 72 } |
59 | 73 |
60 SplitViewController* controller = api()->GetSplitViewController(); | 74 SplitViewController* controller = api()->GetSplitViewController(); |
61 WindowListProvider* list_provider = api()->GetWindowListProvider(); | |
62 ASSERT_FALSE(controller->IsSplitViewModeActive()); | 75 ASSERT_FALSE(controller->IsSplitViewModeActive()); |
63 | 76 |
64 controller->ActivateSplitMode(NULL, NULL); | 77 controller->ActivateSplitMode(NULL, NULL); |
65 ASSERT_TRUE(controller->IsSplitViewModeActive()); | 78 ASSERT_TRUE(controller->IsSplitViewModeActive()); |
66 // The last two windows should be on the left and right, respectively. | 79 // The last two windows should be on the left and right, respectively. |
67 EXPECT_EQ(windows[kNumWindows - 1], controller->left_window()); | 80 EXPECT_EQ(windows[kNumWindows - 1], controller->left_window()); |
68 EXPECT_EQ(windows[kNumWindows - 2], controller->right_window()); | 81 EXPECT_EQ(windows[kNumWindows - 2], controller->right_window()); |
82 EXPECT_TRUE(SplitViewWindowsTopmost()); | |
69 | 83 |
70 // Select the window that is currently on the left for the right panel. The | 84 // Select the window that is currently on the left for the right panel. The |
71 // windows should switch. | 85 // windows should switch. |
72 controller->ActivateSplitMode(NULL, windows[kNumWindows - 1]); | 86 controller->ActivateSplitMode(NULL, windows[kNumWindows - 1]); |
73 EXPECT_EQ(windows[kNumWindows - 2], controller->left_window()); | 87 EXPECT_EQ(windows[kNumWindows - 2], controller->left_window()); |
74 EXPECT_EQ(windows[kNumWindows - 1], controller->right_window()); | 88 EXPECT_EQ(windows[kNumWindows - 1], controller->right_window()); |
89 EXPECT_TRUE(SplitViewWindowsTopmost()); | |
75 | 90 |
76 controller->ActivateSplitMode(windows[kNumWindows - 1], NULL); | 91 controller->ActivateSplitMode(windows[kNumWindows - 1], NULL); |
77 EXPECT_EQ(windows[kNumWindows - 1], controller->left_window()); | 92 EXPECT_EQ(windows[kNumWindows - 1], controller->left_window()); |
78 EXPECT_EQ(windows[kNumWindows - 2], controller->right_window()); | 93 EXPECT_EQ(windows[kNumWindows - 2], controller->right_window()); |
94 EXPECT_TRUE(SplitViewWindowsTopmost()); | |
79 | 95 |
80 // Select one of the windows behind the stacks for the right panel. The window | 96 // Select one of the windows behind the stacks for the right panel. The window |
81 // on the left should remain unchanged. | 97 // on the left should remain unchanged. |
82 controller->ActivateSplitMode(NULL, windows[0]); | 98 controller->ActivateSplitMode(NULL, windows[0]); |
83 EXPECT_EQ(windows[kNumWindows - 1], controller->left_window()); | 99 EXPECT_EQ(windows[kNumWindows - 1], controller->left_window()); |
84 EXPECT_EQ(windows[0], controller->right_window()); | 100 EXPECT_EQ(windows[0], controller->right_window()); |
85 EXPECT_EQ(windows[0], *list_provider->GetWindowList().rbegin()); | 101 EXPECT_TRUE(SplitViewWindowsTopmost()); |
86 | 102 |
87 controller->ActivateSplitMode(windows[1], NULL); | 103 controller->ActivateSplitMode(windows[1], NULL); |
88 EXPECT_EQ(windows[1], controller->left_window()); | 104 EXPECT_EQ(windows[1], controller->left_window()); |
89 EXPECT_EQ(windows[0], controller->right_window()); | 105 EXPECT_EQ(windows[0], controller->right_window()); |
90 EXPECT_EQ(windows[1], *list_provider->GetWindowList().rbegin()); | 106 EXPECT_TRUE(SplitViewWindowsTopmost()); |
91 | 107 |
92 controller->ActivateSplitMode(windows[4], windows[5]); | 108 controller->ActivateSplitMode(windows[4], windows[5]); |
93 EXPECT_EQ(windows[4], controller->left_window()); | 109 EXPECT_EQ(windows[4], controller->left_window()); |
94 EXPECT_EQ(windows[5], controller->right_window()); | 110 EXPECT_EQ(windows[5], controller->right_window()); |
95 EXPECT_EQ(windows[4], *list_provider->GetWindowList().rbegin()); | 111 EXPECT_TRUE(SplitViewWindowsTopmost()); |
pkotwicz
2014/09/11 17:26:15
The tests happen to pass without the changes in th
sadrul
2014/09/12 04:32:29
Can you add that test-case here?
oshima
2014/09/12 18:48:41
You probably missed this?
| |
96 EXPECT_EQ(windows[5], *(list_provider->GetWindowList().rbegin() + 1)); | |
97 } | 112 } |
98 | 113 |
99 TEST_F(SplitViewControllerTest, LandscapeOnly) { | 114 TEST_F(SplitViewControllerTest, LandscapeOnly) { |
100 aura::test::TestWindowDelegate delegate; | 115 aura::test::TestWindowDelegate delegate; |
101 ScopedVector<aura::Window> windows; | 116 ScopedVector<aura::Window> windows; |
102 const int kNumWindows = 2; | 117 const int kNumWindows = 2; |
103 for (size_t i = 0; i < kNumWindows; ++i) { | 118 for (size_t i = 0; i < kNumWindows; ++i) { |
104 scoped_ptr<aura::Window> window = CreateTestWindow(NULL, gfx::Rect()); | 119 scoped_ptr<aura::Window> window = CreateTestWindow(NULL, gfx::Rect()); |
105 windows.push_back(window.release()); | 120 windows.push_back(window.release()); |
106 } | 121 } |
(...skipping 20 matching lines...) Expand all Loading... | |
127 // Entering splitview should now be disabled now that the screen is in a | 142 // Entering splitview should now be disabled now that the screen is in a |
128 // portrait orientation. | 143 // portrait orientation. |
129 EXPECT_FALSE(IsSplitViewAllowed()); | 144 EXPECT_FALSE(IsSplitViewAllowed()); |
130 | 145 |
131 // Rotating back to 0 allows splitview again. | 146 // Rotating back to 0 allows splitview again. |
132 ScreenManager::Get()->SetRotation(gfx::Display::ROTATE_0); | 147 ScreenManager::Get()->SetRotation(gfx::Display::ROTATE_0); |
133 EXPECT_TRUE(IsSplitViewAllowed()); | 148 EXPECT_TRUE(IsSplitViewAllowed()); |
134 } | 149 } |
135 | 150 |
136 } // namespace athena | 151 } // namespace athena |
OLD | NEW |