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 | |
108 // test that the rect was initialized | |
reed1
2013/03/04 19:11:47
Might get lucky if 'r' is already empty. Should we
djsollen
2013/03/04 19:47:04
Done.
| |
109 paint.measureText("", 0, &r, SkFloatToScalar(1.0f)); | |
110 REPORTER_ASSERT(reporter, r.isEmpty()); | |
111 | |
112 r.isetWH(10, 10); | |
113 | |
114 // test that our rect was reset | |
115 paint.measureText("", 0, &r, SkFloatToScalar(1.0f)); | |
116 REPORTER_ASSERT(reporter, r.isEmpty()); | |
117 } | |
118 | |
100 static void TestPaint(skiatest::Reporter* reporter) { | 119 static void TestPaint(skiatest::Reporter* reporter) { |
101 // TODO add general paint tests | 120 // TODO add general paint tests |
102 test_copy(reporter); | 121 test_copy(reporter); |
103 | 122 |
104 // regression tests | 123 // regression tests |
105 regression_cubic(reporter); | 124 regression_cubic(reporter); |
125 regression_measureText(reporter); | |
106 } | 126 } |
107 | 127 |
108 #include "TestClassDef.h" | 128 #include "TestClassDef.h" |
109 DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint) | 129 DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint) |
OLD | NEW |