OLD | NEW |
---|---|
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" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 void ShellTestBase::SetUp() { | 27 void ShellTestBase::SetUp() { |
28 shell_context_.Init(); | 28 shell_context_.Init(); |
29 test_server_.reset(new net::test_server::EmbeddedTestServer()); | 29 test_server_.reset(new net::test_server::EmbeddedTestServer()); |
30 ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady()); | 30 ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady()); |
31 base::FilePath service_dir; | 31 base::FilePath service_dir; |
32 CHECK(PathService::Get(base::DIR_MODULE, &service_dir)); | 32 CHECK(PathService::Get(base::DIR_MODULE, &service_dir)); |
33 test_server_->ServeFilesFromDirectory(service_dir); | 33 test_server_->ServeFilesFromDirectory(service_dir); |
34 } | 34 } |
35 | 35 |
36 ScopedMessagePipeHandle ShellTestBase::ConnectToServiceViaNetwork( | |
37 const GURL& application_url, | |
38 const std::string& service_name) { | |
39 shell_context_.mojo_url_resolver()->SetBaseURL( | |
40 test_server_->base_url()); | |
tim (not reviewing)
2014/08/22 22:24:21
This was the key to using NetworkService rather th
DaveMoore
2014/08/22 22:48:35
Whoops. I changed that accidentally. It's back now
| |
41 | |
42 return shell_context_.application_manager() | |
43 ->ConnectToServiceByName(application_url, service_name) | |
44 .Pass(); | |
45 } | |
46 | |
47 ScopedMessagePipeHandle ShellTestBase::ConnectToService( | 36 ScopedMessagePipeHandle ShellTestBase::ConnectToService( |
48 const GURL& application_url, | 37 const GURL& application_url, |
49 const std::string& service_name) { | 38 const std::string& service_name) { |
50 // Set the MojoURLResolver origin to be the same as the base file path for | 39 // Set the MojoURLResolver origin to be the same as the base file path for |
51 // local files. This is primarily for test convenience, so that references | 40 // local files. This is primarily for test convenience, so that references |
52 // to unknown mojo: urls that do not have specific local file or custom | 41 // to unknown mojo: urls that do not have specific local file or custom |
53 // mappings registered on the URL resolver are treated as shared libraries. | 42 // mappings registered on the URL resolver are treated as shared libraries. |
54 base::FilePath service_dir; | 43 base::FilePath service_dir; |
55 CHECK(PathService::Get(base::DIR_MODULE, &service_dir)); | 44 CHECK(PathService::Get(base::DIR_MODULE, &service_dir)); |
56 shell_context_.mojo_url_resolver()->SetBaseURL( | 45 shell_context_.mojo_url_resolver()->SetBaseURL( |
57 net::FilePathToFileURL(service_dir)); | 46 net::FilePathToFileURL(service_dir)); |
58 | 47 |
59 return shell_context_.application_manager() | 48 return shell_context_.ConnectToServiceByName( |
60 ->ConnectToServiceByName(application_url, service_name) | 49 application_url, service_name).Pass(); |
61 .Pass(); | |
62 } | 50 } |
63 | 51 |
64 } // namespace test | 52 } // namespace test |
65 } // namespace shell | 53 } // namespace shell |
66 } // namespace mojo | 54 } // namespace mojo |
OLD | NEW |