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

Side by Side Diff: webrtc/base/bind_unittest.cc

Issue 2711113008: Adding rtc::Unretained to allow avoiding rtc::Bind reference capture. (Closed)
Patch Set: Rebase onto master Created 3 years, 10 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 | « webrtc/base/bind.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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 static_assert( \ 80 static_assert( \
81 is_same<detail::PointerType<T>::type, scoped_refptr<T>>::value, \ 81 is_same<detail::PointerType<T>::type, scoped_refptr<T>>::value, \
82 "PointerType") 82 "PointerType")
83 83
84 EXPECT_IS_CAPTURED_AS_PTR(void); 84 EXPECT_IS_CAPTURED_AS_PTR(void);
85 EXPECT_IS_CAPTURED_AS_PTR(int); 85 EXPECT_IS_CAPTURED_AS_PTR(int);
86 EXPECT_IS_CAPTURED_AS_PTR(double); 86 EXPECT_IS_CAPTURED_AS_PTR(double);
87 EXPECT_IS_CAPTURED_AS_PTR(A); 87 EXPECT_IS_CAPTURED_AS_PTR(A);
88 EXPECT_IS_CAPTURED_AS_PTR(D); 88 EXPECT_IS_CAPTURED_AS_PTR(D);
89 EXPECT_IS_CAPTURED_AS_PTR(RefCountInterface*); 89 EXPECT_IS_CAPTURED_AS_PTR(RefCountInterface*);
90 EXPECT_IS_CAPTURED_AS_PTR(
91 decltype(Unretained<RefCountedObject<RefCountInterface>>));
90 92
91 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(RefCountInterface); 93 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(RefCountInterface);
92 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(B); 94 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(B);
93 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(C); 95 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(C);
94 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(E); 96 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(E);
95 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(F); 97 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(F);
96 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(RefCountedObject<RefCountInterface>); 98 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(RefCountedObject<RefCountInterface>);
97 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(RefCountedObject<B>); 99 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(RefCountedObject<B>);
98 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(RefCountedObject<C>); 100 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(RefCountedObject<C>);
99 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(const RefCountedObject<RefCountInterface>); 101 EXPECT_IS_CAPTURED_AS_SCOPED_REFPTR(const RefCountedObject<RefCountInterface>);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // modified to a non-reference capture. 213 // modified to a non-reference capture.
212 TEST(BindTest, RefArgument) { 214 TEST(BindTest, RefArgument) {
213 const int x = 42; 215 const int x = 42;
214 EXPECT_EQ(&x, Ref(x)); 216 EXPECT_EQ(&x, Ref(x));
215 // Bind() should make a copy of |x|, i.e. the pointers should be different. 217 // Bind() should make a copy of |x|, i.e. the pointers should be different.
216 auto functor = Bind(&Ref, x); 218 auto functor = Bind(&Ref, x);
217 EXPECT_NE(&x, functor()); 219 EXPECT_NE(&x, functor());
218 } 220 }
219 221
220 } // namespace rtc 222 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/bind.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698