Chromium Code Reviews| 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 private: | |
| 25 // WindowListProvider: | |
| 26 virtual aura::Window::Windows GetWindowList() const OVERRIDE { | |
| 27 return container_->children(); | |
| 28 } | |
| 29 | |
| 30 virtual void MoveToFront(aura::Window* window) OVERRIDE { | |
| 31 CHECK_EQ(container_, window->parent()); | |
| 32 container_->StackChildAtTop(window); | |
| 33 } | |
| 34 | |
| 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()); | |
|
mfomitchev
2014/08/14 22:30:20
Should we also confirm that windows[0] moves to th
sadrul
2014/08/15 00:20:14
Done.
| |
| 78 | |
| 79 controller.ActivateSplitMode(windows[1], NULL); | |
| 80 EXPECT_EQ(windows[1], controller.left_window()); | |
| 81 EXPECT_EQ(windows[0], controller.right_window()); | |
|
mfomitchev
2014/08/14 22:30:20
Confirm windows[1] moves to the top?
sadrul
2014/08/15 00:20:14
Done.
| |
| 82 } | |
|
mfomitchev
2014/08/14 22:30:20
Can you also add a test for passing two non-null w
sadrul
2014/08/15 00:20:14
Done.
| |
| 83 | |
| 84 } // namespace athena | |
| OLD | NEW |