| 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 ~TestConnector() override { (*delete_count_)++; } |
| 19 virtual void ConnectToService( | 19 void ConnectToService(const std::string& name, |
| 20 const std::string& name, | 20 ScopedMessagePipeHandle client_handle) override {} |
| 21 ScopedMessagePipeHandle client_handle) override {} | |
| 22 | 21 |
| 23 private: | 22 private: |
| 24 int* delete_count_; | 23 int* delete_count_; |
| 25 }; | 24 }; |
| 26 | 25 |
| 27 TEST(ServiceRegistryTest, Ownership) { | 26 TEST(ServiceRegistryTest, Ownership) { |
| 28 int delete_count = 0; | 27 int delete_count = 0; |
| 29 | 28 |
| 30 // Destruction. | 29 // Destruction. |
| 31 { | 30 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 57 registry.AddServiceConnector(new TestConnector("TC1", &delete_count)); | 56 registry.AddServiceConnector(new TestConnector("TC1", &delete_count)); |
| 58 registry.AddServiceConnector(new TestConnector("TC1", &delete_count)); | 57 registry.AddServiceConnector(new TestConnector("TC1", &delete_count)); |
| 59 EXPECT_EQ(5, delete_count); | 58 EXPECT_EQ(5, delete_count); |
| 60 } | 59 } |
| 61 EXPECT_EQ(6, delete_count); | 60 EXPECT_EQ(6, delete_count); |
| 62 } | 61 } |
| 63 | 62 |
| 64 } // namespace | 63 } // namespace |
| 65 } // namespace internal | 64 } // namespace internal |
| 66 } // namespace mojo | 65 } // namespace mojo |
| OLD | NEW |