OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "athena/wm/split_view_controller.h" |
| 6 |
| 7 #include "athena/common/fill_layout_manager.h" |
| 8 #include "athena/test/athena_test_base.h" |
| 9 #include "athena/wm/public/window_list_provider.h" |
| 10 #include "base/memory/scoped_vector.h" |
| 11 #include "ui/aura/test/test_window_delegate.h" |
| 12 #include "ui/aura/window.h" |
| 13 |
| 14 namespace athena { |
| 15 |
| 16 typedef test::AthenaTestBase SplitViewControllerTest; |
| 17 |
| 18 class SimpleWindowListProvider : public WindowListProvider { |
| 19 public: |
| 20 explicit SimpleWindowListProvider(aura::Window* container) |
| 21 : container_(container) {} |
| 22 virtual ~SimpleWindowListProvider() {} |
| 23 |
| 24 // WindowListProvider: |
| 25 virtual aura::Window::Windows GetWindowList() const OVERRIDE { |
| 26 return container_->children(); |
| 27 } |
| 28 |
| 29 virtual void MoveToFront(aura::Window* window) OVERRIDE { |
| 30 CHECK_EQ(container_, window->parent()); |
| 31 container_->StackChildAtTop(window); |
| 32 } |
| 33 |
| 34 private: |
| 35 aura::Window* container_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(SimpleWindowListProvider); |
| 38 }; |
| 39 |
| 40 // Tests that when split mode is activated, the windows on the left and right |
| 41 // are selected correctly. |
| 42 TEST_F(SplitViewControllerTest, SplitModeActivation) { |
| 43 aura::test::TestWindowDelegate delegate; |
| 44 ScopedVector<aura::Window> windows; |
| 45 const int kNumWindows = 6; |
| 46 for (size_t i = 0; i < kNumWindows; ++i) { |
| 47 aura::Window* window = new aura::Window(&delegate); |
| 48 window->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| 49 root_window()->AddChild(window); |
| 50 windows.push_back(window); |
| 51 } |
| 52 |
| 53 SimpleWindowListProvider list_provider(root_window()); |
| 54 SplitViewController controller(root_window(), &list_provider, NULL); |
| 55 ASSERT_FALSE(controller.IsSplitViewModeActive()); |
| 56 |
| 57 controller.ActivateSplitMode(NULL, NULL); |
| 58 ASSERT_TRUE(controller.IsSplitViewModeActive()); |
| 59 // The last two windows should be on the left and right, respectively. |
| 60 EXPECT_EQ(windows[kNumWindows - 1], controller.left_window()); |
| 61 EXPECT_EQ(windows[kNumWindows - 2], controller.right_window()); |
| 62 |
| 63 // Select the window that is currently on the left for the right panel. The |
| 64 // windows should switch. |
| 65 controller.ActivateSplitMode(NULL, windows[kNumWindows - 1]); |
| 66 EXPECT_EQ(windows[kNumWindows - 2], controller.left_window()); |
| 67 EXPECT_EQ(windows[kNumWindows - 1], controller.right_window()); |
| 68 |
| 69 controller.ActivateSplitMode(windows[kNumWindows - 1], NULL); |
| 70 EXPECT_EQ(windows[kNumWindows - 1], controller.left_window()); |
| 71 EXPECT_EQ(windows[kNumWindows - 2], controller.right_window()); |
| 72 |
| 73 // Select one of the windows behind the stacks for the right panel. The window |
| 74 // on the left should remain unchanged. |
| 75 controller.ActivateSplitMode(NULL, windows[0]); |
| 76 EXPECT_EQ(windows[kNumWindows - 1], controller.left_window()); |
| 77 EXPECT_EQ(windows[0], controller.right_window()); |
| 78 EXPECT_EQ(windows[0], *list_provider.GetWindowList().rbegin()); |
| 79 |
| 80 controller.ActivateSplitMode(windows[1], NULL); |
| 81 EXPECT_EQ(windows[1], controller.left_window()); |
| 82 EXPECT_EQ(windows[0], controller.right_window()); |
| 83 EXPECT_EQ(windows[1], *list_provider.GetWindowList().rbegin()); |
| 84 |
| 85 controller.ActivateSplitMode(windows[4], windows[5]); |
| 86 EXPECT_EQ(windows[4], controller.left_window()); |
| 87 EXPECT_EQ(windows[5], controller.right_window()); |
| 88 EXPECT_EQ(windows[4], *list_provider.GetWindowList().rbegin()); |
| 89 EXPECT_EQ(windows[5], *(list_provider.GetWindowList().rbegin() + 1)); |
| 90 } |
| 91 |
| 92 } // namespace athena |
OLD | NEW |