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/service_connector.h" | 7 #include "mojo/public/cpp/application/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 ServiceConnector { | 14 class TestConnector : public ServiceConnector { |
15 public: | 15 public: |
16 explicit TestConnector(int* delete_count) : delete_count_(delete_count) {} | 16 explicit TestConnector(int* delete_count) : delete_count_(delete_count) {} |
17 ~TestConnector() override { (*delete_count_)++; } | 17 ~TestConnector() override { (*delete_count_)++; } |
18 void ConnectToService(ApplicationConnection* application_connection, | 18 void ConnectToService(const ConnectionContext& connection_context, |
19 const std::string& interface_name, | 19 const std::string& interface_name, |
20 ScopedMessagePipeHandle client_handle) override {} | 20 ScopedMessagePipeHandle client_handle) override {} |
21 | 21 |
22 private: | 22 private: |
23 int* delete_count_; | 23 int* delete_count_; |
24 }; | 24 }; |
25 | 25 |
26 TEST(ServiceRegistryTest, Ownership) { | 26 TEST(ServiceRegistryTest, Ownership) { |
27 int delete_count = 0; | 27 int delete_count = 0; |
28 | 28 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 registry.SetServiceConnectorForName(new TestConnector(&delete_count), | 61 registry.SetServiceConnectorForName(new TestConnector(&delete_count), |
62 "TC1"); | 62 "TC1"); |
63 EXPECT_EQ(5, delete_count); | 63 EXPECT_EQ(5, delete_count); |
64 } | 64 } |
65 EXPECT_EQ(6, delete_count); | 65 EXPECT_EQ(6, delete_count); |
66 } | 66 } |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 } // namespace internal | 69 } // namespace internal |
70 } // namespace mojo | 70 } // namespace mojo |
OLD | NEW |