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