OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "SkPath.h" | 9 #include "SkPath.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter()); | 90 SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter()); |
91 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? | 91 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? |
92 SkScalarMul(paint.getStrokeWidth(), miter) : | 92 SkScalarMul(paint.getStrokeWidth(), miter) : |
93 paint.getStrokeWidth(); | 93 paint.getStrokeWidth(); |
94 maxR.inset(-inset, -inset); | 94 maxR.inset(-inset, -inset); |
95 | 95 |
96 // test that our stroke didn't explode | 96 // test that our stroke didn't explode |
97 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); | 97 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); |
98 } | 98 } |
99 | 99 |
| 100 // found and fixed for android: not initializing rect for string's of length 0 |
| 101 static void regression_measureText(skiatest::Reporter* reporter) { |
| 102 |
| 103 SkPaint paint; |
| 104 paint.setTextSize(SkFloatToScalar(12.0f)); |
| 105 |
| 106 SkRect r; |
| 107 r.setLTRB(SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN); |
| 108 |
| 109 // test that the rect was reset |
| 110 paint.measureText("", 0, &r, SkFloatToScalar(1.0f)); |
| 111 REPORTER_ASSERT(reporter, r.isEmpty()); |
| 112 } |
| 113 |
100 static void TestPaint(skiatest::Reporter* reporter) { | 114 static void TestPaint(skiatest::Reporter* reporter) { |
101 // TODO add general paint tests | 115 // TODO add general paint tests |
102 test_copy(reporter); | 116 test_copy(reporter); |
103 | 117 |
104 // regression tests | 118 // regression tests |
105 regression_cubic(reporter); | 119 regression_cubic(reporter); |
| 120 regression_measureText(reporter); |
106 } | 121 } |
107 | 122 |
108 #include "TestClassDef.h" | 123 #include "TestClassDef.h" |
109 DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint) | 124 DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint) |
OLD | NEW |