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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/shell/shell_test_base.h" 5 #include "mojo/shell/shell_test_base.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "net/base/filename_util.h" 13 #include "net/base/filename_util.h"
14 #include "net/test/embedded_test_server/embedded_test_server.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 namespace shell { 18 namespace shell {
18 namespace test { 19 namespace test {
19 20
20 ShellTestBase::ShellTestBase() { 21 ShellTestBase::ShellTestBase() {
21 } 22 }
22 23
23 ShellTestBase::~ShellTestBase() { 24 ShellTestBase::~ShellTestBase() {
24 } 25 }
25 26
27 void ShellTestBase::SetUp() {
28 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
29 ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady());
30 base::FilePath service_dir;
31 CHECK(PathService::Get(base::DIR_MODULE, &service_dir));
32 test_server_->ServeFilesFromDirectory(service_dir);
33 }
34
35 ScopedMessagePipeHandle ShellTestBase::ConnectToServiceViaNetwork(
36 const GURL& application_url,
37 const std::string& service_name) {
38 shell_context_.mojo_url_resolver()->SetOrigin(
39 test_server_->base_url().spec());
40
41 return shell_context_.service_manager()->ConnectToServiceByName(
42 application_url, service_name).Pass();
43 }
44
26 ScopedMessagePipeHandle ShellTestBase::ConnectToService( 45 ScopedMessagePipeHandle ShellTestBase::ConnectToService(
27 const GURL& application_url, 46 const GURL& application_url,
28 const std::string& service_name) { 47 const std::string& service_name) {
48 // Set the MojoURLResolver origin to be the same as the base file path for
49 // local files. This is primarily for test convenience, so that references
50 // to unknown mojo: urls that do not have specific local file or custom
51 // mappings registered on the URL resolver are treated as shared libraries.
29 base::FilePath service_dir; 52 base::FilePath service_dir;
30 CHECK(PathService::Get(base::DIR_MODULE, &service_dir)); 53 CHECK(PathService::Get(base::DIR_MODULE, &service_dir));
31 shell_context_.mojo_url_resolver()->set_origin( 54 shell_context_.mojo_url_resolver()->SetOrigin(
32 net::FilePathToFileURL(service_dir).spec()); 55 net::FilePathToFileURL(service_dir).spec());
33 56
34 return shell_context_.service_manager()->ConnectToServiceByName( 57 return shell_context_.service_manager()->ConnectToServiceByName(
35 application_url, service_name).Pass(); 58 application_url, service_name).Pass();
36 } 59 }
37 60
38 } // namespace test 61 } // namespace test
39 } // namespace shell 62 } // namespace shell
40 } // namespace mojo 63 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698