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/shell/public/cpp/lib/service_registry.h" | 5 #include "mojo/shell/public/cpp/lib/service_registry.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "mojo/shell/public/cpp/service_connector.h" | 8 #include "mojo/shell/public/cpp/service_connector.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 namespace internal { | 12 namespace internal { |
13 namespace { | 13 namespace { |
14 | 14 |
15 class TestConnector : public ServiceConnector { | 15 class TestConnector : public ServiceConnector { |
16 public: | 16 public: |
17 explicit TestConnector(int* delete_count) : delete_count_(delete_count) {} | 17 explicit TestConnector(int* delete_count) : delete_count_(delete_count) {} |
18 ~TestConnector() override { (*delete_count_)++; } | 18 ~TestConnector() override { (*delete_count_)++; } |
19 void ConnectToService(ApplicationConnection* application_connection, | 19 void ConnectToService(Connection* connection, |
20 const std::string& interface_name, | 20 const std::string& interface_name, |
21 ScopedMessagePipeHandle client_handle) override {} | 21 ScopedMessagePipeHandle client_handle) override {} |
22 | 22 |
23 private: | 23 private: |
24 int* delete_count_; | 24 int* delete_count_; |
25 }; | 25 }; |
26 | 26 |
27 TEST(ServiceRegistryTest, Ownership) { | 27 TEST(ServiceRegistryTest, Ownership) { |
28 int delete_count = 0; | 28 int delete_count = 0; |
29 | 29 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 registry.SetServiceConnectorForName(new TestConnector(&delete_count), | 63 registry.SetServiceConnectorForName(new TestConnector(&delete_count), |
64 "TC1"); | 64 "TC1"); |
65 EXPECT_EQ(5, delete_count); | 65 EXPECT_EQ(5, delete_count); |
66 } | 66 } |
67 EXPECT_EQ(6, delete_count); | 67 EXPECT_EQ(6, delete_count); |
68 } | 68 } |
69 | 69 |
70 } // namespace | 70 } // namespace |
71 } // namespace internal | 71 } // namespace internal |
72 } // namespace mojo | 72 } // namespace mojo |
OLD | NEW |