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

Unified Diff: mojo/shell/tests/lifecycle/lifecycle_unittest.cc

Issue 1810713002: Cascade shutdown of instances (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@55all_users
Patch Set: . Created 4 years, 9 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/shell/tests/lifecycle/app_client.cc ('k') | mojo/shell/tests/lifecycle/lifecycle_unittest.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/tests/lifecycle/lifecycle_unittest.cc
diff --git a/mojo/shell/tests/lifecycle/lifecycle_unittest.cc b/mojo/shell/tests/lifecycle/lifecycle_unittest.cc
index fd34f11b17b6dffe02523d93be1f90113cd263a4..27e068f5635c59b45e4e4f92288f4b543308fbb4 100644
--- a/mojo/shell/tests/lifecycle/lifecycle_unittest.cc
+++ b/mojo/shell/tests/lifecycle/lifecycle_unittest.cc
@@ -18,6 +18,7 @@ namespace shell {
namespace {
const char kTestAppName[] = "mojo:lifecycle_unittest_app";
+const char kTestParentName[] = "mojo:lifecycle_unittest_parent";
const char kTestExeName[] = "exe:lifecycle_unittest_exe";
const char kTestPackageName[] = "mojo:lifecycle_unittest_package";
const char kTestPackageAppNameA[] = "mojo:lifecycle_unittest_package_app_a";
@@ -438,6 +439,34 @@ TEST_F(LifecycleTest, Exe_TerminateProcess) {
EXPECT_EQ(0u, instances()->GetNewInstanceCount());
}
+TEST_F(LifecycleTest, ShutdownTree) {
+ // Verifies that Instances are destroyed when their creator is.
+ scoped_ptr<Connection> parent_connection =
+ connector()->Connect(kTestParentName);
+ test::mojom::ParentPtr parent;
+ parent_connection->GetInterface(&parent);
+
+ // This asks kTestParentName to open a connection to kTestAppName and blocks
+ // on a response from a Ping().
+ {
+ base::RunLoop loop;
+ parent->ConnectToChild(base::Bind(&QuitLoop, &loop));
+ loop.Run();
+ }
+
+ // Should now have two new instances (parent and child).
+ EXPECT_EQ(2u, instances()->GetNewInstanceCount());
+ EXPECT_TRUE(instances()->HasInstanceForName(kTestParentName));
+ EXPECT_TRUE(instances()->HasInstanceForName(kTestAppName));
+
+ parent->Quit();
+
+ // Quitting the parent should cascade-quit the child.
+ WaitForInstanceDestruction();
+ EXPECT_EQ(0u, instances()->GetNewInstanceCount());
+ EXPECT_FALSE(instances()->HasInstanceForName(kTestParentName));
+ EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName));
+}
} // namespace shell
} // namespace mojo
« no previous file with comments | « mojo/shell/tests/lifecycle/app_client.cc ('k') | mojo/shell/tests/lifecycle/lifecycle_unittest.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698