aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/UtilsTest.cpp
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-04 18:11:21 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-04 18:11:21 +0000
commit6eb549e8ca3d88d7536859fd5aa3343fc3011f2f (patch)
treed97411a5a61648e62f2e23e6139982681b9fa6d1 /tests/UtilsTest.cpp
parente8a76ae8edc4f90456f9d8f90e56bf97f2657f3a (diff)
Revert "Remove SkRefPtr" - r7021
samplecode/ still needs to be updated. Review URL: https://codereview.appspot.com/7032048 git-svn-id: http://skia.googlecode.com/svn/trunk@7022 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/UtilsTest.cpp')
-rw-r--r--tests/UtilsTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/UtilsTest.cpp b/tests/UtilsTest.cpp
index 7f27f7e78e..1c2f870d1f 100644
--- a/tests/UtilsTest.cpp
+++ b/tests/UtilsTest.cpp
@@ -27,6 +27,35 @@ private:
SK_DEFINE_INST_COUNT(RefClass)
+static void test_refptr(skiatest::Reporter* reporter) {
+ RefClass* r0 = new RefClass(0);
+
+ SkRefPtr<RefClass> rc0;
+ REPORTER_ASSERT(reporter, rc0.get() == NULL);
+ REPORTER_ASSERT(reporter, !rc0);
+
+ SkRefPtr<RefClass> rc1;
+ REPORTER_ASSERT(reporter, rc0 == rc1);
+ REPORTER_ASSERT(reporter, rc0.get() != r0);
+
+ rc0 = r0;
+ REPORTER_ASSERT(reporter, rc0);
+ REPORTER_ASSERT(reporter, rc0 != rc1);
+ REPORTER_ASSERT(reporter, rc0.get() == r0);
+
+ rc1 = rc0;
+ REPORTER_ASSERT(reporter, rc1);
+ REPORTER_ASSERT(reporter, rc0 == rc1);
+ REPORTER_ASSERT(reporter, rc0.get() == r0);
+
+ rc0 = NULL;
+ REPORTER_ASSERT(reporter, rc0.get() == NULL);
+ REPORTER_ASSERT(reporter, !rc0);
+ REPORTER_ASSERT(reporter, rc0 != rc1);
+
+ r0->unref();
+}
+
static void test_autounref(skiatest::Reporter* reporter) {
RefClass obj(0);
REPORTER_ASSERT(reporter, 1 == obj.getRefCnt());
@@ -149,6 +178,7 @@ static void TestUTF(skiatest::Reporter* reporter) {
test_utf16(reporter);
test_search(reporter);
+ test_refptr(reporter);
test_autounref(reporter);
}