OLD | NEW |
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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 |
| 7 #include "base/test/opaque_ref_counted.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
7 | 9 |
8 namespace { | 10 namespace { |
9 | 11 |
10 class SelfAssign : public base::RefCounted<SelfAssign> { | 12 class SelfAssign : public base::RefCounted<SelfAssign> { |
11 friend class base::RefCounted<SelfAssign>; | 13 friend class base::RefCounted<SelfAssign>; |
12 | 14 |
13 ~SelfAssign() {} | 15 ~SelfAssign() {} |
14 }; | 16 }; |
15 | 17 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 TEST(RefCountedUnitTest, ScopedRefPtrMemberAccess) { | 55 TEST(RefCountedUnitTest, ScopedRefPtrMemberAccess) { |
54 CheckDerivedMemberAccess check; | 56 CheckDerivedMemberAccess check; |
55 } | 57 } |
56 | 58 |
57 TEST(RefCountedUnitTest, ScopedRefPtrToSelf) { | 59 TEST(RefCountedUnitTest, ScopedRefPtrToSelf) { |
58 ScopedRefPtrToSelf* check = new ScopedRefPtrToSelf(); | 60 ScopedRefPtrToSelf* check = new ScopedRefPtrToSelf(); |
59 EXPECT_FALSE(ScopedRefPtrToSelf::was_destroyed()); | 61 EXPECT_FALSE(ScopedRefPtrToSelf::was_destroyed()); |
60 check->SelfDestruct(); | 62 check->SelfDestruct(); |
61 EXPECT_TRUE(ScopedRefPtrToSelf::was_destroyed()); | 63 EXPECT_TRUE(ScopedRefPtrToSelf::was_destroyed()); |
62 } | 64 } |
| 65 |
| 66 TEST(RefCountedUnitTest, ScopedRefPtrToOpaque) { |
| 67 scoped_refptr<base::OpaqueRefCounted> p = base::MakeOpaqueRefCounted(); |
| 68 base::TestOpaqueRefCounted(p); |
| 69 |
| 70 scoped_refptr<base::OpaqueRefCounted> q; |
| 71 q = p; |
| 72 base::TestOpaqueRefCounted(p); |
| 73 base::TestOpaqueRefCounted(q); |
| 74 } |
OLD | NEW |