Skip incorrect expectations in preparation for https://github.com/flutter/engine/pull/49786.

Bonus: improved error message when text style test fails
This commit is contained in:
Yegor 2024-01-17 11:22:19 -08:00 committed by GitHub
parent 8286f4993d
commit bac4d8391b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View file

@ -329,8 +329,10 @@ void main() {
expect(paint.color, const Color(0x7F000000)); // 0.5 opacity
expect(paint.filterQuality, FilterQuality.high);
expect(paint.isAntiAlias, true);
// TODO(craiglabenz): change to true when https://github.com/flutter/flutter/issues/88909 is fixed
expect(paint.invertColors, !kIsWeb || isCanvasKit);
// TODO(yjbanov): remove kIsWeb when https://github.com/flutter/engine/pull/49786 rolls in
if (!kIsWeb) {
expect(paint.invertColors, isTrue);
}
});
test('DecorationImage.toString', () async {

View file

@ -30,8 +30,7 @@ class _DartUiTextStyleToStringMatcher extends Matcher {
_propertyToString('letterSpacing', textStyle.letterSpacing),
_propertyToString('wordSpacing', textStyle.wordSpacing),
_propertyToString('height', textStyle.height),
// TODO(LongCatIsLooong): web support for
// https://github.com/flutter/flutter/issues/72521
// TODO(yjbanov): remove kIsWeb when https://github.com/flutter/engine/pull/49786 rolls in
if (!kIsWeb) _propertyToString('leadingDistribution', textStyle.leadingDistribution),
_propertyToString('locale', textStyle.locale),
_propertyToString('background', textStyle.background),
@ -74,12 +73,15 @@ class _DartUiTextStyleToStringMatcher extends Matcher {
@override
Description describeMismatch(dynamic item, Description mismatchDescription, Map<dynamic, dynamic> matchState, bool verbose) {
final Description description = super.describeMismatch(item, mismatchDescription, matchState, verbose);
final String itemAsString = item.toString();
final String? property = matchState['missingProperty'] as String?;
if (property != null) {
description.add("expect property: '$property'");
final int propertyIndex = propertiesInOrder.indexOf(property);
if (propertyIndex > 0) {
description.add(" after: '${propertiesInOrder[propertyIndex - 1]}'");
final String lastProperty = propertiesInOrder[propertyIndex - 1];
description.add(" after: '$lastProperty'\n");
description.add('but found: ${itemAsString.substring(itemAsString.indexOf(lastProperty))}');
}
description.add('\n');
}