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

Unified Diff: mojo/shell/shell_test_base.cc

Issue 397733003: mojo: kill app_thread before unloading main app library and add tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/shell/shell_test_base.cc
diff --git a/mojo/shell/shell_test_base.cc b/mojo/shell/shell_test_base.cc
index 24cf859777b80617822bc999363553706b14b1c5..d7aeebd5e1d3bce32a5d6fec072cee2623916e4d 100644
--- a/mojo/shell/shell_test_base.cc
+++ b/mojo/shell/shell_test_base.cc
@@ -11,6 +11,7 @@
#include "base/path_service.h"
#include "build/build_config.h"
#include "net/base/filename_util.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h"
namespace mojo {
@@ -23,12 +24,34 @@ ShellTestBase::ShellTestBase() {
ShellTestBase::~ShellTestBase() {
}
+void ShellTestBase::SetUp() {
+ test_server_.reset(new net::test_server::EmbeddedTestServer());
viettrungluu 2014/07/15 22:44:54 Do we really want to do this for all tests, even o
+ ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady());
+ base::FilePath service_dir;
+ CHECK(PathService::Get(base::DIR_MODULE, &service_dir));
+ test_server_->ServeFilesFromDirectory(service_dir);
+}
+
+ScopedMessagePipeHandle ShellTestBase::ConnectToServiceViaNetwork(
+ const GURL& application_url,
+ const std::string& service_name) {
+ shell_context_.mojo_url_resolver()->SetOrigin(
+ test_server_->base_url().spec());
+
+ return shell_context_.service_manager()->ConnectToServiceByName(
+ application_url, service_name).Pass();
+}
+
ScopedMessagePipeHandle ShellTestBase::ConnectToService(
const GURL& application_url,
const std::string& service_name) {
+ // Set the MojoURLResolver 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_.mojo_url_resolver()->set_origin(
+ shell_context_.mojo_url_resolver()->SetOrigin(
net::FilePathToFileURL(service_dir).spec());
return shell_context_.service_manager()->ConnectToServiceByName(

Powered by Google App Engine
This is Rietveld 408576698