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

Unified Diff: mojo/application/public/cpp/tests/service_registry_unittest.cc

Issue 1254383016: ApplicationConnection lifetime management changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/application/public/cpp/tests/BUILD.gn ('k') | mojo/common/tracing_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/application/public/cpp/tests/service_registry_unittest.cc
diff --git a/mojo/application/public/cpp/tests/service_registry_unittest.cc b/mojo/application/public/cpp/tests/service_registry_unittest.cc
index 4a9f28a497eaa0a7bd499c334548f3a1c8754de6..98ce637310a8a1c1a7c83450bb610ce7d9a15737 100644
--- a/mojo/application/public/cpp/tests/service_registry_unittest.cc
+++ b/mojo/application/public/cpp/tests/service_registry_unittest.cc
@@ -4,6 +4,7 @@
#include "mojo/application/public/cpp/lib/service_registry.h"
+#include "base/memory/scoped_ptr.h"
#include "mojo/application/public/cpp/service_connector.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -28,43 +29,40 @@ TEST(ServiceRegistryTest, Ownership) {
// Destruction.
{
- ServiceRegistry* registry = new ServiceRegistry;
- registry->SetServiceConnectorForName(new TestConnector(&delete_count),
- "TC1");
- registry->CloseConnection();
+ ServiceRegistry registry;
+ registry.SetServiceConnectorForName(new TestConnector(&delete_count),
+ "TC1");
}
EXPECT_EQ(1, delete_count);
// Removal.
{
- ServiceRegistry* registry = new ServiceRegistry;
+ scoped_ptr<ServiceRegistry> registry(new ServiceRegistry);
ServiceConnector* c = new TestConnector(&delete_count);
registry->SetServiceConnectorForName(c, "TC1");
registry->RemoveServiceConnectorForName("TC1");
- registry->CloseConnection();
+ registry.reset();
EXPECT_EQ(2, delete_count);
}
// Multiple.
{
- ServiceRegistry* registry = new ServiceRegistry;
- registry->SetServiceConnectorForName(new TestConnector(&delete_count),
- "TC1");
- registry->SetServiceConnectorForName(new TestConnector(&delete_count),
- "TC2");
- registry->CloseConnection();
+ ServiceRegistry registry;
+ registry.SetServiceConnectorForName(new TestConnector(&delete_count),
+ "TC1");
+ registry.SetServiceConnectorForName(new TestConnector(&delete_count),
+ "TC2");
}
EXPECT_EQ(4, delete_count);
// Re-addition.
{
- ServiceRegistry* registry = new ServiceRegistry;
- registry->SetServiceConnectorForName(new TestConnector(&delete_count),
- "TC1");
- registry->SetServiceConnectorForName(new TestConnector(&delete_count),
- "TC1");
+ ServiceRegistry registry;
+ registry.SetServiceConnectorForName(new TestConnector(&delete_count),
+ "TC1");
+ registry.SetServiceConnectorForName(new TestConnector(&delete_count),
+ "TC1");
EXPECT_EQ(5, delete_count);
- registry->CloseConnection();
}
EXPECT_EQ(6, delete_count);
}
« no previous file with comments | « mojo/application/public/cpp/tests/BUILD.gn ('k') | mojo/common/tracing_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698