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

Unified Diff: tests/PaintTest.cpp

Issue 21949007: Remove operator== from SkPaint (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix lines breaking test. 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/views/animated/SkStaticTextView.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PaintTest.cpp
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index e25c7c3f08a8efe41d3168050dd15e32b6cb7b6a..5c8411cf4f9327c5db3a8defaf0716dc33d8a352 100644
--- a/tests/PaintTest.cpp
+++ b/tests/PaintTest.cpp
@@ -133,6 +133,15 @@ static void test_filterlevel(skiatest::Reporter* reporter) {
}
}
+bool SkPaintShallowEquals(const SkPaint& a, const SkPaint &b) {
reed1 2013/08/05 20:40:37 I think this guy should just test for the fields i
+#ifdef SK_BUILD_FOR_ANDROID
+ // Assumption: fGenerationID is the last struct member.
+ return !memcmp(&a, &b, SK_OFFSETOF(SkPaint, fGenerationID));
+#else
+ return !memcmp(&a, &b, sizeof(a));
+#endif
+}
+
static void test_copy(skiatest::Reporter* reporter) {
SkPaint paint;
// set a few member variables
@@ -147,19 +156,19 @@ static void test_copy(skiatest::Reporter* reporter) {
// copy the paint using the copy constructor and check they are the same
SkPaint copiedPaint = paint;
- REPORTER_ASSERT(reporter, paint == copiedPaint);
+ REPORTER_ASSERT(reporter, SkPaintShallowEquals(paint, copiedPaint));
#ifdef SK_BUILD_FOR_ANDROID
// the copy constructor should preserve the Generation ID
uint32_t paintGenID = paint.getGenerationID();
uint32_t copiedPaintGenID = copiedPaint.getGenerationID();
REPORTER_ASSERT(reporter, paintGenID == copiedPaintGenID);
- REPORTER_ASSERT(reporter, !memcmp(&paint, &copiedPaint, sizeof(paint)));
+ REPORTER_ASSERT(reporter, SkPaintShallowEquals(paint, copiedPaint));
#endif
// copy the paint using the equal operator and check they are the same
copiedPaint = paint;
- REPORTER_ASSERT(reporter, paint == copiedPaint);
+ REPORTER_ASSERT(reporter, SkPaintShallowEquals(paint, copiedPaint));
#ifdef SK_BUILD_FOR_ANDROID
// the equals operator should increment the Generation ID
@@ -173,8 +182,8 @@ static void test_copy(skiatest::Reporter* reporter) {
SkPaint cleanPaint;
paint.reset();
copiedPaint.reset();
- REPORTER_ASSERT(reporter, cleanPaint == paint);
- REPORTER_ASSERT(reporter, cleanPaint == copiedPaint);
+ REPORTER_ASSERT(reporter, SkPaintShallowEquals(cleanPaint, paint));
+ REPORTER_ASSERT(reporter, SkPaintShallowEquals(cleanPaint, copiedPaint));
#ifdef SK_BUILD_FOR_ANDROID
// the reset function should increment the Generation ID
« no previous file with comments | « src/views/animated/SkStaticTextView.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698