Index: tests/PathTest.cpp |
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp |
index c47b2c4858d6f9ff3f2351c4a2db25fe484ca8aa..feec979883b38da98bac16e94c9935ab1df75c4d 100644 |
--- a/tests/PathTest.cpp |
+++ b/tests/PathTest.cpp |
@@ -127,7 +127,6 @@ static void test_android_specific_behavior(skiatest::Reporter* reporter) { |
original.setSourcePath(&source); |
original.moveTo(0, 0); |
original.lineTo(1, 1); |
- REPORTER_ASSERT(reporter, original.getGenerationID() > 0); |
REPORTER_ASSERT(reporter, original.getSourcePath() == &source); |
uint32_t copyID, assignID; |
@@ -141,33 +140,84 @@ static void test_android_specific_behavior(skiatest::Reporter* reporter) { |
SkPath assign; |
assignID = assign.getGenerationID(); |
assign = original; |
- REPORTER_ASSERT(reporter, assign.getGenerationID() > assignID); |
+ REPORTER_ASSERT(reporter, assign.getGenerationID() != assignID); |
REPORTER_ASSERT(reporter, assign.getSourcePath() == original.getSourcePath()); |
// Test rewind. Increment generation ID, don't touch source path. |
copyID = copy.getGenerationID(); |
copy.rewind(); |
- REPORTER_ASSERT(reporter, copy.getGenerationID() > copyID); |
+ REPORTER_ASSERT(reporter, copy.getGenerationID() != copyID); |
REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); |
// Test reset. Increment generation ID, don't touch source path. |
mtklein
2013/10/30 15:59:10
These little comments may need an update. Maybe j
bsalomon
2013/10/30 17:39:08
Done.
|
assignID = assign.getGenerationID(); |
assign.reset(); |
- REPORTER_ASSERT(reporter, assign.getGenerationID() > assignID); |
+ REPORTER_ASSERT(reporter, assign.getGenerationID() != assignID); |
REPORTER_ASSERT(reporter, assign.getSourcePath() == original.getSourcePath()); |
// Test swap. Increment both generation IDs, swap source paths. |
+ copy.reset(); |
+ copy.moveTo(2, 2); |
copy.setSourcePath(&anotherSource); |
copyID = copy.getGenerationID(); |
+ assign.moveTo(3, 3); |
assignID = assign.getGenerationID(); |
copy.swap(assign); |
- REPORTER_ASSERT(reporter, copy.getGenerationID() > copyID); |
- REPORTER_ASSERT(reporter, assign.getGenerationID() > assignID); |
+ REPORTER_ASSERT(reporter, copy.getGenerationID() != copyID); |
+ REPORTER_ASSERT(reporter, assign.getGenerationID() != assignID); |
REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); |
REPORTER_ASSERT(reporter, assign.getSourcePath() == &anotherSource); |
#endif |
} |
+static void test_gen_id(skiatest::Reporter* reporter) { |
+ SkPath a, b; |
+ REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID()); |
+ |
+ a.moveTo(0, 0); |
+ uint32_t z = a.getGenerationID(); |
mtklein
2013/10/30 15:59:10
const on v,w,x,y,z would help reading?
bsalomon
2013/10/30 17:39:08
Done.
|
+ REPORTER_ASSERT(reporter, z != b.getGenerationID()); |
+ |
+ a.reset(); |
+ REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID()); |
+ |
+ a.moveTo(1, 1); |
+ uint32_t y = a.getGenerationID(); |
+ REPORTER_ASSERT(reporter, z != y); |
+ |
+ b.moveTo(2, 2); |
+ uint32_t x = b.getGenerationID(); |
+ REPORTER_ASSERT(reporter, x != y && x != z); |
+ |
+ a.swap(b); |
+ REPORTER_ASSERT(reporter, b.getGenerationID() == y && a.getGenerationID() == x); |
+ |
+ b = a; |
+ REPORTER_ASSERT(reporter, b.getGenerationID() == x); |
+ |
+ SkPath c(a); |
+ REPORTER_ASSERT(reporter, c.getGenerationID() == x); |
+ |
+ c.lineTo(3, 3); |
+ uint32_t w = c.getGenerationID(); |
+ REPORTER_ASSERT(reporter, b.getGenerationID() == x); |
+ REPORTER_ASSERT(reporter, a.getGenerationID() == x); |
+ REPORTER_ASSERT(reporter, w != x); |
+ |
+#ifdef SK_BUILD_FOR_ANDROID |
+ static bool kExpectGenIDToIgnoreFill = false; |
+#else |
+ static bool kExpectGenIDToIgnoreFill = true; |
+#endif |
+ |
+ c.toggleInverseFillType(); |
+ uint32_t v = c.getGenerationID(); |
+ REPORTER_ASSERT(reporter, (v == w) == kExpectGenIDToIgnoreFill); |
+ |
+ c.rewind(); |
+ REPORTER_ASSERT(reporter, v != c.getGenerationID()); |
+} |
+ |
// This used to assert in the debug build, as the edges did not all line-up. |
static void test_bad_cubic_crbug234190() { |
SkPath path; |
@@ -2620,6 +2670,7 @@ static void TestPath(skiatest::Reporter* reporter) { |
test_bad_cubic_crbug229478(); |
test_bad_cubic_crbug234190(); |
test_android_specific_behavior(reporter); |
+ test_gen_id(reporter); |
test_path_close_issue1474(reporter); |
test_path_to_region(reporter); |
} |