Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Side by Side Diff: base/bind_unittest.cc

Issue 2106123002: Remove unused UnsafeBindtoRefCountedArg in bind_helpers.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/bind_helpers.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 EXPECT_EQ(1, array_cb.Run()); 643 EXPECT_EQ(1, array_cb.Run());
644 644
645 Callback<int()> const_array_cb = Bind(&ArrayGet, *const_array_ptr, 1); 645 Callback<int()> const_array_cb = Bind(&ArrayGet, *const_array_ptr, 1);
646 EXPECT_EQ(1, const_array_cb.Run()); 646 EXPECT_EQ(1, const_array_cb.Run());
647 647
648 array[1] = 3; 648 array[1] = 3;
649 EXPECT_EQ(3, array_cb.Run()); 649 EXPECT_EQ(3, array_cb.Run());
650 EXPECT_EQ(3, const_array_cb.Run()); 650 EXPECT_EQ(3, const_array_cb.Run());
651 } 651 }
652 652
653 // Verify SupportsAddRefAndRelease correctly introspects the class type for
654 // AddRef() and Release().
655 // - Class with AddRef() and Release()
656 // - Class without AddRef() and Release()
657 // - Derived Class with AddRef() and Release()
658 // - Derived Class without AddRef() and Release()
659 // - Derived Class with AddRef() and Release() and a private destructor.
660 TEST_F(BindTest, SupportsAddRefAndRelease) {
661 EXPECT_TRUE(internal::SupportsAddRefAndRelease<HasRef>::value);
662 EXPECT_FALSE(internal::SupportsAddRefAndRelease<NoRef>::value);
663
664 // StrictMock<T> is a derived class of T. So, we use StrictMock<HasRef> and
665 // StrictMock<NoRef> to test that SupportsAddRefAndRelease works over
666 // inheritance.
667 EXPECT_TRUE(internal::SupportsAddRefAndRelease<StrictMock<HasRef> >::value);
668 EXPECT_FALSE(internal::SupportsAddRefAndRelease<StrictMock<NoRef> >::value);
669
670 // This matters because the implementation creates a dummy class that
671 // inherits from the template type.
672 EXPECT_TRUE(internal::SupportsAddRefAndRelease<HasRefPrivateDtor>::value);
673 }
674
675 // Unretained() wrapper support. 653 // Unretained() wrapper support.
676 // - Method bound to Unretained() non-const object. 654 // - Method bound to Unretained() non-const object.
677 // - Const method bound to Unretained() non-const object. 655 // - Const method bound to Unretained() non-const object.
678 // - Const method bound to Unretained() const object. 656 // - Const method bound to Unretained() const object.
679 TEST_F(BindTest, Unretained) { 657 TEST_F(BindTest, Unretained) {
680 EXPECT_CALL(no_ref_, VoidMethod0()); 658 EXPECT_CALL(no_ref_, VoidMethod0());
681 EXPECT_CALL(no_ref_, VoidConstMethod0()).Times(2); 659 EXPECT_CALL(no_ref_, VoidConstMethod0()).Times(2);
682 660
683 Callback<void()> method_cb = 661 Callback<void()> method_cb =
684 Bind(&NoRef::VoidMethod0, Unretained(&no_ref_)); 662 Bind(&NoRef::VoidMethod0, Unretained(&no_ref_));
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 base::Callback<void(int)> null_cb; 1072 base::Callback<void(int)> null_cb;
1095 ASSERT_TRUE(null_cb.is_null()); 1073 ASSERT_TRUE(null_cb.is_null());
1096 EXPECT_DEATH(base::Bind(null_cb, 42), ""); 1074 EXPECT_DEATH(base::Bind(null_cb, 42), "");
1097 } 1075 }
1098 1076
1099 #endif // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && 1077 #endif // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) &&
1100 // GTEST_HAS_DEATH_TEST 1078 // GTEST_HAS_DEATH_TEST
1101 1079
1102 } // namespace 1080 } // namespace
1103 } // namespace base 1081 } // namespace base
OLDNEW
« no previous file with comments | « base/bind_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698