OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/public/cpp/application/lib/service_registry.h" | 5 #include "mojo/public/cpp/application/lib/service_registry.h" |
6 | 6 |
7 #include "mojo/public/cpp/application/lib/service_connector.h" | 7 #include "mojo/public/cpp/application/lib/service_connector.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
11 namespace internal { | 11 namespace internal { |
12 namespace { | 12 namespace { |
13 | 13 |
14 class TestConnector : public ServiceConnectorBase { | 14 class TestConnector : public ServiceConnectorBase { |
15 public: | 15 public: |
16 TestConnector(const std::string& name, int* delete_count) | 16 TestConnector(const std::string& name, int* delete_count) |
17 : ServiceConnectorBase(name), delete_count_(delete_count) {} | 17 : ServiceConnectorBase(name), delete_count_(delete_count) {} |
18 virtual ~TestConnector() { (*delete_count_)++; } | 18 virtual ~TestConnector() { (*delete_count_)++; } |
19 virtual void ConnectToService( | 19 virtual void ConnectToService( |
20 const std::string& name, | 20 const std::string& name, |
21 ScopedMessagePipeHandle client_handle) MOJO_OVERRIDE {} | 21 ScopedMessagePipeHandle client_handle) override {} |
| 22 |
22 private: | 23 private: |
23 int* delete_count_; | 24 int* delete_count_; |
24 }; | 25 }; |
25 | 26 |
26 TEST(ServiceRegistryTest, Ownership) { | 27 TEST(ServiceRegistryTest, Ownership) { |
27 int delete_count = 0; | 28 int delete_count = 0; |
28 | 29 |
29 // Destruction. | 30 // Destruction. |
30 { | 31 { |
31 ServiceRegistry registry; | 32 ServiceRegistry registry; |
(...skipping 24 matching lines...) Expand all Loading... |
56 registry.AddServiceConnector(new TestConnector("TC1", &delete_count)); | 57 registry.AddServiceConnector(new TestConnector("TC1", &delete_count)); |
57 registry.AddServiceConnector(new TestConnector("TC1", &delete_count)); | 58 registry.AddServiceConnector(new TestConnector("TC1", &delete_count)); |
58 EXPECT_EQ(5, delete_count); | 59 EXPECT_EQ(5, delete_count); |
59 } | 60 } |
60 EXPECT_EQ(6, delete_count); | 61 EXPECT_EQ(6, delete_count); |
61 } | 62 } |
62 | 63 |
63 } // namespace | 64 } // namespace |
64 } // namespace internal | 65 } // namespace internal |
65 } // namespace mojo | 66 } // namespace mojo |
OLD | NEW |