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

Unified Diff: mojo/shell/shell_test_base.cc

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 9 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_android.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
new file mode 100644
index 0000000000000000000000000000000000000000..da9a7d95f53639bb344cbea798395ac9d8bb65bc
--- /dev/null
+++ b/mojo/shell/shell_test_base.cc
@@ -0,0 +1,73 @@
+// 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/shell/shell_test_base.h"
+
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "build/build_config.h"
+#include "mojo/shell/filename_util.h"
+#include "url/gurl.h"
+
+namespace mojo {
+namespace shell {
+namespace test {
+
+namespace {
+
+void QuitIfRunning() {
+ if (base::MessageLoop::current() &&
+ base::MessageLoop::current()->is_running()) {
+ base::MessageLoop::current()->QuitWhenIdle();
+ }
+}
+
+} // namespace
+
+ShellTestBase::ShellTestBase() {
+}
+
+ShellTestBase::~ShellTestBase() {
+}
+
+void ShellTestBase::SetUp() {
+ CHECK(shell_context_.Init());
+ SetUpTestApplications();
+}
+
+void ShellTestBase::TearDown() {
+ shell_context_.Shutdown();
+}
+
+ScopedMessagePipeHandle ShellTestBase::ConnectToService(
+ const GURL& application_url,
+ const std::string& service_name) {
+ ServiceProviderPtr services;
+ shell_context_.application_manager()->ConnectToApplication(
+ application_url, GURL(), GetProxy(&services), nullptr,
+ base::Bind(&QuitIfRunning));
+ MessagePipe pipe;
+ services->ConnectToService(service_name, pipe.handle1.Pass());
+ return pipe.handle0.Pass();
+}
+
+#if !defined(OS_ANDROID)
+void ShellTestBase::SetUpTestApplications() {
+ // Set the URLResolver origin to be the same as the base file path for
+ // local files. This is primarily for test convenience, so that references
+ // to unknown mojo: urls that do not have specific local file or custom
+ // mappings registered on the URL resolver are treated as shared libraries.
+ base::FilePath service_dir;
+ CHECK(PathService::Get(base::DIR_MODULE, &service_dir));
+ shell_context_.url_resolver()->SetMojoBaseURL(FilePathToFileURL(service_dir));
+}
+#endif
+
+} // namespace test
+} // namespace shell
+} // namespace mojo
« no previous file with comments | « mojo/shell/shell_test_base.h ('k') | mojo/shell/shell_test_base_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698