embed a refdict inside SkDevice
udate unittests to test refdict's destructor
git-svn-id: http://skia.googlecode.com/svn/trunk@731 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/RefDictTest.cpp b/tests/RefDictTest.cpp
index 61f64e9..f52541b 100644
--- a/tests/RefDictTest.cpp
+++ b/tests/RefDictTest.cpp
@@ -46,6 +46,20 @@
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());
+
+ {
+ SkRefDict d;
+ REPORTER_ASSERT(reporter, NULL == d.find("foo"));
+ REPORTER_ASSERT(reporter, 1 == data0.getRefCnt());
+ d.set("foo", &data0);
+ REPORTER_ASSERT(reporter, &data0 == d.find("foo"));
+ REPORTER_ASSERT(reporter, 2 == data0.getRefCnt());
+ // 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());
}
#include "TestClassDef.h"