OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
| 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
| 10 #include "SkRefCnt.h" |
| 11 #include "SkTRefArray.h" |
| 12 #include "SkThreadUtils.h" |
8 #include "SkTypes.h" | 13 #include "SkTypes.h" |
9 #include "Test.h" | |
10 | |
11 #include "SkRefCnt.h" | |
12 #include "SkThreadUtils.h" | |
13 #include "SkWeakRefCnt.h" | 14 #include "SkWeakRefCnt.h" |
14 #include "SkTRefArray.h" | |
15 | |
16 /////////////////////////////////////////////////////////////////////////////// | |
17 | 15 |
18 class InstCounterClass { | 16 class InstCounterClass { |
19 public: | 17 public: |
20 InstCounterClass() { fCount = gInstCounter++; } | 18 InstCounterClass() { fCount = gInstCounter++; } |
21 InstCounterClass(const InstCounterClass& src) { | 19 InstCounterClass(const InstCounterClass& src) { |
22 fCount = src.fCount; | 20 fCount = src.fCount; |
23 gInstCounter += 1; | 21 gInstCounter += 1; |
24 } | 22 } |
25 virtual ~InstCounterClass() { gInstCounter -= 1; } | 23 virtual ~InstCounterClass() { gInstCounter -= 1; } |
26 | 24 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 thing1.join(); | 134 thing1.join(); |
137 thing2.join(); | 135 thing2.join(); |
138 thing3.join(); | 136 thing3.join(); |
139 thing4.join(); | 137 thing4.join(); |
140 | 138 |
141 REPORTER_ASSERT(reporter, ref->getRefCnt() == 1); | 139 REPORTER_ASSERT(reporter, ref->getRefCnt() == 1); |
142 REPORTER_ASSERT(reporter, ref->getWeakCnt() == 1); | 140 REPORTER_ASSERT(reporter, ref->getWeakCnt() == 1); |
143 ref->unref(); | 141 ref->unref(); |
144 } | 142 } |
145 | 143 |
146 static void test_refCntTests(skiatest::Reporter* reporter) { | 144 DEF_TEST(RefCnt, reporter) { |
147 test_refCnt(reporter); | 145 test_refCnt(reporter); |
148 test_weakRefCnt(reporter); | 146 test_weakRefCnt(reporter); |
149 test_refarray(reporter); | 147 test_refarray(reporter); |
150 } | 148 } |
151 | |
152 #include "TestClassDef.h" | |
153 DEFINE_TESTCLASS("RefCnt", RefCntTestClass, test_refCntTests) | |
OLD | NEW |