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

Unified Diff: tests/PathTest.cpp

Issue 22911002: Update how SkPath handles fGenerationID and fSourcePath, and add tests to cover. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: ued -> used Created 7 years, 4 months 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
« no previous file with comments | « src/core/SkPath.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
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 4637e9218b8533762850e76cbffc4edd9d178f48..e6795d63c5909bb370a5080d0b96d0e87c34e24c 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -84,18 +84,50 @@ static void test_path_close_issue1474(skiatest::Reporter* reporter) {
static void test_android_specific_behavior(skiatest::Reporter* reporter) {
#ifdef SK_BUILD_FOR_ANDROID
- // Copy constructor should preserve generation ID, but assignment shouldn't.
- SkPath original;
+ // Make sure we treat fGenerationID and fSourcePath correctly for each of
+ // copy, assign, rewind, reset, and swap.
+ SkPath original, source, anotherSource;
+ original.setSourcePath(&source);
original.moveTo(0, 0);
original.lineTo(1, 1);
REPORTER_ASSERT(reporter, original.getGenerationID() > 0);
+ REPORTER_ASSERT(reporter, original.getSourcePath() == &source);
- const SkPath copy(original);
+ uint32_t copyID, assignID;
+
+ // Test copy constructor. Copy generation ID, copy source path.
+ SkPath copy(original);
REPORTER_ASSERT(reporter, copy.getGenerationID() == original.getGenerationID());
+ REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath());
+ // Test assigment operator. Increment generation ID, copy source path.
SkPath assign;
+ assignID = assign.getGenerationID();
assign = original;
- REPORTER_ASSERT(reporter, assign.getGenerationID() != original.getGenerationID());
+ 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.getSourcePath() == original.getSourcePath());
+
+ // Test reset. Increment generation ID, don't touch source path.
+ assignID = assign.getGenerationID();
+ assign.reset();
+ REPORTER_ASSERT(reporter, assign.getGenerationID() > assignID);
+ REPORTER_ASSERT(reporter, assign.getSourcePath() == original.getSourcePath());
+
+ // Test swap. Increment both generation IDs, swap source paths.
+ copy.setSourcePath(&anotherSource);
+ copyID = copy.getGenerationID();
+ assignID = assign.getGenerationID();
+ copy.swap(assign);
+ 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
}
« no previous file with comments | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698