| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/process/process.h" | 11 #include "base/process/process.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "services/shell/public/cpp/identity.h" | 13 #include "services/shell/public/cpp/identity.h" |
| 14 #include "services/shell/public/cpp/shell_test.h" | 14 #include "services/shell/public/cpp/service_test.h" |
| 15 #include "services/shell/public/interfaces/service_manager.mojom.h" | 15 #include "services/shell/public/interfaces/service_manager.mojom.h" |
| 16 #include "services/shell/tests/lifecycle/lifecycle_unittest.mojom.h" | 16 #include "services/shell/tests/lifecycle/lifecycle_unittest.mojom.h" |
| 17 #include "services/shell/tests/util.h" | 17 #include "services/shell/tests/util.h" |
| 18 | 18 |
| 19 namespace shell { | 19 namespace shell { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const char kTestAppName[] = "mojo:lifecycle_unittest_app"; | 23 const char kTestAppName[] = "mojo:lifecycle_unittest_app"; |
| 24 const char kTestParentName[] = "mojo:lifecycle_unittest_parent"; | 24 const char kTestParentName[] = "mojo:lifecycle_unittest_parent"; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 // Set when the client wants to wait for this object to track the destruction | 120 // Set when the client wants to wait for this object to track the destruction |
| 121 // of an instance before proceeding. | 121 // of an instance before proceeding. |
| 122 base::RunLoop* destruction_loop_ = nullptr; | 122 base::RunLoop* destruction_loop_ = nullptr; |
| 123 | 123 |
| 124 DISALLOW_COPY_AND_ASSIGN(InstanceState); | 124 DISALLOW_COPY_AND_ASSIGN(InstanceState); |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace | 127 } // namespace |
| 128 | 128 |
| 129 class LifecycleTest : public test::ShellTest { | 129 class LifecycleTest : public test::ServiceTest { |
| 130 public: | 130 public: |
| 131 LifecycleTest() : ShellTest(kTestName) {} | 131 LifecycleTest() : ServiceTest(kTestName) {} |
| 132 ~LifecycleTest() override {} | 132 ~LifecycleTest() override {} |
| 133 | 133 |
| 134 protected: | 134 protected: |
| 135 // test::ShellTest: | 135 // test::ServiceTest: |
| 136 void SetUp() override { | 136 void SetUp() override { |
| 137 test::ShellTest::SetUp(); | 137 test::ServiceTest::SetUp(); |
| 138 InitPackage(); | 138 InitPackage(); |
| 139 instances_ = TrackInstances(); | 139 instances_ = TrackInstances(); |
| 140 } | 140 } |
| 141 void TearDown() override { | 141 void TearDown() override { |
| 142 instances_.reset(); | 142 instances_.reset(); |
| 143 test::ShellTest::TearDown(); | 143 test::ServiceTest::TearDown(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 bool CanRunCrashTest() { | 146 bool CanRunCrashTest() { |
| 147 return !base::CommandLine::ForCurrentProcess()->HasSwitch("single-process"); | 147 return !base::CommandLine::ForCurrentProcess()->HasSwitch("single-process"); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void InitPackage() { | 150 void InitPackage() { |
| 151 test::mojom::LifecycleControlPtr lifecycle = ConnectTo(kTestPackageName); | 151 test::mojom::LifecycleControlPtr lifecycle = ConnectTo(kTestPackageName); |
| 152 base::RunLoop loop; | 152 base::RunLoop loop; |
| 153 lifecycle.set_connection_error_handler(base::Bind(&QuitLoop, &loop)); | 153 lifecycle.set_connection_error_handler(base::Bind(&QuitLoop, &loop)); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 parent->Quit(); | 445 parent->Quit(); |
| 446 | 446 |
| 447 // Quitting the parent should cascade-quit the child. | 447 // Quitting the parent should cascade-quit the child. |
| 448 WaitForInstanceDestruction(); | 448 WaitForInstanceDestruction(); |
| 449 EXPECT_EQ(0u, instances()->GetNewInstanceCount()); | 449 EXPECT_EQ(0u, instances()->GetNewInstanceCount()); |
| 450 EXPECT_FALSE(instances()->HasInstanceForName(kTestParentName)); | 450 EXPECT_FALSE(instances()->HasInstanceForName(kTestParentName)); |
| 451 EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName)); | 451 EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName)); |
| 452 } | 452 } |
| 453 | 453 |
| 454 } // namespace shell | 454 } // namespace shell |
| OLD | NEW |