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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 scoped_ptr<ApplicationLoader>(content_handler_loader), | 218 scoped_ptr<ApplicationLoader>(content_handler_loader), |
219 content_handler_url_); | 219 content_handler_url_); |
220 | 220 |
221 uint32_t content_handler_id; | 221 uint32_t content_handler_id; |
222 { | 222 { |
223 base::RunLoop run_loop; | 223 base::RunLoop run_loop; |
224 scoped_ptr<ConnectToApplicationParams> params( | 224 scoped_ptr<ConnectToApplicationParams> params( |
225 new ConnectToApplicationParams); | 225 new ConnectToApplicationParams); |
226 params->set_source(Identity(requestor_url_)); | 226 params->set_source(Identity(requestor_url_)); |
227 params->SetTargetURL(GURL("test:test")); | 227 params->SetTargetURL(GURL("test:test")); |
228 params->set_connect_callback([&content_handler_id, &run_loop](uint32_t t) { | 228 params->set_connect_callback( |
| 229 [&content_handler_id, &run_loop](uint32_t, uint32_t t) { |
229 content_handler_id = t; | 230 content_handler_id = t; |
230 run_loop.Quit(); | 231 run_loop.Quit(); |
231 }); | 232 }); |
232 application_manager_->ConnectToApplication(std::move(params)); | 233 application_manager_->ConnectToApplication(std::move(params)); |
233 run_loop.Run(); | 234 run_loop.Run(); |
234 EXPECT_NE(Shell::kInvalidContentHandlerID, content_handler_id); | 235 EXPECT_NE(Shell::kInvalidApplicationID, content_handler_id); |
235 } | 236 } |
236 | 237 |
237 uint32_t content_handler_id2; | 238 uint32_t content_handler_id2; |
238 { | 239 { |
239 base::RunLoop run_loop; | 240 base::RunLoop run_loop; |
240 scoped_ptr<ConnectToApplicationParams> params( | 241 scoped_ptr<ConnectToApplicationParams> params( |
241 new ConnectToApplicationParams); | 242 new ConnectToApplicationParams); |
242 params->set_source(Identity(requestor_url_)); | 243 params->set_source(Identity(requestor_url_)); |
243 params->SetTargetURL(GURL("test:test")); | 244 params->SetTargetURL(GURL("test:test")); |
244 params->set_connect_callback([&content_handler_id2, &run_loop](uint32_t t) { | 245 params->set_connect_callback( |
| 246 [&content_handler_id2, &run_loop](uint32_t, uint32_t t) { |
245 content_handler_id2 = t; | 247 content_handler_id2 = t; |
246 run_loop.Quit(); | 248 run_loop.Quit(); |
247 }); | 249 }); |
248 application_manager_->ConnectToApplication(std::move(params)); | 250 application_manager_->ConnectToApplication(std::move(params)); |
249 run_loop.Run(); | 251 run_loop.Run(); |
250 EXPECT_NE(Shell::kInvalidContentHandlerID, content_handler_id2); | 252 EXPECT_NE(Shell::kInvalidApplicationID, content_handler_id2); |
251 } | 253 } |
252 EXPECT_EQ(content_handler_id, content_handler_id2); | 254 EXPECT_EQ(content_handler_id, content_handler_id2); |
253 } | 255 } |
254 | 256 |
255 TEST_F(ContentHandlerTest, DifferedContentHandlersGetDifferentIDs) { | 257 TEST_F(ContentHandlerTest, DifferedContentHandlersGetDifferentIDs) { |
256 TestApplicationLoader* content_handler_loader = new TestApplicationLoader; | 258 TestApplicationLoader* content_handler_loader = new TestApplicationLoader; |
257 application_manager_->SetLoaderForURL( | 259 application_manager_->SetLoaderForURL( |
258 scoped_ptr<ApplicationLoader>(content_handler_loader), | 260 scoped_ptr<ApplicationLoader>(content_handler_loader), |
259 content_handler_url_); | 261 content_handler_url_); |
260 | 262 |
261 uint32_t content_handler_id; | 263 uint32_t content_handler_id; |
262 { | 264 { |
263 base::RunLoop run_loop; | 265 base::RunLoop run_loop; |
264 scoped_ptr<ConnectToApplicationParams> params( | 266 scoped_ptr<ConnectToApplicationParams> params( |
265 new ConnectToApplicationParams); | 267 new ConnectToApplicationParams); |
266 params->set_source(Identity(requestor_url_)); | 268 params->set_source(Identity(requestor_url_)); |
267 params->SetTargetURL(GURL("test:test")); | 269 params->SetTargetURL(GURL("test:test")); |
268 params->set_connect_callback([&content_handler_id, &run_loop](uint32_t t) { | 270 params->set_connect_callback( |
| 271 [&content_handler_id, &run_loop](uint32_t, uint32_t t) { |
269 content_handler_id = t; | 272 content_handler_id = t; |
270 run_loop.Quit(); | 273 run_loop.Quit(); |
271 }); | 274 }); |
272 application_manager_->ConnectToApplication(std::move(params)); | 275 application_manager_->ConnectToApplication(std::move(params)); |
273 run_loop.Run(); | 276 run_loop.Run(); |
274 EXPECT_NE(Shell::kInvalidContentHandlerID, content_handler_id); | 277 EXPECT_NE(Shell::kInvalidApplicationID, content_handler_id); |
275 } | 278 } |
276 | 279 |
277 const std::string mime_type2 = "test/mime-type2"; | 280 const std::string mime_type2 = "test/mime-type2"; |
278 const GURL content_handler_url2("http://test.content.handler2"); | 281 const GURL content_handler_url2("http://test.content.handler2"); |
279 test_package_manager_->set_mime_type(mime_type2); | 282 test_package_manager_->set_mime_type(mime_type2); |
280 test_package_manager_->RegisterContentHandler(mime_type2, | 283 test_package_manager_->RegisterContentHandler(mime_type2, |
281 content_handler_url2); | 284 content_handler_url2); |
282 | 285 |
283 TestApplicationLoader* content_handler_loader2 = new TestApplicationLoader; | 286 TestApplicationLoader* content_handler_loader2 = new TestApplicationLoader; |
284 application_manager_->SetLoaderForURL( | 287 application_manager_->SetLoaderForURL( |
285 scoped_ptr<ApplicationLoader>(content_handler_loader2), | 288 scoped_ptr<ApplicationLoader>(content_handler_loader2), |
286 content_handler_url2); | 289 content_handler_url2); |
287 | 290 |
288 uint32_t content_handler_id2; | 291 uint32_t content_handler_id2; |
289 { | 292 { |
290 base::RunLoop run_loop; | 293 base::RunLoop run_loop; |
291 scoped_ptr<ConnectToApplicationParams> params( | 294 scoped_ptr<ConnectToApplicationParams> params( |
292 new ConnectToApplicationParams); | 295 new ConnectToApplicationParams); |
293 params->set_source(Identity(requestor_url_)); | 296 params->set_source(Identity(requestor_url_)); |
294 params->SetTargetURL(GURL("test2:test2")); | 297 params->SetTargetURL(GURL("test2:test2")); |
295 params->set_connect_callback([&content_handler_id2, &run_loop](uint32_t t) { | 298 params->set_connect_callback( |
| 299 [&content_handler_id2, &run_loop](uint32_t, uint32_t t) { |
296 content_handler_id2 = t; | 300 content_handler_id2 = t; |
297 run_loop.Quit(); | 301 run_loop.Quit(); |
298 }); | 302 }); |
299 application_manager_->ConnectToApplication(std::move(params)); | 303 application_manager_->ConnectToApplication(std::move(params)); |
300 run_loop.Run(); | 304 run_loop.Run(); |
301 EXPECT_NE(Shell::kInvalidContentHandlerID, content_handler_id2); | 305 EXPECT_NE(Shell::kInvalidApplicationID, content_handler_id2); |
302 } | 306 } |
303 EXPECT_NE(content_handler_id, content_handler_id2); | 307 EXPECT_NE(content_handler_id, content_handler_id2); |
304 } | 308 } |
305 | 309 |
306 TEST_F(ContentHandlerTest, | 310 TEST_F(ContentHandlerTest, |
307 ConnectWithNoContentHandlerGetsInvalidContentHandlerId) { | 311 ConnectWithNoContentHandlerGetsInvalidContentHandlerId) { |
308 application_manager_->SetLoaderForURL( | 312 application_manager_->SetLoaderForURL( |
309 scoped_ptr<ApplicationLoader>(new TestApplicationLoader), | 313 scoped_ptr<ApplicationLoader>(new TestApplicationLoader), |
310 GURL("test:test")); | 314 GURL("test:test")); |
311 | 315 |
312 uint32_t content_handler_id = 1u; | 316 uint32_t content_handler_id = 1u; |
313 scoped_ptr<ConnectToApplicationParams> params( | 317 scoped_ptr<ConnectToApplicationParams> params( |
314 new ConnectToApplicationParams); | 318 new ConnectToApplicationParams); |
315 params->SetTargetURL(GURL("test:test")); | 319 params->SetTargetURL(GURL("test:test")); |
316 params->set_connect_callback( | 320 params->set_connect_callback( |
317 [&content_handler_id](uint32_t t) { content_handler_id = t; }); | 321 [&content_handler_id](uint32_t, uint32_t t) { content_handler_id = t; }); |
318 application_manager_->ConnectToApplication(std::move(params)); | 322 application_manager_->ConnectToApplication(std::move(params)); |
319 EXPECT_EQ(0u, content_handler_id); | 323 EXPECT_EQ(0u, content_handler_id); |
320 } | 324 } |
321 | 325 |
322 } // namespace test | 326 } // namespace test |
323 } // namespace package_manager | 327 } // namespace package_manager |
324 } // namespace mojo | 328 } // namespace mojo |
OLD | NEW |