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/test/athena_test_base.h" | 8 #include "athena/test/athena_test_base.h" |
8 #include "athena/wm/public/window_list_provider.h" | 9 #include "athena/wm/public/window_list_provider.h" |
9 #include "athena/wm/test/window_manager_impl_test_api.h" | 10 #include "athena/wm/test/window_manager_impl_test_api.h" |
10 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
11 #include "ui/aura/test/test_window_delegate.h" | 12 #include "ui/aura/test/test_window_delegate.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/gfx/display.h" | |
15 #include "ui/gfx/screen.h" | |
13 | 16 |
14 namespace athena { | 17 namespace athena { |
15 | 18 |
16 typedef test::AthenaTestBase SplitViewControllerTest; | 19 typedef test::AthenaTestBase SplitViewControllerTest; |
17 | 20 |
18 // Tests that when split mode is activated, the windows on the left and right | 21 // Tests that when split mode is activated, the windows on the left and right |
19 // are selected correctly. | 22 // are selected correctly. |
20 TEST_F(SplitViewControllerTest, SplitModeActivation) { | 23 TEST_F(SplitViewControllerTest, SplitModeActivation) { |
21 aura::test::TestWindowDelegate delegate; | 24 aura::test::TestWindowDelegate delegate; |
22 ScopedVector<aura::Window> windows; | 25 ScopedVector<aura::Window> windows; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 EXPECT_EQ(windows[0], controller->right_window()); | 62 EXPECT_EQ(windows[0], controller->right_window()); |
60 EXPECT_EQ(windows[1], *list_provider->GetWindowList().rbegin()); | 63 EXPECT_EQ(windows[1], *list_provider->GetWindowList().rbegin()); |
61 | 64 |
62 controller->ActivateSplitMode(windows[4], windows[5]); | 65 controller->ActivateSplitMode(windows[4], windows[5]); |
63 EXPECT_EQ(windows[4], controller->left_window()); | 66 EXPECT_EQ(windows[4], controller->left_window()); |
64 EXPECT_EQ(windows[5], controller->right_window()); | 67 EXPECT_EQ(windows[5], controller->right_window()); |
65 EXPECT_EQ(windows[4], *list_provider->GetWindowList().rbegin()); | 68 EXPECT_EQ(windows[4], *list_provider->GetWindowList().rbegin()); |
66 EXPECT_EQ(windows[5], *(list_provider->GetWindowList().rbegin() + 1)); | 69 EXPECT_EQ(windows[5], *(list_provider->GetWindowList().rbegin() + 1)); |
67 } | 70 } |
68 | 71 |
72 TEST_F(SplitViewControllerTest, LandscapeOnly) { | |
73 aura::test::TestWindowDelegate delegate; | |
74 ScopedVector<aura::Window> windows; | |
75 const int kNumWindows = 2; | |
76 for (size_t i = 0; i < kNumWindows; ++i) { | |
77 scoped_ptr<aura::Window> window = CreateTestWindow(NULL, gfx::Rect()); | |
78 windows.push_back(window.release()); | |
79 } | |
80 ASSERT_EQ(gfx::Display::ROTATE_0, | |
81 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()); | |
82 | |
83 test::WindowManagerImplTestApi api; | |
84 SplitViewController* controller = api.GetSplitViewController(); | |
85 ASSERT_TRUE(controller->CanScroll()); | |
86 ASSERT_FALSE(controller->IsSplitViewModeActive()); | |
87 | |
88 controller->ActivateSplitMode(NULL, NULL); | |
89 ASSERT_TRUE(controller->IsSplitViewModeActive()); | |
90 | |
91 // Screen rotation should be locked while in splitview. | |
92 ScreenManager::Get()->SetRotation(gfx::Display::ROTATE_90); | |
93 EXPECT_EQ(gfx::Display::ROTATE_0, | |
94 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()); | |
95 | |
96 // Screen is rotated on exiting splitview. | |
97 controller->DeactivateSplitMode(); | |
98 ASSERT_EQ(gfx::Display::ROTATE_90, | |
99 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()); | |
100 | |
101 // Entering splitview should now be disabled now that the screen is in a | |
102 // portrait orientation. | |
103 ASSERT_TRUE(controller->CanScroll()); | |
mfomitchev
2014/09/03 15:43:40
Perhaps finish the test by rotating it back and co
flackr
2014/09/03 16:42:13
Done.
| |
104 } | |
105 | |
69 } // namespace athena | 106 } // namespace athena |
OLD | NEW |