From 6eb549e8ca3d88d7536859fd5aa3343fc3011f2f Mon Sep 17 00:00:00 2001 From: "vandebo@chromium.org" Date: Fri, 4 Jan 2013 18:11:21 +0000 Subject: 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 --- tests/UtilsTest.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests/UtilsTest.cpp') 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 rc0; + REPORTER_ASSERT(reporter, rc0.get() == NULL); + REPORTER_ASSERT(reporter, !rc0); + + SkRefPtr 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); } -- cgit v1.2.3