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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "mojo/public/cpp/bindings/binding_set.h" | 6 #include "mojo/public/cpp/bindings/binding_set.h" |
7 #include "services/service_manager/public/cpp/service_test.h" | 7 #include "services/service_manager/public/cpp/service_test.h" |
8 #include "services/service_manager/tests/shutdown/shutdown_unittest.mojom.h" | 8 #include "services/service_manager/tests/shutdown/shutdown_unittest.mojom.h" |
9 | 9 |
10 namespace service_manager { | 10 namespace service_manager { |
11 namespace { | 11 namespace { |
12 | 12 |
13 class ShutdownTest : public test::ServiceTest { | 13 class ShutdownTest : public test::ServiceTest { |
14 public: | 14 public: |
15 ShutdownTest() : test::ServiceTest("shutdown_unittest") {} | 15 ShutdownTest() : test::ServiceTest("shutdown_unittest") {} |
16 ~ShutdownTest() override {} | 16 ~ShutdownTest() override {} |
17 | 17 |
18 private: | 18 private: |
19 DISALLOW_COPY_AND_ASSIGN(ShutdownTest); | 19 DISALLOW_COPY_AND_ASSIGN(ShutdownTest); |
20 }; | 20 }; |
21 | 21 |
22 TEST_F(ShutdownTest, ConnectRace) { | 22 TEST_F(ShutdownTest, ConnectRace) { |
23 // This test exercises a number of potential shutdown races that can lead to | 23 // This test exercises a number of potential shutdown races that can lead to |
24 // client deadlock if any of various parts of the EDK or service manager are | 24 // client deadlock if any of various parts of the EDK or service manager are |
25 // not | 25 // not |
26 // working as intended. | 26 // working as intended. |
27 | 27 |
28 mojom::ShutdownTestClientControllerPtr control; | 28 mojom::ShutdownTestClientControllerPtr control; |
29 connector()->ConnectToInterface("shutdown_client", &control); | 29 connector()->BindInterface("shutdown_client", &control); |
30 | 30 |
31 // Connect to shutdown_service and immediately request that it shut down. | 31 // Connect to shutdown_service and immediately request that it shut down. |
32 mojom::ShutdownTestServicePtr service; | 32 mojom::ShutdownTestServicePtr service; |
33 connector()->ConnectToInterface("shutdown_service", &service); | 33 connector()->BindInterface("shutdown_service", &service); |
34 service->ShutDown(); | 34 service->ShutDown(); |
35 | 35 |
36 // Tell shutdown_client to connect to an interface on shutdown_service and | 36 // Tell shutdown_client to connect to an interface on shutdown_service and |
37 // then block waiting for the interface pipe to signal something. If anything | 37 // then block waiting for the interface pipe to signal something. If anything |
38 // goes wrong, its pipe won't signal and the client process will hang without | 38 // goes wrong, its pipe won't signal and the client process will hang without |
39 // responding to this request. | 39 // responding to this request. |
40 base::RunLoop loop; | 40 base::RunLoop loop; |
41 control->ConnectAndWait(loop.QuitClosure()); | 41 control->ConnectAndWait(loop.QuitClosure()); |
42 loop.Run(); | 42 loop.Run(); |
43 } | 43 } |
44 | 44 |
45 } // namespace | 45 } // namespace |
46 } // namespace service_manager | 46 } // namespace service_manager |
OLD | NEW |