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

Unified Diff: mojo/service_manager/service_manager_unittest.cc

Issue 343473005: mojo: fail gracefully if ServiceRegistry can't find ServiceConnector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweak test Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/application/lib/service_registry.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/service_manager/service_manager_unittest.cc
diff --git a/mojo/service_manager/service_manager_unittest.cc b/mojo/service_manager/service_manager_unittest.cc
index 2e86769a144759d34338b20b138408029c58666c..a2122017c27b44e39c5b7c1df234f32f9059817e 100644
--- a/mojo/service_manager/service_manager_unittest.cc
+++ b/mojo/service_manager/service_manager_unittest.cc
@@ -25,6 +25,20 @@ struct TestContext {
int num_loader_deletes;
};
+class QuitMessageLoopErrorHandler : public ErrorHandler {
+ public:
+ QuitMessageLoopErrorHandler() {}
+ virtual ~QuitMessageLoopErrorHandler() {}
+
+ // |ErrorHandler| implementation:
+ virtual void OnConnectionError() OVERRIDE {
+ base::MessageLoop::current()->QuitWhenIdle();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(QuitMessageLoopErrorHandler);
+};
+
class TestServiceImpl : public InterfaceImpl<TestService> {
public:
explicit TestServiceImpl(TestContext* context) : context_(context) {
@@ -114,7 +128,7 @@ class TestServiceLoader : public ServiceLoader {
// Used to test that the requestor url will be correctly passed.
class TestAImpl : public InterfaceImpl<TestA> {
public:
- TestAImpl(Application* app) : app_(app) {}
+ explicit TestAImpl(Application* app) : app_(app) {}
virtual void LoadB() OVERRIDE {
TestBPtr b;
@@ -135,7 +149,7 @@ class TestBImpl : public InterfaceImpl<TestB> {
class TestApp : public Application, public ServiceLoader {
public:
- TestApp(std::string requestor_url)
+ explicit TestApp(std::string requestor_url)
: requestor_url_(requestor_url),
num_connects_(0) {
}
@@ -354,6 +368,26 @@ TEST_F(ServiceManagerTest, ANoLoadB) {
EXPECT_EQ(0, b_app->num_connects());
}
+TEST_F(ServiceManagerTest, NoServiceNoLoad) {
+ ServiceManager sm;
+
+ TestApp* b_app = new TestApp(std::string());
+ b_app->AddService<TestBImpl>();
+ sm.SetLoaderForURL(scoped_ptr<ServiceLoader>(b_app), GURL(kTestBURLString));
+
+ // There is no TestA service implementation registered with ServiceManager,
+ // so this cannot succeed (but also shouldn't crash).
+ TestAPtr a;
+ sm.ConnectTo(GURL(kTestBURLString), &a, GURL());
+ QuitMessageLoopErrorHandler quitter;
+ a.set_error_handler(&quitter);
+ a->LoadB();
+
+ loop_.Run();
+ EXPECT_TRUE(a.encountered_error());
+ EXPECT_EQ(0, b_app->num_connects());
+}
+
TEST_F(ServiceManagerTest, Interceptor) {
ServiceManager sm;
TestServiceInterceptor interceptor;
« no previous file with comments | « mojo/public/cpp/application/lib/service_registry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698