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" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 local_address->ipv4->addr.resize(4); | 84 local_address->ipv4->addr.resize(4); |
85 local_address->ipv4->addr[0] = 127; | 85 local_address->ipv4->addr[0] = 127; |
86 local_address->ipv4->addr[1] = 0; | 86 local_address->ipv4->addr[1] = 0; |
87 local_address->ipv4->addr[2] = 0; | 87 local_address->ipv4->addr[2] = 0; |
88 local_address->ipv4->addr[3] = 1; | 88 local_address->ipv4->addr[3] = 1; |
89 local_address->ipv4->port = 0; | 89 local_address->ipv4->port = 0; |
90 http_server_factory_->CreateHttpServer(GetProxy(&http_server_), | 90 http_server_factory_->CreateHttpServer(GetProxy(&http_server_), |
91 local_address.Pass()); | 91 local_address.Pass()); |
92 | 92 |
93 http_server_->GetPort([this](uint16_t p) { port_ = p; }); | 93 http_server_->GetPort([this](uint16_t p) { port_ = p; }); |
94 EXPECT_TRUE(http_server_.WaitForIncomingResponse()); | 94 EXPECT_TRUE(http_server_.WaitForIncomingMethodCall()); |
95 | 95 |
96 InterfacePtr<http_server::HttpHandler> http_handler; | 96 InterfacePtr<http_server::HttpHandler> http_handler; |
97 handler_.reset(new GetHandler(GetProxy(&http_handler).Pass(), port_)); | 97 handler_.reset(new GetHandler(GetProxy(&http_handler).Pass(), port_)); |
98 http_server_->SetHandler(".*", http_handler.Pass(), | 98 http_server_->SetHandler(".*", http_handler.Pass(), |
99 [](bool result) { EXPECT_TRUE(result); }); | 99 [](bool result) { EXPECT_TRUE(result); }); |
100 EXPECT_TRUE(http_server_.WaitForIncomingResponse()); | 100 EXPECT_TRUE(http_server_.WaitForIncomingMethodCall()); |
101 } | 101 } |
102 | 102 |
103 std::string GetURL(const std::string& path) { | 103 std::string GetURL(const std::string& path) { |
104 return ::mojo::GetURL(port_, path); | 104 return ::mojo::GetURL(port_, path); |
105 } | 105 } |
106 | 106 |
107 http_server::HttpServerFactoryPtr http_server_factory_; | 107 http_server::HttpServerFactoryPtr http_server_factory_; |
108 http_server::HttpServerPtr http_server_; | 108 http_server::HttpServerPtr http_server_; |
109 scoped_ptr<GetHandler> handler_; | 109 scoped_ptr<GetHandler> handler_; |
110 uint16_t port_; | 110 uint16_t port_; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); | 188 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); |
189 EXPECT_EQ("hello", message); | 189 EXPECT_EQ("hello", message); |
190 base::MessageLoop::current()->Quit(); | 190 base::MessageLoop::current()->Quit(); |
191 }; | 191 }; |
192 pingable->Ping("hello", callback); | 192 pingable->Ping("hello", callback); |
193 base::RunLoop().Run(); | 193 base::RunLoop().Run(); |
194 } | 194 } |
195 | 195 |
196 } // namespace | 196 } // namespace |
197 } // namespace mojo | 197 } // namespace mojo |
OLD | NEW |