Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: trunk/src/mojo/service_manager/service_manager_unittest.cc

Issue 443063003: Revert 287680 "mojo: terminate apps if the shell goes away" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "mojo/public/cpp/application/application_connection.h" 8 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 service_manager_->ConnectToService(GURL(kTestAURLString), &a); 611 service_manager_->ConnectToService(GURL(kTestAURLString), &a);
612 a->CallB(); 612 a->CallB();
613 loop_.Run(); 613 loop_.Run();
614 EXPECT_EQ(0, tester_context_.num_b_calls()); 614 EXPECT_EQ(0, tester_context_.num_b_calls());
615 615
616 EXPECT_FALSE(tester_context_.a_called_quit()); 616 EXPECT_FALSE(tester_context_.a_called_quit());
617 EXPECT_TRUE(tester_context_.tester_called_quit()); 617 EXPECT_TRUE(tester_context_.tester_called_quit());
618 } 618 }
619 619
620 TEST_F(ServiceManagerTest, NoServiceNoLoad) { 620 TEST_F(ServiceManagerTest, NoServiceNoLoad) {
621 AddLoaderForURL(GURL(kTestAURLString), std::string()); 621 // Because we'll never successfully connect to anything here and apps are not
622 // capable of noticing zero incoming connections and quitting, we need to use
623 // a quittable loader.
624 scoped_ptr<BackgroundShellServiceLoader> loader(MakeLoader(std::string()));
625 loader->set_quit_on_shutdown();
626 service_manager_->SetLoaderForURL(loader.PassAs<ServiceLoader>(),
627 GURL(kTestAURLString));
628
622 629
623 // There is no TestC service implementation registered with ServiceManager, 630 // There is no TestC service implementation registered with ServiceManager,
624 // so this cannot succeed (but also shouldn't crash). 631 // so this cannot succeed (but also shouldn't crash).
625 TestCPtr c; 632 TestCPtr c;
626 service_manager_->ConnectToService(GURL(kTestAURLString), &c); 633 service_manager_->ConnectToService(GURL(kTestAURLString), &c);
627 QuitMessageLoopErrorHandler quitter; 634 QuitMessageLoopErrorHandler quitter;
628 c.set_error_handler(&quitter); 635 c.set_error_handler(&quitter);
629 636
630 loop_.Run(); 637 loop_.Run();
631 EXPECT_TRUE(c.encountered_error()); 638 EXPECT_TRUE(c.encountered_error());
632 } 639 }
633 640
634 TEST_F(ServiceManagerTest, Interceptor) { 641 TEST_F(ServiceManagerTest, Interceptor) {
635 TestServiceInterceptor interceptor; 642 TestServiceInterceptor interceptor;
636 TestServiceLoader* default_loader = new TestServiceLoader; 643 TestServiceLoader* default_loader = new TestServiceLoader;
637 service_manager_->set_default_loader( 644 service_manager_->set_default_loader(
638 scoped_ptr<ServiceLoader>(default_loader)); 645 scoped_ptr<ServiceLoader>(default_loader));
639 service_manager_->SetInterceptor(&interceptor); 646 service_manager_->SetInterceptor(&interceptor);
640 647
641 std::string url("test:test3"); 648 std::string url("test:test3");
642 TestServicePtr test_service; 649 TestServicePtr test_service;
643 service_manager_->ConnectToService(GURL(url), &test_service); 650 service_manager_->ConnectToService(GURL(url), &test_service);
644 651
645 EXPECT_EQ(1, interceptor.call_count()); 652 EXPECT_EQ(1, interceptor.call_count());
646 EXPECT_EQ(url, interceptor.url_spec()); 653 EXPECT_EQ(url, interceptor.url_spec());
647 EXPECT_EQ(1, default_loader->num_loads()); 654 EXPECT_EQ(1, default_loader->num_loads());
648 } 655 }
649 656
650 } // namespace mojo 657 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698