diff options
author | 2014-07-08 06:48:17 -0700 | |
---|---|---|
committer | 2014-07-08 06:48:17 -0700 | |
commit | 4ae94ffce5ecf1b71cb5e295b68bf4ec9e697443 (patch) | |
tree | 6c734cf27a2f033bfb5f512420860fd035d0bbfa /tests/RefDictTest.cpp | |
parent | 3afef1f75f710b8f183113cdc5188416f7d01f28 (diff) |
Remove ability for Release code to call getRefCnt() or getWeakRefCnt().
These getRefCnt() methods are not thread safe, so Skia code should not
be calling them. unique() is fine.
SkDEBUG code (SkASSERTs) can still call getRefCnt() / getWeakRefCnt().
This adds tools/RefCntIs.{h,cpp}, which lets tests make their assertions in
both debug and release modes.
BUG=skia:2726
R=senorblanco@chromium.org, mtklein@google.com, reed@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/378643003
Diffstat (limited to 'tests/RefDictTest.cpp')
-rw-r--r-- | tests/RefDictTest.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/tests/RefDictTest.cpp b/tests/RefDictTest.cpp index 1e18a6815d..5b9987e29a 100644 --- a/tests/RefDictTest.cpp +++ b/tests/RefDictTest.cpp @@ -6,6 +6,7 @@ */ #include "SkRefDict.h" +#include "RefCntIs.h" #include "Test.h" class TestRC : public SkRefCnt { @@ -25,50 +26,50 @@ DEF_TEST(RefDict, reporter) { dict.set("foo", &data0); REPORTER_ASSERT(reporter, &data0 == dict.find("foo")); - REPORTER_ASSERT(reporter, 2 == data0.getRefCnt()); + REPORTER_ASSERT(reporter, RefCntIs(data0, 2)); dict.set("foo", &data0); REPORTER_ASSERT(reporter, &data0 == dict.find("foo")); - REPORTER_ASSERT(reporter, 2 == data0.getRefCnt()); + REPORTER_ASSERT(reporter, RefCntIs(data0, 2)); dict.set("foo", &data1); REPORTER_ASSERT(reporter, &data1 == dict.find("foo")); - REPORTER_ASSERT(reporter, 1 == data0.getRefCnt()); - REPORTER_ASSERT(reporter, 2 == data1.getRefCnt()); + REPORTER_ASSERT(reporter, RefCntIs(data0, 1)); + REPORTER_ASSERT(reporter, RefCntIs(data1, 2)); dict.set("foo", NULL); REPORTER_ASSERT(reporter, NULL == dict.find("foo")); - REPORTER_ASSERT(reporter, 1 == data0.getRefCnt()); - REPORTER_ASSERT(reporter, 1 == data1.getRefCnt()); + REPORTER_ASSERT(reporter, RefCntIs(data0, 1)); + REPORTER_ASSERT(reporter, RefCntIs(data1, 1)); dict.set("foo", &data0); dict.set("bar", &data1); REPORTER_ASSERT(reporter, &data0 == dict.find("foo")); REPORTER_ASSERT(reporter, &data1 == dict.find("bar")); - REPORTER_ASSERT(reporter, 2 == data0.getRefCnt()); - REPORTER_ASSERT(reporter, 2 == data1.getRefCnt()); + REPORTER_ASSERT(reporter, RefCntIs(data0, 2)); + REPORTER_ASSERT(reporter, RefCntIs(data1, 2)); dict.set("foo", &data1); REPORTER_ASSERT(reporter, &data1 == dict.find("foo")); REPORTER_ASSERT(reporter, &data1 == dict.find("bar")); - REPORTER_ASSERT(reporter, 1 == data0.getRefCnt()); - REPORTER_ASSERT(reporter, 3 == data1.getRefCnt()); + REPORTER_ASSERT(reporter, RefCntIs(data0, 1)); + REPORTER_ASSERT(reporter, RefCntIs(data1, 3)); dict.removeAll(); REPORTER_ASSERT(reporter, NULL == dict.find("foo")); REPORTER_ASSERT(reporter, NULL == dict.find("bar")); - REPORTER_ASSERT(reporter, 1 == data0.getRefCnt()); - REPORTER_ASSERT(reporter, 1 == data1.getRefCnt()); + REPORTER_ASSERT(reporter, RefCntIs(data0, 1)); + REPORTER_ASSERT(reporter, RefCntIs(data1, 1)); { SkRefDict d; REPORTER_ASSERT(reporter, NULL == d.find("foo")); - REPORTER_ASSERT(reporter, 1 == data0.getRefCnt()); + REPORTER_ASSERT(reporter, RefCntIs(data0, 1)); d.set("foo", &data0); REPORTER_ASSERT(reporter, &data0 == d.find("foo")); - REPORTER_ASSERT(reporter, 2 == data0.getRefCnt()); + REPORTER_ASSERT(reporter, RefCntIs(data0, 2)); // let d go out of scope still with a ref on data0 } // be sure d's destructor lowered data0's owner count back to 1 - REPORTER_ASSERT(reporter, 1 == data0.getRefCnt()); + REPORTER_ASSERT(reporter, RefCntIs(data0, 1)); } |