Index: mojo/shell/public/cpp/tests/interface_registry_unittest.cc |
diff --git a/mojo/shell/public/cpp/tests/interface_registry_unittest.cc b/mojo/shell/public/cpp/tests/interface_registry_unittest.cc |
deleted file mode 100644 |
index cf6441fcb883e22b1186ee4768995761e5c06e70..0000000000000000000000000000000000000000 |
--- a/mojo/shell/public/cpp/tests/interface_registry_unittest.cc |
+++ /dev/null |
@@ -1,73 +0,0 @@ |
-// Copyright 2014 The Chromium Authors. All rights reserved. |
-// Use of this source code is governed by a BSD-style license that can be |
-// found in the LICENSE file. |
- |
-#include "mojo/shell/public/cpp/interface_registry.h" |
- |
-#include "base/memory/scoped_ptr.h" |
-#include "base/message_loop/message_loop.h" |
-#include "mojo/shell/public/cpp/interface_binder.h" |
-#include "testing/gtest/include/gtest/gtest.h" |
- |
-namespace mojo { |
-namespace internal { |
-namespace { |
- |
-class TestBinder : public InterfaceBinder { |
- public: |
- explicit TestBinder(int* delete_count) : delete_count_(delete_count) {} |
- ~TestBinder() override { (*delete_count_)++; } |
- void BindInterface(Connection* connection, |
- const std::string& interface_name, |
- ScopedMessagePipeHandle client_handle) override {} |
- |
- private: |
- int* delete_count_; |
-}; |
- |
-TEST(InterfaceRegistryTest, Ownership) { |
- base::MessageLoop message_loop_; |
- int delete_count = 0; |
- |
- // Destruction. |
- { |
- InterfaceRegistry registry(nullptr); |
- InterfaceRegistry::TestApi test_api(®istry); |
- test_api.SetInterfaceBinderForName(new TestBinder(&delete_count), "TC1"); |
- } |
- EXPECT_EQ(1, delete_count); |
- |
- // Removal. |
- { |
- scoped_ptr<InterfaceRegistry> registry(new InterfaceRegistry(nullptr)); |
- InterfaceBinder* b = new TestBinder(&delete_count); |
- InterfaceRegistry::TestApi test_api(registry.get()); |
- test_api.SetInterfaceBinderForName(b, "TC1"); |
- test_api.RemoveInterfaceBinderForName("TC1"); |
- registry.reset(); |
- EXPECT_EQ(2, delete_count); |
- } |
- |
- // Multiple. |
- { |
- InterfaceRegistry registry(nullptr); |
- InterfaceRegistry::TestApi test_api(®istry); |
- test_api.SetInterfaceBinderForName(new TestBinder(&delete_count), "TC1"); |
- test_api.SetInterfaceBinderForName(new TestBinder(&delete_count), "TC2"); |
- } |
- EXPECT_EQ(4, delete_count); |
- |
- // Re-addition. |
- { |
- InterfaceRegistry registry(nullptr); |
- InterfaceRegistry::TestApi test_api(®istry); |
- test_api.SetInterfaceBinderForName(new TestBinder(&delete_count), "TC1"); |
- test_api.SetInterfaceBinderForName(new TestBinder(&delete_count), "TC1"); |
- EXPECT_EQ(5, delete_count); |
- } |
- EXPECT_EQ(6, delete_count); |
-} |
- |
-} // namespace |
-} // namespace internal |
-} // namespace mojo |