Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Unified Diff: tests/PathTest.cpp

Issue 115323004: Improved SkPathRef interface security (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/core/SkPathRef.cpp ('K') | « src/core/SkPathRef.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathTest.cpp
===================================================================
--- tests/PathTest.cpp (revision 12667)
+++ tests/PathTest.cpp (working copy)
@@ -2679,8 +2679,8 @@
SkMatrix translate;
translate.setTranslate(SkIntToScalar(12), SkIntToScalar(12));
- // For simplicity, all the path concatenation related operations
- // would mark it non-circle, though in theory it's still a circle.
+ // Although all the path concatenation related operations leave
+ // the path a circle, most mark it as a non-circle for simplicity
// empty + circle (translate)
path = empty;
@@ -2690,7 +2690,7 @@
// circle + empty (translate)
path = circle;
path.addPath(empty, translate);
- check_for_circle(reporter, path, false, kCircleDir);
+ check_for_circle(reporter, path, true, kCircleDir);
// test reverseAddPath
path = circle;
@@ -3138,48 +3138,49 @@
}
}
+class TestingPathRefCreator {
+public:
+ static SkPathRef* Create() {
+ return SkNEW(SkPathRef);
+ }
+};
+
static void test_pathref(skiatest::Reporter* reporter) {
static const int kRepeatCnt = 10;
- SkPathRef* pathRef = SkPathRef::CreateEmpty();
- SkAutoTUnref<SkPathRef> pathRef2(SkPathRef::CreateEmpty());
- SkMatrix mat;
+ SkAutoTUnref<SkPathRef> pathRef(TestingPathRefCreator::Create());
- mat.setTranslate(10, 10);
+ SkPathRef::Editor ed(&pathRef);
- SkPathRef::CreateTransformedCopy(&pathRef2, *pathRef, mat);
-
- SkPathRef::Editor ed(&pathRef2);
-
{
ed.growForRepeatedVerb(SkPath::kMove_Verb, kRepeatCnt);
- REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs());
- REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countPoints());
- REPORTER_ASSERT(reporter, 0 == pathRef2->getSegmentMasks());
+ REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
+ REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countPoints());
+ REPORTER_ASSERT(reporter, 0 == pathRef->getSegmentMasks());
for (int i = 0; i < kRepeatCnt; ++i) {
- REPORTER_ASSERT(reporter, SkPath::kMove_Verb == pathRef2->atVerb(i));
+ REPORTER_ASSERT(reporter, SkPath::kMove_Verb == pathRef->atVerb(i));
}
ed.resetToSize(0, 0, 0);
}
{
ed.growForRepeatedVerb(SkPath::kLine_Verb, kRepeatCnt);
- REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs());
- REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countPoints());
- REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == pathRef2->getSegmentMasks());
+ REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
+ REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countPoints());
+ REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == pathRef->getSegmentMasks());
for (int i = 0; i < kRepeatCnt; ++i) {
- REPORTER_ASSERT(reporter, SkPath::kLine_Verb == pathRef2->atVerb(i));
+ REPORTER_ASSERT(reporter, SkPath::kLine_Verb == pathRef->atVerb(i));
}
ed.resetToSize(0, 0, 0);
}
{
ed.growForRepeatedVerb(SkPath::kQuad_Verb, kRepeatCnt);
- REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs());
- REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef2->countPoints());
- REPORTER_ASSERT(reporter, SkPath::kQuad_SegmentMask == pathRef2->getSegmentMasks());
+ REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
+ REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints());
+ REPORTER_ASSERT(reporter, SkPath::kQuad_SegmentMask == pathRef->getSegmentMasks());
for (int i = 0; i < kRepeatCnt; ++i) {
- REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == pathRef2->atVerb(i));
+ REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == pathRef->atVerb(i));
}
ed.resetToSize(0, 0, 0);
}
@@ -3187,24 +3188,24 @@
{
SkScalar* weights = NULL;
ed.growForRepeatedVerb(SkPath::kConic_Verb, kRepeatCnt, &weights);
- REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs());
- REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef2->countPoints());
- REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countWeights());
- REPORTER_ASSERT(reporter, SkPath::kConic_SegmentMask == pathRef2->getSegmentMasks());
+ REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
+ REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints());
+ REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countWeights());
+ REPORTER_ASSERT(reporter, SkPath::kConic_SegmentMask == pathRef->getSegmentMasks());
REPORTER_ASSERT(reporter, NULL != weights);
for (int i = 0; i < kRepeatCnt; ++i) {
- REPORTER_ASSERT(reporter, SkPath::kConic_Verb == pathRef2->atVerb(i));
+ REPORTER_ASSERT(reporter, SkPath::kConic_Verb == pathRef->atVerb(i));
}
ed.resetToSize(0, 0, 0);
}
{
ed.growForRepeatedVerb(SkPath::kCubic_Verb, kRepeatCnt);
- REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs());
- REPORTER_ASSERT(reporter, 3*kRepeatCnt == pathRef2->countPoints());
- REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == pathRef2->getSegmentMasks());
+ REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
+ REPORTER_ASSERT(reporter, 3*kRepeatCnt == pathRef->countPoints());
+ REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == pathRef->getSegmentMasks());
for (int i = 0; i < kRepeatCnt; ++i) {
- REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == pathRef2->atVerb(i));
+ REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == pathRef->atVerb(i));
}
ed.resetToSize(0, 0, 0);
}
« src/core/SkPathRef.cpp ('K') | « src/core/SkPathRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698