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/base/athena_test_base.h" | 8 #include "athena/test/base/athena_test_base.h" |
9 #include "athena/test/base/test_windows.h" | |
10 #include "athena/wm/public/window_list_provider.h" | 9 #include "athena/wm/public/window_list_provider.h" |
11 #include "athena/wm/test/window_manager_impl_test_api.h" | 10 #include "athena/wm/test/window_manager_impl_test_api.h" |
12 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
13 #include "ui/aura/test/test_window_delegate.h" | 12 #include "ui/aura/test/test_window_delegate.h" |
14 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
15 #include "ui/gfx/display.h" | 14 #include "ui/gfx/display.h" |
16 #include "ui/gfx/screen.h" | 15 #include "ui/gfx/screen.h" |
17 #include "ui/wm/core/window_util.h" | 16 #include "ui/wm/core/window_util.h" |
18 | 17 |
19 namespace athena { | 18 namespace athena { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 DISALLOW_COPY_AND_ASSIGN(SplitViewControllerTest); | 95 DISALLOW_COPY_AND_ASSIGN(SplitViewControllerTest); |
97 }; | 96 }; |
98 | 97 |
99 // Tests that when split mode is activated, the windows on the left and right | 98 // Tests that when split mode is activated, the windows on the left and right |
100 // are selected correctly. | 99 // are selected correctly. |
101 TEST_F(SplitViewControllerTest, SplitModeActivation) { | 100 TEST_F(SplitViewControllerTest, SplitModeActivation) { |
102 aura::test::TestWindowDelegate delegate; | 101 aura::test::TestWindowDelegate delegate; |
103 ScopedVector<aura::Window> windows; | 102 ScopedVector<aura::Window> windows; |
104 const int kNumWindows = 6; | 103 const int kNumWindows = 6; |
105 for (size_t i = 0; i < kNumWindows; ++i) { | 104 for (size_t i = 0; i < kNumWindows; ++i) { |
106 scoped_ptr<aura::Window> window = test::CreateNormalWindow(NULL, NULL); | 105 scoped_ptr<aura::Window> window = CreateTestWindow(NULL, gfx::Rect()); |
107 windows.push_back(window.release()); | 106 windows.push_back(window.release()); |
108 windows[i]->Hide(); | 107 windows[i]->Hide(); |
109 } | 108 } |
110 | 109 |
111 windows[kNumWindows - 1]->Show(); | 110 windows[kNumWindows - 1]->Show(); |
112 wm::ActivateWindow(windows[kNumWindows - 1]); | 111 wm::ActivateWindow(windows[kNumWindows - 1]); |
113 | 112 |
114 SplitViewController* controller = api()->GetSplitViewController(); | 113 SplitViewController* controller = api()->GetSplitViewController(); |
115 ASSERT_FALSE(controller->IsSplitViewModeActive()); | 114 ASSERT_FALSE(controller->IsSplitViewModeActive()); |
116 | 115 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return window->layer()->transform().To2dTranslation().x(); | 187 return window->layer()->transform().To2dTranslation().x(); |
189 } | 188 } |
190 | 189 |
191 // Tests that calls to the methods of DragHandleScrollDelegate will disengage | 190 // Tests that calls to the methods of DragHandleScrollDelegate will disengage |
192 // split view mode under the correct circumstances. | 191 // split view mode under the correct circumstances. |
193 TEST_F(SplitViewControllerTest, ScrollDragHandle) { | 192 TEST_F(SplitViewControllerTest, ScrollDragHandle) { |
194 aura::test::TestWindowDelegate delegate; | 193 aura::test::TestWindowDelegate delegate; |
195 ScopedVector<aura::Window> windows; | 194 ScopedVector<aura::Window> windows; |
196 const int kNumWindows = 2; | 195 const int kNumWindows = 2; |
197 for (size_t i = 0; i < kNumWindows; ++i) { | 196 for (size_t i = 0; i < kNumWindows; ++i) { |
198 scoped_ptr<aura::Window> window = test::CreateNormalWindow(NULL, NULL); | 197 scoped_ptr<aura::Window> window = CreateTestWindow(NULL, gfx::Rect()); |
199 windows.push_back(window.release()); | 198 windows.push_back(window.release()); |
200 windows[i]->Hide(); | 199 windows[i]->Hide(); |
201 } | 200 } |
202 | 201 |
203 SplitViewController* controller = api()->GetSplitViewController(); | 202 SplitViewController* controller = api()->GetSplitViewController(); |
204 ASSERT_FALSE(controller->IsSplitViewModeActive()); | 203 ASSERT_FALSE(controller->IsSplitViewModeActive()); |
205 | 204 |
206 aura::Window* left_window = windows[0]; | 205 aura::Window* left_window = windows[0]; |
207 aura::Window* right_window = windows[1]; | 206 aura::Window* right_window = windows[1]; |
208 left_window->Show(); | 207 left_window->Show(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 EXPECT_EQ(NULL, controller->left_window()); | 283 EXPECT_EQ(NULL, controller->left_window()); |
285 EXPECT_EQ(NULL, controller->right_window()); | 284 EXPECT_EQ(NULL, controller->right_window()); |
286 EXPECT_EQ(left_window, GetTopmostWindow()); | 285 EXPECT_EQ(left_window, GetTopmostWindow()); |
287 } | 286 } |
288 | 287 |
289 TEST_F(SplitViewControllerTest, LandscapeOnly) { | 288 TEST_F(SplitViewControllerTest, LandscapeOnly) { |
290 aura::test::TestWindowDelegate delegate; | 289 aura::test::TestWindowDelegate delegate; |
291 ScopedVector<aura::Window> windows; | 290 ScopedVector<aura::Window> windows; |
292 const int kNumWindows = 2; | 291 const int kNumWindows = 2; |
293 for (size_t i = 0; i < kNumWindows; ++i) { | 292 for (size_t i = 0; i < kNumWindows; ++i) { |
294 scoped_ptr<aura::Window> window = test::CreateNormalWindow(NULL, NULL); | 293 scoped_ptr<aura::Window> window = CreateTestWindow(NULL, gfx::Rect()); |
295 window->Hide(); | 294 window->Hide(); |
296 windows.push_back(window.release()); | 295 windows.push_back(window.release()); |
297 } | 296 } |
298 windows[kNumWindows - 1]->Show(); | 297 windows[kNumWindows - 1]->Show(); |
299 wm::ActivateWindow(windows[kNumWindows - 1]); | 298 wm::ActivateWindow(windows[kNumWindows - 1]); |
300 | 299 |
301 ASSERT_EQ(gfx::Display::ROTATE_0, | 300 ASSERT_EQ(gfx::Display::ROTATE_0, |
302 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()); | 301 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()); |
303 | 302 |
304 SplitViewController* controller = api()->GetSplitViewController(); | 303 SplitViewController* controller = api()->GetSplitViewController(); |
(...skipping 16 matching lines...) Expand all Loading... |
321 // Entering splitview should now be disabled now that the screen is in a | 320 // Entering splitview should now be disabled now that the screen is in a |
322 // portrait orientation. | 321 // portrait orientation. |
323 EXPECT_FALSE(IsSplitViewAllowed()); | 322 EXPECT_FALSE(IsSplitViewAllowed()); |
324 | 323 |
325 // Rotating back to 0 allows splitview again. | 324 // Rotating back to 0 allows splitview again. |
326 ScreenManager::Get()->SetRotation(gfx::Display::ROTATE_0); | 325 ScreenManager::Get()->SetRotation(gfx::Display::ROTATE_0); |
327 EXPECT_TRUE(IsSplitViewAllowed()); | 326 EXPECT_TRUE(IsSplitViewAllowed()); |
328 } | 327 } |
329 | 328 |
330 } // namespace athena | 329 } // namespace athena |
OLD | NEW |