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

Unified Diff: mojo/shell/shell_test_base.cc

Issue 314293002: Mojo: Add a trivial end-to-end (in-process) test of Mojo shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 6 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/shell_test_base.h ('k') | mojo/shell/shell_test_base_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/shell_test_base.cc
diff --git a/mojo/shell/shell_test_base.cc b/mojo/shell/shell_test_base.cc
index f258af474622e89d53bf720e298ac202fe07c7c6..ebe3405169fa5d1e2b456e8cbe2606b851a517ff 100644
--- a/mojo/shell/shell_test_base.cc
+++ b/mojo/shell/shell_test_base.cc
@@ -4,6 +4,15 @@
#include "mojo/shell/shell_test_base.h"
+#include "base/command_line.h"
+#include "base/file_util.h"
+#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "build/build_config.h"
+#include "mojo/shell/context.h"
+#include "net/base/filename_util.h"
+#include "url/gurl.h"
+
namespace mojo {
namespace shell {
namespace test {
@@ -14,6 +23,35 @@ ShellTestBase::ShellTestBase() {
ShellTestBase::~ShellTestBase() {
}
+void ShellTestBase::InitMojo() {
+ DCHECK(!message_loop_);
+ DCHECK(!shell_context_);
+ message_loop_.reset(new base::MessageLoop());
+ shell_context_.reset(new Context());
+}
+
+void ShellTestBase::LaunchServiceInProcess(
+ const GURL& service_url,
+ const std::string& service_name,
+ ScopedMessagePipeHandle client_handle) {
+ DCHECK(message_loop_);
+ DCHECK(shell_context_);
+
+ base::FilePath base_dir = base::MakeAbsoluteFilePath(
+ base::CommandLine::ForCurrentProcess()->GetProgram().DirName());
+ // On Mac and Windows, libraries are dumped beside the executables.
+#if defined(OS_MACOSX) || defined(OS_WIN)
+ base::FilePath service_dir(base_dir);
+#else
+ // On Linux, they're under lib/.
+ base::FilePath service_dir(base_dir.AppendASCII("lib"));
+#endif
+ shell_context_->set_mojo_origin(net::FilePathToFileURL(service_dir).spec());
+
+ shell_context_->service_manager()->ConnectToService(
+ service_url, service_name, client_handle.Pass(), GURL());
+}
+
} // namespace test
} // namespace shell
} // namespace mojo
« no previous file with comments | « mojo/shell/shell_test_base.h ('k') | mojo/shell/shell_test_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698