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

Unified Diff: mojo/shell/shell_test_helper.h

Issue 256133002: Changes view manager test to connect via shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge to trunk Created 6 years, 8 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
« no previous file with comments | « mojo/shell/run.cc ('k') | mojo/shell/shell_test_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/shell_test_helper.h
diff --git a/mojo/shell/shell_test_helper.h b/mojo/shell/shell_test_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..53d84a30b76faed2256397fe69ca647c4ed25e22
--- /dev/null
+++ b/mojo/shell/shell_test_helper.h
@@ -0,0 +1,66 @@
+// 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.
+
+#ifndef MOJO_SHELL_SHELL_TEST_HELPER_
+#define MOJO_SHELL_SHELL_TEST_HELPER_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/run_loop.h"
+#include "base/threading/thread.h"
+#include "mojo/public/cpp/bindings/remote_ptr.h"
+#include "mojo/public/cpp/environment/environment.h"
+#include "mojo/public/interfaces/shell/shell.mojom.h"
+
+namespace base {
+class MessageLoopProxy;
+class RunLoop;
+}
+
+namespace mojo {
+namespace shell {
+
+// ShellTestHelper is useful for tests to establish a connection to the Shell.
+// ShellTestHelper does this by spawning a thread and connecting. Invoke Init()
+// to do this. Once done, shell() returns the handle to the Shell.
+class ShellTestHelper {
+ public:
+ struct State;
+
+ ShellTestHelper();
+ ~ShellTestHelper();
+
+ void Init();
+
+ // Returns a handle to the Shell. ShellTestHelper owns the shell.
+ Shell* shell() { return shell_.get(); }
+
+ private:
+ class TestShellClient;
+
+ // Invoked once connection has been established.
+ void OnShellStarted();
+
+ Environment environment_;
+
+ base::Thread shell_thread_;
+
+ // If non-null we're in Init() and waiting for connection.
+ scoped_ptr<base::RunLoop> run_loop_;
+
+ // See comment in declaration for details.
+ State* state_;
+
+ // Client interface for the shell.
+ scoped_ptr<TestShellClient> shell_client_;
+
+ RemotePtr<Shell> shell_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellTestHelper);
+};
+
+} // namespace shell
+} // namespace mojo
+
+#endif // MOJO_SHELL_SHELL_TEST_HELPER_
« no previous file with comments | « mojo/shell/run.cc ('k') | mojo/shell/shell_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698