| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 private: | 24 private: |
| 25 RTC_DISALLOW_COPY_AND_ASSIGN(A); | 25 RTC_DISALLOW_COPY_AND_ASSIGN(A); |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 class RefClass : public RefCountInterface { | 28 class RefClass : public RefCountInterface { |
| 29 public: | 29 public: |
| 30 RefClass() {} | 30 RefClass() {} |
| 31 | 31 |
| 32 protected: | 32 protected: |
| 33 virtual ~RefClass() {} | 33 ~RefClass() override {} |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 class RefClassWithRvalue : public RefCountInterface { | 36 class RefClassWithRvalue : public RefCountInterface { |
| 37 public: | 37 public: |
| 38 explicit RefClassWithRvalue(std::unique_ptr<A> a) : a_(std::move(a)) {} | 38 explicit RefClassWithRvalue(std::unique_ptr<A> a) : a_(std::move(a)) {} |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 virtual ~RefClassWithRvalue() {} | 41 ~RefClassWithRvalue() override {} |
| 42 | 42 |
| 43 public: | 43 public: |
| 44 std::unique_ptr<A> a_; | 44 std::unique_ptr<A> a_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class RefClassWithMixedValues : public RefCountInterface { | 47 class RefClassWithMixedValues : public RefCountInterface { |
| 48 public: | 48 public: |
| 49 RefClassWithMixedValues(std::unique_ptr<A> a, int b, const std::string& c) | 49 RefClassWithMixedValues(std::unique_ptr<A> a, int b, const std::string& c) |
| 50 : a_(std::move(a)), b_(b), c_(c) {} | 50 : a_(std::move(a)), b_(b), c_(c) {} |
| 51 | 51 |
| 52 protected: | 52 protected: |
| 53 virtual ~RefClassWithMixedValues() {} | 53 ~RefClassWithMixedValues() override {} |
| 54 | 54 |
| 55 public: | 55 public: |
| 56 std::unique_ptr<A> a_; | 56 std::unique_ptr<A> a_; |
| 57 int b_; | 57 int b_; |
| 58 std::string c_; | 58 std::string c_; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| 63 TEST(RefCountedObject, Basic) { | 63 TEST(RefCountedObject, Basic) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 82 std::string c = "hello"; | 82 std::string c = "hello"; |
| 83 scoped_refptr<RefClassWithMixedValues> ref( | 83 scoped_refptr<RefClassWithMixedValues> ref( |
| 84 new RefCountedObject<RefClassWithMixedValues>(std::move(a), b, c)); | 84 new RefCountedObject<RefClassWithMixedValues>(std::move(a), b, c)); |
| 85 EXPECT_TRUE(ref->a_.get() != nullptr); | 85 EXPECT_TRUE(ref->a_.get() != nullptr); |
| 86 EXPECT_TRUE(a.get() == nullptr); | 86 EXPECT_TRUE(a.get() == nullptr); |
| 87 EXPECT_EQ(b, ref->b_); | 87 EXPECT_EQ(b, ref->b_); |
| 88 EXPECT_EQ(c, ref->c_); | 88 EXPECT_EQ(c, ref->c_); |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace rtc | 91 } // namespace rtc |
| OLD | NEW |