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/data_pipe_utils/data_pipe_utils.h" | 13 #include "mojo/data_pipe_utils/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/application/connect.h" |
16 #include "mojo/public/cpp/system/macros.h" | 17 #include "mojo/public/cpp/system/macros.h" |
| 18 #include "mojo/public/interfaces/application/application_connector.mojom.h" |
17 #include "mojo/services/http_server/cpp/http_server_util.h" | 19 #include "mojo/services/http_server/cpp/http_server_util.h" |
18 #include "mojo/services/http_server/interfaces/http_server.mojom.h" | 20 #include "mojo/services/http_server/interfaces/http_server.mojom.h" |
19 #include "mojo/services/http_server/interfaces/http_server_factory.mojom.h" | 21 #include "mojo/services/http_server/interfaces/http_server_factory.mojom.h" |
20 #include "mojo/services/network/interfaces/net_address.mojom.h" | 22 #include "mojo/services/network/interfaces/net_address.mojom.h" |
21 #include "shell/kPingable.h" | 23 #include "shell/kPingable.h" |
22 #include "shell/test/pingable.mojom.h" | 24 #include "shell/test/pingable.mojom.h" |
23 | 25 |
24 using mojo::String; | 26 using mojo::String; |
25 | 27 |
26 namespace { | 28 namespace { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 const String& message) { | 190 const String& message) { |
189 EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true)); | 191 EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true)); |
190 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); | 192 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); |
191 EXPECT_EQ("hello", message); | 193 EXPECT_EQ("hello", message); |
192 base::MessageLoop::current()->Quit(); | 194 base::MessageLoop::current()->Quit(); |
193 }; | 195 }; |
194 pingable->Ping("hello", callback); | 196 pingable->Ping("hello", callback); |
195 base::RunLoop().Run(); | 197 base::RunLoop().Run(); |
196 } | 198 } |
197 | 199 |
| 200 TEST_F(ShellAppTest, ApplicationConnector) { |
| 201 mojo::ApplicationConnectorPtr app_connector; |
| 202 app_connector.Bind(application_impl()->CreateApplicationConnector()); |
| 203 |
| 204 PingablePtr pingable; |
| 205 ConnectToService(app_connector.get(), "mojo:pingable_app", &pingable); |
| 206 auto callback = [this](const String& app_url, const String& connection_url, |
| 207 const String& message) { |
| 208 EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true)); |
| 209 EXPECT_EQ(app_url, connection_url); |
| 210 EXPECT_EQ("hello", message); |
| 211 base::MessageLoop::current()->Quit(); |
| 212 }; |
| 213 pingable->Ping("hello", callback); |
| 214 base::RunLoop().Run(); |
| 215 } |
| 216 |
198 } // namespace | 217 } // namespace |
OLD | NEW |