Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: athena/wm/split_view_controller_unittest.cc

Issue 472963002: athena: Add a test for split-view controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« athena/wm/split_view_controller.h ('K') | « athena/wm/split_view_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/wm/split_view_controller_unittest.cc
diff --git a/athena/wm/split_view_controller_unittest.cc b/athena/wm/split_view_controller_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..db68c0a884d439ea0907362dbf185ebde3f737a1
--- /dev/null
+++ b/athena/wm/split_view_controller_unittest.cc
@@ -0,0 +1,84 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/wm/split_view_controller.h"
+
+#include "athena/common/fill_layout_manager.h"
+#include "athena/test/athena_test_base.h"
+#include "athena/wm/public/window_list_provider.h"
+#include "base/memory/scoped_vector.h"
+#include "ui/aura/test/test_window_delegate.h"
+#include "ui/aura/window.h"
+
+namespace athena {
+
+typedef test::AthenaTestBase SplitViewControllerTest;
+
+class SimpleWindowListProvider : public WindowListProvider {
+ public:
+ explicit SimpleWindowListProvider(aura::Window* container)
+ : container_(container) {}
+ virtual ~SimpleWindowListProvider() {}
+
+ private:
+ // WindowListProvider:
+ virtual aura::Window::Windows GetWindowList() const OVERRIDE {
+ return container_->children();
+ }
+
+ virtual void MoveToFront(aura::Window* window) OVERRIDE {
+ CHECK_EQ(container_, window->parent());
+ container_->StackChildAtTop(window);
+ }
+
+ aura::Window* container_;
+
+ DISALLOW_COPY_AND_ASSIGN(SimpleWindowListProvider);
+};
+
+// Tests that when split mode is activated, the windows on the left and right
+// are selected correctly.
+TEST_F(SplitViewControllerTest, SplitModeActivation) {
+ aura::test::TestWindowDelegate delegate;
+ ScopedVector<aura::Window> windows;
+ const int kNumWindows = 6;
+ for (size_t i = 0; i < kNumWindows; ++i) {
+ aura::Window* window = new aura::Window(&delegate);
+ window->Init(aura::WINDOW_LAYER_SOLID_COLOR);
+ root_window()->AddChild(window);
+ windows.push_back(window);
+ }
+
+ SimpleWindowListProvider list_provider(root_window());
+ SplitViewController controller(root_window(), &list_provider, NULL);
+ ASSERT_FALSE(controller.IsSplitViewModeActive());
+
+ controller.ActivateSplitMode(NULL, NULL);
+ ASSERT_TRUE(controller.IsSplitViewModeActive());
+ // The last two windows should be on the left and right, respectively.
+ EXPECT_EQ(windows[kNumWindows - 1], controller.left_window());
+ EXPECT_EQ(windows[kNumWindows - 2], controller.right_window());
+
+ // Select the window that is currently on the left for the right panel. The
+ // windows should switch.
+ controller.ActivateSplitMode(NULL, windows[kNumWindows - 1]);
+ EXPECT_EQ(windows[kNumWindows - 2], controller.left_window());
+ EXPECT_EQ(windows[kNumWindows - 1], controller.right_window());
+
+ controller.ActivateSplitMode(windows[kNumWindows - 1], NULL);
+ EXPECT_EQ(windows[kNumWindows - 1], controller.left_window());
+ EXPECT_EQ(windows[kNumWindows - 2], controller.right_window());
+
+ // Select one of the windows behind the stacks for the right panel. The window
+ // on the left should remain unchanged.
+ controller.ActivateSplitMode(NULL, windows[0]);
+ EXPECT_EQ(windows[kNumWindows - 1], controller.left_window());
+ 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.
+
+ controller.ActivateSplitMode(windows[1], NULL);
+ EXPECT_EQ(windows[1], controller.left_window());
+ 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.
+}
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.
+
+} // namespace athena
« athena/wm/split_view_controller.h ('K') | « athena/wm/split_view_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698