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

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
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..0ab74b0658b77a3e96e23fb2fe2efde7ed003ebe 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;
+ scoped_ptr<ServiceRegistry> registry(new ServiceRegistry);
sky 2015/08/11 18:28:04 nit: declare on stack here and remaining places (e
registry->SetServiceConnectorForName(new TestConnector(&delete_count),
"TC1");
- registry->CloseConnection();
}
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;
+ scoped_ptr<ServiceRegistry> registry(new ServiceRegistry);
registry->SetServiceConnectorForName(new TestConnector(&delete_count),
"TC1");
registry->SetServiceConnectorForName(new TestConnector(&delete_count),
"TC2");
- registry->CloseConnection();
}
EXPECT_EQ(4, delete_count);
// Re-addition.
{
- ServiceRegistry* registry = new ServiceRegistry;
+ scoped_ptr<ServiceRegistry> registry(new ServiceRegistry);
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);
}

Powered by Google App Engine
This is Rietveld 408576698