OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 am.ConnectToService(test_url, &test_service); | 520 am.ConnectToService(test_url, &test_service); |
521 TestClient test_client(test_service.Pass()); | 521 TestClient test_client(test_service.Pass()); |
522 test_client.Test("test"); | 522 test_client.Test("test"); |
523 loop_.Run(); | 523 loop_.Run(); |
524 std::vector<std::string> app_args = loader->GetArgs(); | 524 std::vector<std::string> app_args = loader->GetArgs(); |
525 ASSERT_EQ(args.size(), app_args.size()); | 525 ASSERT_EQ(args.size(), app_args.size()); |
526 EXPECT_EQ(args[0], app_args[0]); | 526 EXPECT_EQ(args[0], app_args[0]); |
527 EXPECT_EQ(args[1], app_args[1]); | 527 EXPECT_EQ(args[1], app_args[1]); |
528 } | 528 } |
529 | 529 |
| 530 // Confirm that arguments are aggregated through mappings. |
| 531 TEST_F(ApplicationManagerTest, ArgsAndMapping) { |
| 532 ApplicationManager am(&test_delegate_); |
| 533 GURL test_url("test:test"); |
| 534 GURL test_url2("test:test2"); |
| 535 test_delegate_.AddMapping(test_url, test_url2); |
| 536 std::vector<std::string> args; |
| 537 args.push_back("test_arg1"); |
| 538 args.push_back("test_arg2"); |
| 539 am.SetArgsForURL(args, test_url); |
| 540 std::vector<std::string> args2; |
| 541 args2.push_back("test_arg3"); |
| 542 args2.push_back("test_arg4"); |
| 543 am.SetArgsForURL(args2, test_url2); |
| 544 TestApplicationLoader* loader = new TestApplicationLoader; |
| 545 loader->set_context(&context_); |
| 546 am.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), test_url2); |
| 547 { |
| 548 // Connext to the mapped url |
| 549 TestServicePtr test_service; |
| 550 am.ConnectToService(test_url, &test_service); |
| 551 TestClient test_client(test_service.Pass()); |
| 552 test_client.Test("test"); |
| 553 loop_.Run(); |
| 554 std::vector<std::string> app_args = loader->GetArgs(); |
| 555 ASSERT_EQ(args.size() + args2.size(), app_args.size()); |
| 556 EXPECT_EQ(args[0], app_args[0]); |
| 557 EXPECT_EQ(args[1], app_args[1]); |
| 558 EXPECT_EQ(args2[0], app_args[2]); |
| 559 EXPECT_EQ(args2[1], app_args[3]); |
| 560 } |
| 561 { |
| 562 // Connext to the target url |
| 563 TestServicePtr test_service; |
| 564 am.ConnectToService(test_url2, &test_service); |
| 565 TestClient test_client(test_service.Pass()); |
| 566 test_client.Test("test"); |
| 567 loop_.Run(); |
| 568 std::vector<std::string> app_args = loader->GetArgs(); |
| 569 ASSERT_EQ(args.size() + args2.size(), app_args.size()); |
| 570 EXPECT_EQ(args[0], app_args[0]); |
| 571 EXPECT_EQ(args[1], app_args[1]); |
| 572 EXPECT_EQ(args2[0], app_args[2]); |
| 573 EXPECT_EQ(args2[1], app_args[3]); |
| 574 } |
| 575 } |
| 576 |
530 TEST_F(ApplicationManagerTest, ClientError) { | 577 TEST_F(ApplicationManagerTest, ClientError) { |
531 test_client_->Test("test"); | 578 test_client_->Test("test"); |
532 EXPECT_TRUE(HasFactoryForTestURL()); | 579 EXPECT_TRUE(HasFactoryForTestURL()); |
533 loop_.Run(); | 580 loop_.Run(); |
534 EXPECT_EQ(1, context_.num_impls); | 581 EXPECT_EQ(1, context_.num_impls); |
535 test_client_.reset(NULL); | 582 test_client_.reset(NULL); |
536 loop_.Run(); | 583 loop_.Run(); |
537 EXPECT_EQ(0, context_.num_impls); | 584 EXPECT_EQ(0, context_.num_impls); |
538 EXPECT_TRUE(HasFactoryForTestURL()); | 585 EXPECT_TRUE(HasFactoryForTestURL()); |
539 } | 586 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 // test::test2 should go to scheme loader. | 797 // test::test2 should go to scheme loader. |
751 application_manager_->ConnectToService(GURL("test:test2?foo=bar"), | 798 application_manager_->ConnectToService(GURL("test:test2?foo=bar"), |
752 &test_service); | 799 &test_service); |
753 EXPECT_EQ(1, url_loader->num_loads()); | 800 EXPECT_EQ(1, url_loader->num_loads()); |
754 EXPECT_EQ(1, scheme_loader->num_loads()); | 801 EXPECT_EQ(1, scheme_loader->num_loads()); |
755 } | 802 } |
756 | 803 |
757 } // namespace | 804 } // namespace |
758 } // namespace shell | 805 } // namespace shell |
759 } // namespace mojo | 806 } // namespace mojo |
OLD | NEW |