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