aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2015-11-19 10:35:34 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-19 10:35:34 -0800
commit8d381022e72f49c2ad02c6fc3fbbb6f03c95bdf2 (patch)
tree1d14d6741d9ab09e34e23a6d493d8e70ef50a11e /tests
parentf38b0d86b888692f7d703916114781be43249600 (diff)
Fix nearly-vertical gradient assert
Use a SkScalarNearlyZero(dx) test instead of !SkScalarIsFinite(invDx). R=reed@google.com Review URL: https://codereview.chromium.org/1456783005
Diffstat (limited to 'tests')
-rw-r--r--tests/GradientTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp
index d0ea1f2b4d..8d73569f64 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -9,6 +9,7 @@
#include "SkColorShader.h"
#include "SkGradientShader.h"
#include "SkShader.h"
+#include "SkSurface.h"
#include "SkTemplates.h"
#include "Test.h"
@@ -196,8 +197,24 @@ static void TestGradientShaders(skiatest::Reporter* reporter) {
}
}
+static void test_nearly_vertical(skiatest::Reporter* reporter) {
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(200, 200));
+
+ const SkPoint pts[] = {{ 100, 50 }, { 100.0001f, 50000 }};
+ const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
+ const SkScalar pos[] = { 0, 1 };
+ SkAutoTUnref<SkShader> gradient(
+ SkGradientShader::CreateLinear(pts, colors, pos, 2, SkShader::kClamp_TileMode));
+
+ SkPaint paint;
+ paint.setShader(gradient);
+
+ surface->getCanvas()->drawPaint(paint);
+}
+
DEF_TEST(Gradient, reporter) {
TestGradientShaders(reporter);
TestConstantGradient(reporter);
test_big_grad(reporter);
+ test_nearly_vertical(reporter);
}