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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 bool configure_incoming_connection_called_; | 453 bool configure_incoming_connection_called_; |
454 }; | 454 }; |
455 | 455 |
456 class ApplicationManagerTest : public testing::Test { | 456 class ApplicationManagerTest : public testing::Test { |
457 public: | 457 public: |
458 ApplicationManagerTest() : tester_context_(&loop_) {} | 458 ApplicationManagerTest() : tester_context_(&loop_) {} |
459 | 459 |
460 ~ApplicationManagerTest() override {} | 460 ~ApplicationManagerTest() override {} |
461 | 461 |
462 void SetUp() override { | 462 void SetUp() override { |
463 application_manager_.reset(new ApplicationManager(&test_delegate_)); | 463 application_manager_.reset( |
| 464 new ApplicationManager(ApplicationManager::Options(), &test_delegate_)); |
464 test_loader_ = new TestApplicationLoader; | 465 test_loader_ = new TestApplicationLoader; |
465 test_loader_->set_context(&context_); | 466 test_loader_->set_context(&context_); |
466 application_manager_->set_default_loader( | 467 application_manager_->set_default_loader( |
467 scoped_ptr<ApplicationLoader>(test_loader_)); | 468 scoped_ptr<ApplicationLoader>(test_loader_)); |
468 | 469 |
469 TestServicePtr service_proxy; | 470 TestServicePtr service_proxy; |
470 application_manager_->ConnectToService(GURL(kTestURLString), | 471 application_manager_->ConnectToService(GURL(kTestURLString), |
471 &service_proxy); | 472 &service_proxy); |
472 test_client_.reset(new TestClient(service_proxy.Pass())); | 473 test_client_.reset(new TestClient(service_proxy.Pass())); |
473 } | 474 } |
(...skipping 26 matching lines...) Expand all Loading... |
500 }; | 501 }; |
501 | 502 |
502 TEST_F(ApplicationManagerTest, Basic) { | 503 TEST_F(ApplicationManagerTest, Basic) { |
503 test_client_->Test("test"); | 504 test_client_->Test("test"); |
504 loop_.Run(); | 505 loop_.Run(); |
505 EXPECT_EQ(std::string("test"), context_.last_test_string); | 506 EXPECT_EQ(std::string("test"), context_.last_test_string); |
506 } | 507 } |
507 | 508 |
508 // Confirm that no arguments are sent to an application by default. | 509 // Confirm that no arguments are sent to an application by default. |
509 TEST_F(ApplicationManagerTest, NoArgs) { | 510 TEST_F(ApplicationManagerTest, NoArgs) { |
510 ApplicationManager am(&test_delegate_); | 511 ApplicationManager am(ApplicationManager::Options(), &test_delegate_); |
511 GURL test_url("test:test"); | 512 GURL test_url("test:test"); |
512 TestApplicationLoader* loader = new TestApplicationLoader; | 513 TestApplicationLoader* loader = new TestApplicationLoader; |
513 loader->set_context(&context_); | 514 loader->set_context(&context_); |
514 am.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), test_url); | 515 am.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), test_url); |
515 TestServicePtr test_service; | 516 TestServicePtr test_service; |
516 am.ConnectToService(test_url, &test_service); | 517 am.ConnectToService(test_url, &test_service); |
517 TestClient test_client(test_service.Pass()); | 518 TestClient test_client(test_service.Pass()); |
518 test_client.Test("test"); | 519 test_client.Test("test"); |
519 loop_.Run(); | 520 loop_.Run(); |
520 std::vector<std::string> app_args = loader->GetArgs(); | 521 std::vector<std::string> app_args = loader->GetArgs(); |
521 EXPECT_EQ(0U, app_args.size()); | 522 EXPECT_EQ(0U, app_args.size()); |
522 } | 523 } |
523 | 524 |
524 // Confirm that arguments are sent to an application. | 525 // Confirm that arguments are sent to an application. |
525 TEST_F(ApplicationManagerTest, Args) { | 526 TEST_F(ApplicationManagerTest, Args) { |
526 ApplicationManager am(&test_delegate_); | 527 ApplicationManager am(ApplicationManager::Options(), &test_delegate_); |
527 GURL test_url("test:test"); | 528 GURL test_url("test:test"); |
528 std::vector<std::string> args; | 529 std::vector<std::string> args; |
529 args.push_back("test_arg1"); | 530 args.push_back("test_arg1"); |
530 args.push_back("test_arg2"); | 531 args.push_back("test_arg2"); |
531 am.SetArgsForURL(args, test_url); | 532 am.SetArgsForURL(args, test_url); |
532 TestApplicationLoader* loader = new TestApplicationLoader; | 533 TestApplicationLoader* loader = new TestApplicationLoader; |
533 loader->set_context(&context_); | 534 loader->set_context(&context_); |
534 am.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), test_url); | 535 am.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), test_url); |
535 TestServicePtr test_service; | 536 TestServicePtr test_service; |
536 am.ConnectToService(test_url, &test_service); | 537 am.ConnectToService(test_url, &test_service); |
537 TestClient test_client(test_service.Pass()); | 538 TestClient test_client(test_service.Pass()); |
538 test_client.Test("test"); | 539 test_client.Test("test"); |
539 loop_.Run(); | 540 loop_.Run(); |
540 std::vector<std::string> app_args = loader->GetArgs(); | 541 std::vector<std::string> app_args = loader->GetArgs(); |
541 ASSERT_EQ(args.size(), app_args.size()); | 542 ASSERT_EQ(args.size(), app_args.size()); |
542 EXPECT_EQ(args[0], app_args[0]); | 543 EXPECT_EQ(args[0], app_args[0]); |
543 EXPECT_EQ(args[1], app_args[1]); | 544 EXPECT_EQ(args[1], app_args[1]); |
544 } | 545 } |
545 | 546 |
546 // Confirm that arguments are aggregated through mappings. | 547 // Confirm that arguments are aggregated through mappings. |
547 TEST_F(ApplicationManagerTest, ArgsAndMapping) { | 548 TEST_F(ApplicationManagerTest, ArgsAndMapping) { |
548 ApplicationManager am(&test_delegate_); | 549 ApplicationManager am(ApplicationManager::Options(), &test_delegate_); |
549 GURL test_url("test:test"); | 550 GURL test_url("test:test"); |
550 GURL test_url2("test:test2"); | 551 GURL test_url2("test:test2"); |
551 test_delegate_.AddMapping(test_url, test_url2); | 552 test_delegate_.AddMapping(test_url, test_url2); |
552 std::vector<std::string> args; | 553 std::vector<std::string> args; |
553 args.push_back("test_arg1"); | 554 args.push_back("test_arg1"); |
554 args.push_back("test_arg2"); | 555 args.push_back("test_arg2"); |
555 am.SetArgsForURL(args, test_url); | 556 am.SetArgsForURL(args, test_url); |
556 std::vector<std::string> args2; | 557 std::vector<std::string> args2; |
557 args2.push_back("test_arg3"); | 558 args2.push_back("test_arg3"); |
558 args2.push_back("test_arg4"); | 559 args2.push_back("test_arg4"); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 loop_.Run(); | 597 loop_.Run(); |
597 EXPECT_EQ(1, context_.num_impls); | 598 EXPECT_EQ(1, context_.num_impls); |
598 test_client_.reset(); | 599 test_client_.reset(); |
599 loop_.Run(); | 600 loop_.Run(); |
600 EXPECT_EQ(0, context_.num_impls); | 601 EXPECT_EQ(0, context_.num_impls); |
601 EXPECT_TRUE(HasFactoryForTestURL()); | 602 EXPECT_TRUE(HasFactoryForTestURL()); |
602 } | 603 } |
603 | 604 |
604 TEST_F(ApplicationManagerTest, Deletes) { | 605 TEST_F(ApplicationManagerTest, Deletes) { |
605 { | 606 { |
606 ApplicationManager am(&test_delegate_); | 607 ApplicationManager am(ApplicationManager::Options(), &test_delegate_); |
607 TestApplicationLoader* default_loader = new TestApplicationLoader; | 608 TestApplicationLoader* default_loader = new TestApplicationLoader; |
608 default_loader->set_context(&context_); | 609 default_loader->set_context(&context_); |
609 TestApplicationLoader* url_loader1 = new TestApplicationLoader; | 610 TestApplicationLoader* url_loader1 = new TestApplicationLoader; |
610 TestApplicationLoader* url_loader2 = new TestApplicationLoader; | 611 TestApplicationLoader* url_loader2 = new TestApplicationLoader; |
611 url_loader1->set_context(&context_); | 612 url_loader1->set_context(&context_); |
612 url_loader2->set_context(&context_); | 613 url_loader2->set_context(&context_); |
613 TestApplicationLoader* scheme_loader1 = new TestApplicationLoader; | 614 TestApplicationLoader* scheme_loader1 = new TestApplicationLoader; |
614 TestApplicationLoader* scheme_loader2 = new TestApplicationLoader; | 615 TestApplicationLoader* scheme_loader2 = new TestApplicationLoader; |
615 scheme_loader1->set_context(&context_); | 616 scheme_loader1->set_context(&context_); |
616 scheme_loader2->set_context(&context_); | 617 scheme_loader2->set_context(&context_); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 bool called = false; | 810 bool called = false; |
810 application_manager_->ConnectToApplication( | 811 application_manager_->ConnectToApplication( |
811 GURL("test:test"), GURL(), nullptr, nullptr, | 812 GURL("test:test"), GURL(), nullptr, nullptr, |
812 base::Bind(&QuitClosure, base::Unretained(&called))); | 813 base::Bind(&QuitClosure, base::Unretained(&called))); |
813 loop_.Run(); | 814 loop_.Run(); |
814 EXPECT_TRUE(called); | 815 EXPECT_TRUE(called); |
815 } | 816 } |
816 | 817 |
817 } // namespace | 818 } // namespace |
818 } // namespace shell | 819 } // namespace shell |
OLD | NEW |