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/base_paths.h" | 5 #include "base/base_paths.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.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 "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "mojo/common/data_pipe_utils.h" | 13 #include "mojo/common/data_pipe_utils.h" |
14 #include "mojo/public/cpp/application/application_impl.h" | 14 #include "mojo/public/cpp/application/application_impl.h" |
15 #include "mojo/public/cpp/application/application_test_base.h" | 15 #include "mojo/public/cpp/application/application_test_base.h" |
16 #include "mojo/public/cpp/system/macros.h" | 16 #include "mojo/public/cpp/system/macros.h" |
17 #include "mojo/services/network/public/interfaces/net_address.mojom.h" | 17 #include "mojo/services/network/public/interfaces/net_address.mojom.h" |
18 #include "services/http_server/public/http_server.mojom.h" | 18 #include "services/http_server/public/http_server.mojom.h" |
19 #include "services/http_server/public/http_server_factory.mojom.h" | 19 #include "services/http_server/public/http_server_factory.mojom.h" |
20 #include "services/http_server/public/http_server_util.h" | 20 #include "services/http_server/public/http_server_util.h" |
21 #include "shell/kPingable.h" | 21 #include "shell/kPingable.h" |
22 #include "shell/test/pingable.mojom.h" | 22 #include "shell/test/pingable.mojom.h" |
| 23 |
23 namespace mojo { | 24 namespace mojo { |
24 | |
25 namespace { | 25 namespace { |
26 | 26 |
27 std::string GetURL(uint16_t port, const std::string& path) { | 27 std::string GetURL(uint16_t port, const std::string& path) { |
28 return base::StringPrintf("http://127.0.0.1:%u/%s", port, path.c_str()); | 28 return base::StringPrintf("http://127.0.0.1:%u/%s", |
| 29 static_cast<unsigned>(port), path.c_str()); |
29 } | 30 } |
30 | 31 |
31 } // namespace | |
32 | |
33 class GetHandler : public http_server::HttpHandler { | 32 class GetHandler : public http_server::HttpHandler { |
34 public: | 33 public: |
35 GetHandler(InterfaceRequest<http_server::HttpHandler> request, uint16_t port) | 34 GetHandler(InterfaceRequest<http_server::HttpHandler> request, uint16_t port) |
36 : binding_(this, request.Pass()), port_(port) { | 35 : binding_(this, request.Pass()), port_(port) { |
37 } | 36 } |
38 ~GetHandler() override {} | 37 ~GetHandler() override {} |
39 | 38 |
40 private: | 39 private: |
41 // http_server::HttpHandler: | 40 // http_server::HttpHandler: |
42 void HandleRequest( | 41 void HandleRequest( |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 const String& message) { | 186 const String& message) { |
188 EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true)); | 187 EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true)); |
189 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); | 188 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); |
190 EXPECT_EQ("hello", message); | 189 EXPECT_EQ("hello", message); |
191 base::MessageLoop::current()->Quit(); | 190 base::MessageLoop::current()->Quit(); |
192 }; | 191 }; |
193 pingable->Ping("hello", callback); | 192 pingable->Ping("hello", callback); |
194 base::RunLoop().Run(); | 193 base::RunLoop().Run(); |
195 } | 194 } |
196 | 195 |
| 196 } // namespace |
197 } // namespace mojo | 197 } // namespace mojo |
OLD | NEW |