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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 class ShellHTTPAppTest : public ShellAppTest { | 74 class ShellHTTPAppTest : public ShellAppTest { |
75 public: | 75 public: |
76 ShellHTTPAppTest() {} | 76 ShellHTTPAppTest() {} |
77 ~ShellHTTPAppTest() override {} | 77 ~ShellHTTPAppTest() override {} |
78 | 78 |
79 protected: | 79 protected: |
80 void SetUp() override { | 80 void SetUp() override { |
81 ShellAppTest::SetUp(); | 81 ShellAppTest::SetUp(); |
82 | 82 |
83 application_impl()->ConnectToService("mojo:http_server", | 83 application_impl()->ConnectToServiceDeprecated("mojo:http_server", |
84 &http_server_factory_); | 84 &http_server_factory_); |
85 | 85 |
86 mojo::NetAddressPtr local_address(mojo::NetAddress::New()); | 86 mojo::NetAddressPtr local_address(mojo::NetAddress::New()); |
87 local_address->family = mojo::NetAddressFamily::IPV4; | 87 local_address->family = mojo::NetAddressFamily::IPV4; |
88 local_address->ipv4 = mojo::NetAddressIPv4::New(); | 88 local_address->ipv4 = mojo::NetAddressIPv4::New(); |
89 local_address->ipv4->addr.resize(4); | 89 local_address->ipv4->addr.resize(4); |
90 local_address->ipv4->addr[0] = 127; | 90 local_address->ipv4->addr[0] = 127; |
91 local_address->ipv4->addr[1] = 0; | 91 local_address->ipv4->addr[1] = 0; |
92 local_address->ipv4->addr[2] = 0; | 92 local_address->ipv4->addr[2] = 0; |
93 local_address->ipv4->addr[3] = 1; | 93 local_address->ipv4->addr[3] = 1; |
94 local_address->ipv4->port = 0; | 94 local_address->ipv4->port = 0; |
(...skipping 17 matching lines...) Expand all Loading... |
112 scoped_ptr<GetHandler> handler_; | 112 scoped_ptr<GetHandler> handler_; |
113 uint16_t port_; | 113 uint16_t port_; |
114 | 114 |
115 private: | 115 private: |
116 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellHTTPAppTest); | 116 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellHTTPAppTest); |
117 }; | 117 }; |
118 | 118 |
119 // Test that we can load apps over http. | 119 // Test that we can load apps over http. |
120 TEST_F(ShellHTTPAppTest, Http) { | 120 TEST_F(ShellHTTPAppTest, Http) { |
121 PingablePtr pingable; | 121 PingablePtr pingable; |
122 application_impl()->ConnectToService(GetURL("app"), &pingable); | 122 application_impl()->ConnectToServiceDeprecated(GetURL("app"), &pingable); |
123 pingable->Ping("hello", | 123 pingable->Ping("hello", |
124 [this](const String& app_url, const String& connection_url, | 124 [this](const String& app_url, const String& connection_url, |
125 const String& message) { | 125 const String& message) { |
126 EXPECT_EQ(GetURL("app"), app_url); | 126 EXPECT_EQ(GetURL("app"), app_url); |
127 EXPECT_EQ(GetURL("app"), connection_url); | 127 EXPECT_EQ(GetURL("app"), connection_url); |
128 EXPECT_EQ("hello", message); | 128 EXPECT_EQ("hello", message); |
129 base::MessageLoop::current()->Quit(); | 129 base::MessageLoop::current()->Quit(); |
130 }); | 130 }); |
131 base::RunLoop().Run(); | 131 base::RunLoop().Run(); |
132 } | 132 } |
133 | 133 |
134 // Test that redirects work. | 134 // Test that redirects work. |
135 // TODO(aa): Test that apps receive the correct URL parameters. | 135 // TODO(aa): Test that apps receive the correct URL parameters. |
136 TEST_F(ShellHTTPAppTest, Redirect) { | 136 TEST_F(ShellHTTPAppTest, Redirect) { |
137 PingablePtr pingable; | 137 PingablePtr pingable; |
138 application_impl()->ConnectToService(GetURL("redirect"), &pingable); | 138 application_impl()->ConnectToServiceDeprecated(GetURL("redirect"), &pingable); |
139 pingable->Ping("hello", | 139 pingable->Ping("hello", |
140 [this](const String& app_url, const String& connection_url, | 140 [this](const String& app_url, const String& connection_url, |
141 const String& message) { | 141 const String& message) { |
142 EXPECT_EQ(GetURL("app"), app_url); | 142 EXPECT_EQ(GetURL("app"), app_url); |
143 EXPECT_EQ(GetURL("app"), connection_url); | 143 EXPECT_EQ(GetURL("app"), connection_url); |
144 EXPECT_EQ("hello", message); | 144 EXPECT_EQ("hello", message); |
145 base::MessageLoop::current()->Quit(); | 145 base::MessageLoop::current()->Quit(); |
146 }); | 146 }); |
147 base::RunLoop().Run(); | 147 base::RunLoop().Run(); |
148 } | 148 } |
149 | 149 |
150 // Test that querystring is not considered when resolving http applications. | 150 // Test that querystring is not considered when resolving http applications. |
151 // TODO(aa|qsr): Fix this test on Linux ASAN http://crbug.com/463662 | 151 // TODO(aa|qsr): Fix this test on Linux ASAN http://crbug.com/463662 |
152 #if defined(ADDRESS_SANITIZER) | 152 #if defined(ADDRESS_SANITIZER) |
153 #define MAYBE_QueryHandling DISABLED_QueryHandling | 153 #define MAYBE_QueryHandling DISABLED_QueryHandling |
154 #else | 154 #else |
155 #define MAYBE_QueryHandling QueryHandling | 155 #define MAYBE_QueryHandling QueryHandling |
156 #endif // ADDRESS_SANITIZER | 156 #endif // ADDRESS_SANITIZER |
157 TEST_F(ShellHTTPAppTest, MAYBE_QueryHandling) { | 157 TEST_F(ShellHTTPAppTest, MAYBE_QueryHandling) { |
158 PingablePtr pingable1; | 158 PingablePtr pingable1; |
159 PingablePtr pingable2; | 159 PingablePtr pingable2; |
160 application_impl()->ConnectToService(GetURL("app?foo"), &pingable1); | 160 application_impl()->ConnectToServiceDeprecated(GetURL("app?foo"), &pingable1); |
161 application_impl()->ConnectToService(GetURL("app?bar"), &pingable2); | 161 application_impl()->ConnectToServiceDeprecated(GetURL("app?bar"), &pingable2); |
162 | 162 |
163 int num_responses = 0; | 163 int num_responses = 0; |
164 auto callbacks_builder = [this, &num_responses](int query_index) { | 164 auto callbacks_builder = [this, &num_responses](int query_index) { |
165 return [this, &num_responses, query_index](const String& app_url, | 165 return [this, &num_responses, query_index](const String& app_url, |
166 const String& connection_url, | 166 const String& connection_url, |
167 const String& message) { | 167 const String& message) { |
168 EXPECT_EQ(GetURL("app"), app_url); | 168 EXPECT_EQ(GetURL("app"), app_url); |
169 EXPECT_EQ("hello", message); | 169 EXPECT_EQ("hello", message); |
170 if (query_index == 1) { | 170 if (query_index == 1) { |
171 EXPECT_EQ(GetURL("app?foo"), connection_url); | 171 EXPECT_EQ(GetURL("app?foo"), connection_url); |
172 } else if (query_index == 2) { | 172 } else if (query_index == 2) { |
173 EXPECT_EQ(GetURL("app?bar"), connection_url); | 173 EXPECT_EQ(GetURL("app?bar"), connection_url); |
174 } else { | 174 } else { |
175 CHECK(false); | 175 CHECK(false); |
176 } | 176 } |
177 ++num_responses; | 177 ++num_responses; |
178 if (num_responses == 2) | 178 if (num_responses == 2) |
179 base::MessageLoop::current()->Quit(); | 179 base::MessageLoop::current()->Quit(); |
180 }; | 180 }; |
181 }; | 181 }; |
182 pingable1->Ping("hello", callbacks_builder(1)); | 182 pingable1->Ping("hello", callbacks_builder(1)); |
183 pingable2->Ping("hello", callbacks_builder(2)); | 183 pingable2->Ping("hello", callbacks_builder(2)); |
184 base::RunLoop().Run(); | 184 base::RunLoop().Run(); |
185 } | 185 } |
186 | 186 |
187 // mojo: URLs can have querystrings too | 187 // mojo: URLs can have querystrings too |
188 TEST_F(ShellAppTest, MojoURLQueryHandling) { | 188 TEST_F(ShellAppTest, MojoURLQueryHandling) { |
189 PingablePtr pingable; | 189 PingablePtr pingable; |
190 application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable); | 190 application_impl()->ConnectToServiceDeprecated("mojo:pingable_app?foo", |
| 191 &pingable); |
191 auto callback = [](const String& app_url, const String& connection_url, | 192 auto callback = [](const String& app_url, const String& connection_url, |
192 const String& message) { | 193 const String& message) { |
193 EXPECT_TRUE(base::EndsWith(app_url.To<base::StringPiece>(), | 194 EXPECT_TRUE(base::EndsWith(app_url.To<base::StringPiece>(), |
194 "/pingable_app.mojo", | 195 "/pingable_app.mojo", |
195 base::CompareCase::SENSITIVE)); | 196 base::CompareCase::SENSITIVE)); |
196 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); | 197 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); |
197 EXPECT_EQ("hello", message); | 198 EXPECT_EQ("hello", message); |
198 base::MessageLoop::current()->Quit(); | 199 base::MessageLoop::current()->Quit(); |
199 }; | 200 }; |
200 pingable->Ping("hello", callback); | 201 pingable->Ping("hello", callback); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 240 } |
240 | 241 |
241 // The first one should still work. | 242 // The first one should still work. |
242 { | 243 { |
243 SCOPED_TRACE("app_connector1 again"); | 244 SCOPED_TRACE("app_connector1 again"); |
244 TestApplicationConnector(app_connector1.get()); | 245 TestApplicationConnector(app_connector1.get()); |
245 } | 246 } |
246 } | 247 } |
247 | 248 |
248 } // namespace | 249 } // namespace |
OLD | NEW |