aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/UtilsTest.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-02-25 18:10:29 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-02-25 18:10:29 +0000
commita67573e25faa81ea65e6fc368f66d3f0c0a5f189 (patch)
tree2ec1768eaf76e7446c3fa9630588d413ed50463b /tests/UtilsTest.cpp
parent29f6636a5faad017f07980727eb29a13febfaf3d (diff)
Add templated version of SkAutoTUnref. Add unittests for it. Remove unused helper apis on SkAutoUnref. git-svn-id: http://skia.googlecode.com/svn/trunk@858 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/UtilsTest.cpp')
-rw-r--r--tests/UtilsTest.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/UtilsTest.cpp b/tests/UtilsTest.cpp
index 8ec063e77d..1e11bdcc2d 100644
--- a/tests/UtilsTest.cpp
+++ b/tests/UtilsTest.cpp
@@ -43,6 +43,27 @@ static void test_refptr(skiatest::Reporter* reporter) {
r0->unref();
}
+static void test_autounref(skiatest::Reporter* reporter) {
+ RefClass obj(0);
+ REPORTER_ASSERT(reporter, 1 == obj.getRefCnt());
+
+ SkAutoTUnref<RefClass> tmp(&obj);
+ REPORTER_ASSERT(reporter, &obj == tmp.get());
+ REPORTER_ASSERT(reporter, 1 == obj.getRefCnt());
+
+ REPORTER_ASSERT(reporter, &obj == tmp.detach());
+ REPORTER_ASSERT(reporter, 1 == obj.getRefCnt());
+ REPORTER_ASSERT(reporter, NULL == tmp.detach());
+ REPORTER_ASSERT(reporter, NULL == tmp.get());
+
+ obj.ref();
+ REPORTER_ASSERT(reporter, 2 == obj.getRefCnt());
+ {
+ SkAutoTUnref<RefClass> tmp2(&obj);
+ }
+ REPORTER_ASSERT(reporter, 1 == obj.getRefCnt());
+}
+
///////////////////////////////////////////////////////////////////////////////
#define kSEARCH_COUNT 91
@@ -145,7 +166,8 @@ static void TestUTF(skiatest::Reporter* reporter) {
test_utf16(reporter);
test_search(reporter);
test_refptr(reporter);
+ test_autounref(reporter);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("UTF", UtfTestClass, TestUTF)
+DEFINE_TESTCLASS("Utils", UtfTestClass, TestUTF)