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/macros.h" | 5 #include "base/macros.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "mojo/public/cpp/application/application_connection.h" | |
8 #include "mojo/public/cpp/application/application_impl.h" | 7 #include "mojo/public/cpp/application/application_impl.h" |
9 #include "mojo/public/cpp/application/application_test_base.h" | 8 #include "mojo/public/cpp/application/application_test_base.h" |
| 9 #include "mojo/public/cpp/application/connect.h" |
10 #include "mojo/public/cpp/bindings/strong_binding.h" | 10 #include "mojo/public/cpp/bindings/strong_binding.h" |
11 #include "mojo/public/cpp/system/data_pipe.h" | 11 #include "mojo/public/cpp/system/data_pipe.h" |
12 #include "mojo/services/network/interfaces/network_service.mojom.h" | 12 #include "mojo/services/network/interfaces/network_service.mojom.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 namespace service { | 16 namespace service { |
17 namespace { | 17 namespace { |
18 | 18 |
19 const char kMessage[] = "Hello World\n"; | 19 const char kMessage[] = "Hello World\n"; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 }; | 181 }; |
182 | 182 |
183 class URLLoaderInterceptorAppTest : public test::ApplicationTestBase { | 183 class URLLoaderInterceptorAppTest : public test::ApplicationTestBase { |
184 public: | 184 public: |
185 URLLoaderInterceptorAppTest() {} | 185 URLLoaderInterceptorAppTest() {} |
186 ~URLLoaderInterceptorAppTest() override {} | 186 ~URLLoaderInterceptorAppTest() override {} |
187 | 187 |
188 void SetUp() override { | 188 void SetUp() override { |
189 ApplicationTestBase::SetUp(); | 189 ApplicationTestBase::SetUp(); |
190 | 190 |
191 ApplicationConnection* connection = | 191 ConnectToService(application_impl()->shell(), "mojo:network_service", |
192 application_impl()->ConnectToApplication("mojo:network_service"); | 192 GetProxy(&network_service_)); |
193 connection->ConnectToService(&network_service_); | |
194 } | 193 } |
195 | 194 |
196 URLResponsePtr GetResponse(const std::string& url) { | 195 URLResponsePtr GetResponse(const std::string& url) { |
197 URLRequestPtr request = URLRequest::New(); | 196 URLRequestPtr request = URLRequest::New(); |
198 request->url = url; | 197 request->url = url; |
199 URLLoaderPtr loader; | 198 URLLoaderPtr loader; |
200 network_service_->CreateURLLoader(GetProxy(&loader)); | 199 network_service_->CreateURLLoader(GetProxy(&loader)); |
201 URLResponsePtr response; | 200 URLResponsePtr response; |
202 { | 201 { |
203 base::RunLoop loop; | 202 base::RunLoop loop; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 AddInterceptor<CheckCallsInterceptor>(); | 284 AddInterceptor<CheckCallsInterceptor>(); |
286 | 285 |
287 URLResponsePtr response = GetResponse(kUrl1); | 286 URLResponsePtr response = GetResponse(kUrl1); |
288 EXPECT_TRUE(response); | 287 EXPECT_TRUE(response); |
289 EXPECT_EQ(kUrl1, response->url); | 288 EXPECT_EQ(kUrl1, response->url); |
290 EXPECT_EQ(1u, response->headers.size()); | 289 EXPECT_EQ(1u, response->headers.size()); |
291 } | 290 } |
292 | 291 |
293 } // namespace service | 292 } // namespace service |
294 } // namespace mojo | 293 } // namespace mojo |
OLD | NEW |