OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "mojo/application/public/cpp/application_connection.h" | 11 #include "mojo/application/public/cpp/application_connection.h" |
12 #include "mojo/application/public/cpp/application_delegate.h" | 12 #include "mojo/application/public/cpp/application_delegate.h" |
13 #include "mojo/application/public/cpp/application_impl.h" | 13 #include "mojo/application/public/cpp/application_impl.h" |
14 #include "mojo/application/public/cpp/interface_factory.h" | 14 #include "mojo/application/public/cpp/interface_factory.h" |
15 #include "mojo/application/public/interfaces/content_handler.mojom.h" | 15 #include "mojo/application/public/interfaces/content_handler.mojom.h" |
16 #include "mojo/common/weak_binding_set.h" | 16 #include "mojo/common/weak_binding_set.h" |
17 #include "mojo/fetcher/about_fetcher.h" | 17 #include "mojo/fetcher/about_fetcher.h" |
18 #include "mojo/fetcher/base_application_fetcher.h" | 18 #include "mojo/package_manager/package_manager_impl.h" |
19 #include "mojo/runner/context.h" | 19 #include "mojo/runner/context.h" |
20 #include "mojo/shell/application_loader.h" | 20 #include "mojo/shell/application_loader.h" |
21 #include "mojo/shell/application_manager.h" | 21 #include "mojo/shell/application_manager.h" |
22 #include "mojo/util/filename_util.h" | 22 #include "mojo/util/filename_util.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 | 24 |
25 namespace mojo { | 25 namespace mojo { |
26 namespace fetcher { | 26 namespace fetcher { |
27 namespace { | 27 namespace { |
28 | 28 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 shell::EmptyConnectCallback()); | 118 shell::EmptyConnectCallback()); |
119 | 119 |
120 run_loop.Run(); | 120 run_loop.Run(); |
121 } | 121 } |
122 | 122 |
123 // Overridden from testing::Test: | 123 // Overridden from testing::Test: |
124 void SetUp() override { | 124 void SetUp() override { |
125 runner::Context::EnsureEmbedderIsInitialized(); | 125 runner::Context::EnsureEmbedderIsInitialized(); |
126 base::FilePath shell_dir; | 126 base::FilePath shell_dir; |
127 PathService::Get(base::DIR_MODULE, &shell_dir); | 127 PathService::Get(base::DIR_MODULE, &shell_dir); |
128 application_manager_.reset(new shell::ApplicationManager( | 128 scoped_ptr<package_manager::PackageManagerImpl> package_manager( |
129 make_scoped_ptr(new BaseApplicationFetcher(shell_dir)))); | 129 new package_manager::PackageManagerImpl(shell_dir)); |
| 130 package_manager->RegisterContentHandler( |
| 131 "text/html", GURL("test:html_content_handler")); |
| 132 application_manager_.reset( |
| 133 new shell::ApplicationManager(package_manager.Pass())); |
130 application_manager_->SetLoaderForURL( | 134 application_manager_->SetLoaderForURL( |
131 make_scoped_ptr(new TestLoader(&html_content_handler_)), | 135 make_scoped_ptr(new TestLoader(&html_content_handler_)), |
132 GURL("test:html_content_handler")); | 136 GURL("test:html_content_handler")); |
133 application_manager_->RegisterContentHandler( | |
134 "text/html", GURL("test:html_content_handler")); | |
135 } | 137 } |
136 | 138 |
137 void TearDown() override { application_manager_.reset(); } | 139 void TearDown() override { application_manager_.reset(); } |
138 | 140 |
139 private: | 141 private: |
140 base::ShadowingAtExitManager at_exit_; | 142 base::ShadowingAtExitManager at_exit_; |
141 TestContentHandler html_content_handler_; | 143 TestContentHandler html_content_handler_; |
142 base::MessageLoop loop_; | 144 base::MessageLoop loop_; |
143 scoped_ptr<shell::ApplicationManager> application_manager_; | 145 scoped_ptr<shell::ApplicationManager> application_manager_; |
144 | 146 |
(...skipping 20 matching lines...) Expand all Loading... |
165 const URLResponse* response = html_content_handler()->latest_response(); | 167 const URLResponse* response = html_content_handler()->latest_response(); |
166 EXPECT_EQ("about:some_unrecognized_url", response->url); | 168 EXPECT_EQ("about:some_unrecognized_url", response->url); |
167 EXPECT_EQ(404u, response->status_code); | 169 EXPECT_EQ(404u, response->status_code); |
168 EXPECT_EQ("text/html", response->mime_type); | 170 EXPECT_EQ("text/html", response->mime_type); |
169 EXPECT_FALSE(response->body.is_valid()); | 171 EXPECT_FALSE(response->body.is_valid()); |
170 } | 172 } |
171 | 173 |
172 } // namespace | 174 } // namespace |
173 } // namespace fetcher | 175 } // namespace fetcher |
174 } // namespace mojo | 176 } // namespace mojo |
OLD | NEW |