| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 | 9 |
| 10 #include "SkDashPathEffect.h" | 10 #include "SkDashPathEffect.h" |
| 11 #include "SkWriteBuffer.h" | 11 #include "SkWriteBuffer.h" |
| 12 | 12 |
| 13 // crbug.com/348821 was rooted in SkDashPathEffect refusing to flatten and unfla
tten itself when | 13 // crbug.com/348821 was rooted in SkDashPathEffect refusing to flatten and unfla
tten itself when |
| 14 // fInitialDashLength < 0 (a signal the effect is nonsense). Here we test that
it flattens. | 14 // fInitialDashLength < 0 (a signal the effect is nonsense). Here we test that
it flattens. |
| 15 | 15 |
| 16 DEF_TEST(DashPathEffectTest_crbug_348821, r) { | 16 DEF_TEST(DashPathEffectTest_crbug_348821, r) { |
| 17 SkScalar intervals[] = { 1.76934361e+36f, 2.80259693e-45f }; // Values from
bug. | 17 SkScalar intervals[] = { 1.76934361e+36f, 2.80259693e-45f }; // Values from
bug. |
| 18 const int count = 2; | 18 const int count = 2; |
| 19 SkScalar phase = SK_ScalarInfinity; // Used to force the bad fInitialDashLe
ngth = -1 path. | 19 SkScalar phase = SK_ScalarInfinity; // Used to force the bad fInitialDashLe
ngth = -1 path. |
| 20 SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, coun
t, phase)); | 20 SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, coun
t, phase)); |
| 21 | 21 |
| 22 // NULL -> refuses to work with flattening framework. | 22 // nullptr -> refuses to work with flattening framework. |
| 23 REPORTER_ASSERT(r, dash->getFactory() != NULL); | 23 REPORTER_ASSERT(r, dash->getFactory() != nullptr); |
| 24 | 24 |
| 25 SkWriteBuffer buffer; | 25 SkWriteBuffer buffer; |
| 26 buffer.writeFlattenable(dash); | 26 buffer.writeFlattenable(dash); |
| 27 REPORTER_ASSERT(r, buffer.bytesWritten() > 12); // We'd write 12 if broken,
>=40 if not. | 27 REPORTER_ASSERT(r, buffer.bytesWritten() > 12); // We'd write 12 if broken,
>=40 if not. |
| 28 } | 28 } |
| 29 | 29 |
| 30 // Test out the asPoint culling behavior. | 30 // Test out the asPoint culling behavior. |
| 31 DEF_TEST(DashPathEffectTest_asPoints, r) { | 31 DEF_TEST(DashPathEffectTest_asPoints, r) { |
| 32 | 32 |
| 33 const SkScalar intervals[] = { 1.0f, 1.0f }; | 33 const SkScalar intervals[] = { 1.0f, 1.0f }; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 if (i < 2) { | 79 if (i < 2) { |
| 80 REPORTER_ASSERT(r, actualResult == testCases[j].fExpectedRes
ult); | 80 REPORTER_ASSERT(r, actualResult == testCases[j].fExpectedRes
ult); |
| 81 } else { | 81 } else { |
| 82 // On the third pass all the lines should be outside the tra
nslated cull rect | 82 // On the third pass all the lines should be outside the tra
nslated cull rect |
| 83 REPORTER_ASSERT(r, !actualResult); | 83 REPORTER_ASSERT(r, !actualResult); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 } | 88 } |
| OLD | NEW |