aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PaintTest.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-24 23:03:11 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-24 23:03:11 +0000
commite8807f49ed24be3933acf84c9ffa840a03fa43dc (patch)
treeb9c4a437bd0132a5e5636c900d4db50809e43632 /tests/PaintTest.cpp
parenta2b44dc5882856b6ed3670f370819ab39998ada8 (diff)
SkPaint: eliminate some dead bytes in 64-bit build.
+ memcpy-based copy constructor was hiding this gap -> manual copy constructor. + Split tests for finer-grained failures. BUG=skia: Committed: http://code.google.com/p/skia/source/detail?r=13856 Committed: http://code.google.com/p/skia/source/detail?r=13887 R=reed@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/203203003 git-svn-id: http://skia.googlecode.com/svn/trunk@13927 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PaintTest.cpp')
-rw-r--r--tests/PaintTest.cpp43
1 files changed, 15 insertions, 28 deletions
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index e7954b9136..c41e23ac54 100644
--- a/tests/PaintTest.cpp
+++ b/tests/PaintTest.cpp
@@ -59,7 +59,11 @@ static int find_first_zero(const uint16_t glyphs[], int count) {
return count;
}
-static void test_cmap(skiatest::Reporter* reporter) {
+DEF_TEST(Paint_cmap, reporter) {
+ // need to implement charsToGlyphs on other backends (e.g. linux, win)
+ // before we can run this tests everywhere
+ return;
+
static const int NGLYPHS = 64;
SkUnichar src[NGLYPHS];
@@ -101,8 +105,7 @@ static void test_cmap(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, NGLYPHS == nglyphs);
REPORTER_ASSERT(reporter, index == first);
- REPORTER_ASSERT(reporter,
- !memcmp(glyphs0, glyphs1, NGLYPHS * sizeof(uint16_t)));
+ REPORTER_ASSERT(reporter, 0 == memcmp(glyphs0, glyphs1, NGLYPHS * sizeof(uint16_t)));
if (contains) {
REPORTER_ASSERT(reporter, NGLYPHS == first);
} else {
@@ -113,7 +116,7 @@ static void test_cmap(skiatest::Reporter* reporter) {
}
// temparary api for bicubic, just be sure we can set/clear it
-static void test_filterlevel(skiatest::Reporter* reporter) {
+DEF_TEST(Paint_filterlevel, reporter) {
SkPaint p0, p1;
REPORTER_ASSERT(reporter,
@@ -137,7 +140,7 @@ static void test_filterlevel(skiatest::Reporter* reporter) {
}
}
-static void test_copy(skiatest::Reporter* reporter) {
+DEF_TEST(Paint_copy, reporter) {
SkPaint paint;
// set a few member variables
paint.setStyle(SkPaint::kStrokeAndFill_Style);
@@ -159,7 +162,7 @@ static void test_copy(skiatest::Reporter* reporter) {
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, paint == copiedPaint);
#endif
// copy the paint using the equal operator and check they are the same
@@ -171,7 +174,7 @@ static void test_copy(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, paint.getGenerationID() == paintGenID);
REPORTER_ASSERT(reporter, copiedPaint.getGenerationID() != copiedPaintGenID);
copiedPaintGenID = copiedPaint.getGenerationID(); // reset to the new value
- REPORTER_ASSERT(reporter, memcmp(&paint, &copiedPaint, sizeof(paint)));
+ REPORTER_ASSERT(reporter, paint == copiedPaint); // operator== ignores fGenerationID
#endif
// clean the paint and check they are back to their initial states
@@ -185,14 +188,15 @@ static void test_copy(skiatest::Reporter* reporter) {
// the reset function should increment the Generation ID
REPORTER_ASSERT(reporter, paint.getGenerationID() != paintGenID);
REPORTER_ASSERT(reporter, copiedPaint.getGenerationID() != copiedPaintGenID);
- REPORTER_ASSERT(reporter, memcmp(&cleanPaint, &paint, sizeof(cleanPaint)));
- REPORTER_ASSERT(reporter, memcmp(&cleanPaint, &copiedPaint, sizeof(cleanPaint)));
+ // operator== ignores fGenerationID
+ REPORTER_ASSERT(reporter, cleanPaint == paint);
+ REPORTER_ASSERT(reporter, cleanPaint == copiedPaint);
#endif
}
// found and fixed for webkit: mishandling when we hit recursion limit on
// mostly degenerate cubic flatness test
-static void regression_cubic(skiatest::Reporter* reporter) {
+DEF_TEST(Paint_regression_cubic, reporter) {
SkPath path, stroke;
SkPaint paint;
@@ -225,7 +229,7 @@ static void regression_cubic(skiatest::Reporter* reporter) {
}
// found and fixed for android: not initializing rect for string's of length 0
-static void regression_measureText(skiatest::Reporter* reporter) {
+DEF_TEST(Paint_regression_measureText, reporter) {
SkPaint paint;
paint.setTextSize(12.0f);
@@ -238,23 +242,6 @@ static void regression_measureText(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, r.isEmpty());
}
-DEF_TEST(Paint, reporter) {
- // TODO add general paint tests
- test_copy(reporter);
-
- // regression tests
- regression_cubic(reporter);
- regression_measureText(reporter);
-
- test_filterlevel(reporter);
-
- // need to implement charsToGlyphs on other backends (e.g. linux, win)
- // before we can run this tests everywhere
- if (false) {
- test_cmap(reporter);
- }
-}
-
#define ASSERT(expr) REPORTER_ASSERT(r, expr)
DEF_TEST(Paint_FlatteningTraits, r) {