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

Unified Diff: mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc

Issue 260863008: Add support for mapping node tree on the client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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
Index: mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc
diff --git a/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc b/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..102fedd337b608bcb80b3f80deb32efc939b6576 100644
--- a/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc
+++ b/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc
@@ -0,0 +1,99 @@
+// 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 "mojo/services/public/cpp/view_manager/view_manager.h"
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "mojo/services/public/cpp/view_manager/lib/view_manager_observer.h"
+#include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h"
+#include "mojo/services/public/cpp/view_manager/util.h"
+#include "mojo/shell/shell_test_helper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace mojo {
+namespace services {
+namespace view_manager {
+
+base::RunLoop* current_run_loop = NULL;
+
+void DoRunLoop() {
+ base::RunLoop run_loop;
+ current_run_loop = &run_loop;
+ current_run_loop->Run();
+ current_run_loop = NULL;
+}
+
+void QuitRunLoop() {
+ current_run_loop->Quit();
+}
+
+// ViewManager -----------------------------------------------------------------
+
+class ViewManagerTest : public testing::Test,
+ public ViewManagerObserver {
+ public:
+ ViewManagerTest() : connection_count_(0), commit_count_(0) {}
+
+ protected:
+ ViewManager* view_manager_1() { return view_manager_1_.get(); }
+ ViewManager* view_manager_2() { return view_manager_2_.get(); }
+
+ private:
+ // Overridden from testing::Test:
+ virtual void SetUp() OVERRIDE {
+ test_helper_.Init();
+ view_manager_1_.reset(new ViewManager(test_helper_.shell()));
+ view_manager_2_.reset(new ViewManager(test_helper_.shell()));
+ ViewManagerPrivate(view_manager_1_.get()).AddObserver(this);
+ ViewManagerPrivate(view_manager_2_.get()).AddObserver(this);
+
+ // Wait for service connection to be established.
+ DoRunLoop();
+ }
+
+ // Overridden from ViewManagerObserver:
+ virtual void OnViewManagerConnected(ViewManager* manager) OVERRIDE {
+ if (++connection_count_ == 2)
+ QuitRunLoop();
+ }
+ virtual void OnCommit(ViewManager* manager) OVERRIDE {
+ ++commit_count_;
+ }
+ virtual void OnCommitResponse(ViewManager* manager, bool success) OVERRIDE {
+ if (--commit_count_ == 0)
+ QuitRunLoop();
+ }
+
+ base::MessageLoop loop_;
+ shell::ShellTestHelper test_helper_;
+ scoped_ptr<ViewManager> view_manager_1_;
+ scoped_ptr<ViewManager> view_manager_2_;
+ int connection_count_;
+ int commit_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(ViewManagerTest);
+};
+
+TEST_F(ViewManagerTest, BuildNodeTree) {
+ view_manager_1()->BuildNodeTree(base::Bind(&QuitRunLoop));
+ DoRunLoop();
+
+ scoped_ptr<ViewTreeNode> node1(new ViewTreeNode(view_manager_1()));
+ view_manager_1()->tree()->AddChild(node1.get());
+ DoRunLoop();
+
+ view_manager_2()->BuildNodeTree(base::Bind(&QuitRunLoop));
+ DoRunLoop();
+
+ EXPECT_EQ(LoWord(view_manager_2()->tree()->children().front()->id()),
+ LoWord(node1->id()));
+}
+
+// TODO(beng): node hierarchy changed
+// TODO(beng): node destruction
+
+} // namespace view_manager
+} // namespace services
+} // namespace mojo
« no previous file with comments | « mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h ('k') | mojo/services/public/cpp/view_manager/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698