Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b2a9c70

Browse files
committed
make engine tests pass
1 parent 000c34b commit b2a9c70

File tree

9 files changed

+382
-346
lines changed

9 files changed

+382
-346
lines changed

lib/ui/hash_codes.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const _HashEnd _hashEnd = _HashEnd();
1515
class _Jenkins {
1616
static int combine(int hash, Object? o) {
1717
assert(o is! Iterable);
18-
hash = 0x1fffffff & (hash + o!.hashCode);
18+
hash = 0x1fffffff & (hash + o.hashCode);
1919
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
2020
return hash ^ (hash >> 6);
2121
}

lib/ui/hooks.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ String? _localeClosure() {
6161
if (window.locale == null) {
6262
return null;
6363
}
64-
return window.locale!.toString();
64+
return window.locale.toString();
6565
}
6666

6767
@pragma('vm:entry-point')

lib/ui/painting.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2354,7 +2354,11 @@ class PathMetricIterator implements Iterator<PathMetric> {
23542354
PathMetric get current {
23552355
final PathMetric? currentMetric = _pathMetric;
23562356
if (currentMetric == null) {
2357-
throw RangeError('No more path metrics.');
2357+
throw RangeError(
2358+
'PathMetricIterator is not pointing to a PathMetric. This can happen in two situations:\n'
2359+
'- The iteration has not started yet. If so, call "moveNext" to start iteration.'
2360+
'- The iterator ran out of elements. If so, check that "moveNext" returns true prior to calling "current".'
2361+
);
23582362
}
23592363
return currentMetric;
23602364
}

lib/ui/text.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,9 +2021,10 @@ class Paragraph extends NativeFieldWrapperClass2 {
20212021
/// to repeatedly call this. Instead, cache the results.
20222022
List<LineMetrics> computeLineMetrics() {
20232023
final Float64List encoded = _computeLineMetrics();
2024+
final int count = encoded.length ~/ 9;
20242025
int position = 0;
20252026
final List<LineMetrics> metrics = <LineMetrics>[];
2026-
for (int index = 0; index < metrics.length; index += 1) {
2027+
for (int index = 0; index < count; index += 1) {
20272028
metrics.add(LineMetrics(
20282029
hardBreak: encoded[position++] != 0,
20292030
ascent: encoded[position++],

testing/dart/image_filter_test.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ void main() {
8686
checkEquality(B, B);
8787
});
8888

89-
test('ImageFilter - nulls', () async {
90-
final Paint paint = Paint()..imageFilter = ImageFilter.blur(sigmaX: null, sigmaY: null);
91-
expect(paint.imageFilter, equals(ImageFilter.blur()));
92-
93-
expect(() => ImageFilter.matrix(null), throwsNoSuchMethodError);
94-
});
95-
9689
void checkBytes(Uint32List bytes, int center, int side, int corner) {
9790
expect(bytes[0], equals(corner));
9891
expect(bytes[1], equals(side));

testing/dart/path_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void main() {
115115

116116
// basic tests on horizontal line
117117
final PathMetrics simpleHorizontalMetrics = simpleHorizontalLine.computeMetrics();
118-
expect(simpleHorizontalMetrics.iterator.current, isNull);
118+
expect(() => simpleHorizontalMetrics.iterator.current, throwsRangeError);
119119
expect(simpleHorizontalMetrics.iterator.moveNext(), isTrue);
120120
expect(simpleHorizontalMetrics.iterator.current, isNotNull);
121121
expect(simpleHorizontalMetrics.iterator.current.length, equals(10.0));
@@ -128,11 +128,11 @@ void main() {
128128
expect(posTan.angle, equals(0.0));
129129

130130
expect(simpleHorizontalMetrics.iterator.moveNext(), isFalse);
131-
expect(simpleHorizontalMetrics.iterator.current, isNull);
131+
expect(() => simpleHorizontalMetrics.iterator.current, throwsRangeError);
132132

133133
// test with forceClosed
134134
final PathMetrics simpleMetricsClosed = simpleHorizontalLine.computeMetrics(forceClosed: true);
135-
expect(simpleMetricsClosed.iterator.current, isNull);
135+
expect(() => simpleHorizontalMetrics.iterator.current, throwsRangeError);
136136
expect(simpleMetricsClosed.iterator.moveNext(), isTrue);
137137
expect(simpleMetricsClosed.iterator.current, isNotNull);
138138
expect(simpleMetricsClosed.iterator.current.length, equals(20.0)); // because we forced close
@@ -163,15 +163,15 @@ void main() {
163163
..lineTo(10.0, 15.0);
164164

165165
final PathMetrics multiContourMetric = multiContour.computeMetrics();
166-
expect(multiContourMetric.iterator.current, isNull);
166+
expect(() => multiContourMetric.iterator.current, throwsRangeError);
167167
expect(multiContourMetric.iterator.moveNext(), isTrue);
168168
expect(multiContourMetric.iterator.current, isNotNull);
169169
expect(multiContourMetric.iterator.current.length, equals(10.0));
170170
expect(multiContourMetric.iterator.moveNext(), isTrue);
171171
expect(multiContourMetric.iterator.current, isNotNull);
172172
expect(multiContourMetric.iterator.current.length, equals(5.0));
173173
expect(multiContourMetric.iterator.moveNext(), isFalse);
174-
expect(multiContourMetric.iterator.current, isNull);
174+
expect(() => multiContourMetric.iterator.current, throwsRangeError);
175175
});
176176

177177
test('PathMetrics can remember lengths and isClosed', () {

0 commit comments

Comments
 (0)