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 "mojo/fetcher/about_fetcher.h" | 5 #include "mojo/fetcher/about_fetcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "mojo/application/public/cpp/application_connection.h" | 17 #include "mojo/application/public/cpp/application_connection.h" |
18 #include "mojo/application/public/cpp/application_delegate.h" | 18 #include "mojo/application/public/cpp/application_delegate.h" |
19 #include "mojo/application/public/cpp/application_impl.h" | 19 #include "mojo/application/public/cpp/application_impl.h" |
20 #include "mojo/application/public/cpp/interface_factory.h" | 20 #include "mojo/application/public/cpp/interface_factory.h" |
21 #include "mojo/application/public/interfaces/content_handler.mojom.h" | 21 #include "mojo/application/public/interfaces/content_handler.mojom.h" |
22 #include "mojo/common/weak_binding_set.h" | 22 #include "mojo/common/weak_binding_set.h" |
23 #include "mojo/package_manager/package_manager_impl.h" | |
24 #include "mojo/shell/application_loader.h" | 23 #include "mojo/shell/application_loader.h" |
25 #include "mojo/shell/application_manager.h" | 24 #include "mojo/shell/application_manager.h" |
| 25 #include "mojo/shell/package_manager/package_manager_impl.h" |
26 #include "mojo/util/filename_util.h" | 26 #include "mojo/util/filename_util.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 | 28 |
29 namespace mojo { | 29 namespace mojo { |
30 namespace fetcher { | 30 namespace fetcher { |
31 namespace { | 31 namespace { |
32 | 32 |
33 class TestContentHandler : public ApplicationDelegate, | 33 class TestContentHandler : public ApplicationDelegate, |
34 public InterfaceFactory<ContentHandler>, | 34 public InterfaceFactory<ContentHandler>, |
35 public ContentHandler { | 35 public ContentHandler { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 params->set_services(std::move(service_provider_request)); | 123 params->set_services(std::move(service_provider_request)); |
124 application_manager_->ConnectToApplication(std::move(params)); | 124 application_manager_->ConnectToApplication(std::move(params)); |
125 | 125 |
126 run_loop.Run(); | 126 run_loop.Run(); |
127 } | 127 } |
128 | 128 |
129 // Overridden from testing::Test: | 129 // Overridden from testing::Test: |
130 void SetUp() override { | 130 void SetUp() override { |
131 base::FilePath shell_dir; | 131 base::FilePath shell_dir; |
132 PathService::Get(base::DIR_MODULE, &shell_dir); | 132 PathService::Get(base::DIR_MODULE, &shell_dir); |
133 scoped_ptr<package_manager::PackageManagerImpl> package_manager( | 133 scoped_ptr<shell::PackageManagerImpl> package_manager( |
134 new package_manager::PackageManagerImpl(shell_dir, nullptr)); | 134 new shell::PackageManagerImpl(shell_dir, nullptr)); |
135 package_manager->RegisterContentHandler( | 135 package_manager->RegisterContentHandler( |
136 "text/html", GURL("test:html_content_handler")); | 136 "text/html", GURL("test:html_content_handler")); |
137 application_manager_.reset( | 137 application_manager_.reset( |
138 new shell::ApplicationManager(std::move(package_manager))); | 138 new shell::ApplicationManager(std::move(package_manager))); |
139 application_manager_->SetLoaderForURL( | 139 application_manager_->SetLoaderForURL( |
140 make_scoped_ptr(new TestLoader(&html_content_handler_)), | 140 make_scoped_ptr(new TestLoader(&html_content_handler_)), |
141 GURL("test:html_content_handler")); | 141 GURL("test:html_content_handler")); |
142 } | 142 } |
143 | 143 |
144 void TearDown() override { application_manager_.reset(); } | 144 void TearDown() override { application_manager_.reset(); } |
(...skipping 27 matching lines...) Expand all Loading... |
172 const URLResponse* response = html_content_handler()->latest_response(); | 172 const URLResponse* response = html_content_handler()->latest_response(); |
173 EXPECT_EQ("about:some_unrecognized_url", response->url); | 173 EXPECT_EQ("about:some_unrecognized_url", response->url); |
174 EXPECT_EQ(404u, response->status_code); | 174 EXPECT_EQ(404u, response->status_code); |
175 EXPECT_EQ("text/html", response->mime_type); | 175 EXPECT_EQ("text/html", response->mime_type); |
176 EXPECT_FALSE(response->body.is_valid()); | 176 EXPECT_FALSE(response->body.is_valid()); |
177 } | 177 } |
178 | 178 |
179 } // namespace | 179 } // namespace |
180 } // namespace fetcher | 180 } // namespace fetcher |
181 } // namespace mojo | 181 } // namespace mojo |
OLD | NEW |