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 sent to an application in the presence of query |
| 531 // parameters. |
| 532 TEST_F(ApplicationManagerTest, ArgsWithQuery) { |
| 533 ApplicationManager am(ApplicationManager::Options(), &test_delegate_); |
| 534 GURL test_url("test:test"); |
| 535 GURL test_url_with_query("test:test?foo=bar"); |
| 536 std::vector<std::string> args; |
| 537 args.push_back("test_arg1"); |
| 538 am.SetArgsForURL(args, test_url); |
| 539 TestApplicationLoader* loader = new TestApplicationLoader; |
| 540 loader->set_context(&context_); |
| 541 am.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), test_url); |
| 542 TestServicePtr test_service; |
| 543 am.ConnectToService(test_url_with_query, &test_service); |
| 544 TestClient test_client(test_service.Pass()); |
| 545 test_client.Test("test"); |
| 546 loop_.Run(); |
| 547 std::vector<std::string> app_args = loader->GetArgs(); |
| 548 ASSERT_EQ(args.size(), app_args.size()); |
| 549 EXPECT_EQ(args[0], app_args[0]); |
| 550 } |
| 551 |
530 // Confirm that arguments are aggregated through mappings. | 552 // Confirm that arguments are aggregated through mappings. |
531 TEST_F(ApplicationManagerTest, ArgsAndMapping) { | 553 TEST_F(ApplicationManagerTest, ArgsAndMapping) { |
532 ApplicationManager am(ApplicationManager::Options(), &test_delegate_); | 554 ApplicationManager am(ApplicationManager::Options(), &test_delegate_); |
533 GURL test_url("test:test"); | 555 GURL test_url("test:test"); |
534 GURL test_url2("test:test2"); | 556 GURL test_url2("test:test2"); |
535 test_delegate_.AddMapping(test_url, test_url2); | 557 test_delegate_.AddMapping(test_url, test_url2); |
536 std::vector<std::string> args; | 558 std::vector<std::string> args; |
537 args.push_back("test_arg1"); | 559 args.push_back("test_arg1"); |
538 args.push_back("test_arg2"); | 560 args.push_back("test_arg2"); |
539 am.SetArgsForURL(args, test_url); | 561 am.SetArgsForURL(args, test_url); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 bool called = false; | 815 bool called = false; |
794 application_manager_->ConnectToApplication( | 816 application_manager_->ConnectToApplication( |
795 GURL("test:test"), GURL(), nullptr, nullptr, | 817 GURL("test:test"), GURL(), nullptr, nullptr, |
796 base::Bind(&QuitClosure, base::Unretained(&called))); | 818 base::Bind(&QuitClosure, base::Unretained(&called))); |
797 loop_.Run(); | 819 loop_.Run(); |
798 EXPECT_TRUE(called); | 820 EXPECT_TRUE(called); |
799 } | 821 } |
800 | 822 |
801 } // namespace | 823 } // namespace |
802 } // namespace shell | 824 } // namespace shell |
OLD | NEW |