Made some pixel tests fuzzy (#154680)
This is a forward fix for the failures seen in https://github.com/flutter/engine/pull/54714/checks?check_run_id=29742599916 on https://github.com/flutter/engine/pull/54714 issue: https://github.com/flutter/flutter/issues/127855
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:ui' as ui show ColorFilter, Image;
|
||||
import 'dart:ui' as ui show Color, ColorFilter, Image;
|
||||
|
||||
import 'package:fake_async/fake_async.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -14,6 +14,36 @@ import '../image_data.dart';
|
||||
import '../painting/mocks_for_image_cache.dart';
|
||||
import '../rendering/rendering_tester.dart';
|
||||
|
||||
/// Positive result if the colors would be mapped to the same argb8888 color.
|
||||
class _ColorMatcher extends Matcher {
|
||||
_ColorMatcher(this._target);
|
||||
|
||||
final ui.Color _target;
|
||||
|
||||
@override
|
||||
Description describe(Description description) {
|
||||
return description.add('matches "$_target"');
|
||||
}
|
||||
|
||||
@override
|
||||
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
|
||||
if (item is ui.Color) {
|
||||
return item.colorSpace == _target.colorSpace &&
|
||||
(item.a - _target.a).abs() <= (1 / 255) &&
|
||||
(item.r - _target.r).abs() <= (1 / 255) &&
|
||||
(item.g - _target.g).abs() <= (1 / 255) &&
|
||||
(item.b - _target.b).abs() <= (1 / 255);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Matcher _matchesColor(ui.Color color) {
|
||||
return _ColorMatcher(color);
|
||||
}
|
||||
|
||||
class TestCanvas implements Canvas {
|
||||
final List<Invocation> invocations = <Invocation>[];
|
||||
|
||||
@@ -326,7 +356,7 @@ void main() {
|
||||
expect(call.positionalArguments[3], isA<Paint>());
|
||||
final Paint paint = call.positionalArguments[3] as Paint;
|
||||
expect(paint.colorFilter, colorFilter);
|
||||
expect(paint.color, const Color(0x7F000000)); // 0.5 opacity
|
||||
expect(paint.color, _matchesColor(const Color(0x7F000000))); // 0.5 opacity
|
||||
expect(paint.filterQuality, FilterQuality.high);
|
||||
expect(paint.isAntiAlias, true);
|
||||
expect(paint.invertColors, isTrue);
|
||||
|
||||
Reference in New Issue
Block a user