Unverified Commit 62a4643e authored by Alex Li's avatar Alex Li Committed by GitHub

Add `rect` argument to `_ArcPaintPredicate` for tests (#125953)

As preparation for #125945.

The PR improves tests itself which allows the `arc` method to be available to check whether corresponding rects are drawn during tests.
parent 45cd2afc
...@@ -318,7 +318,7 @@ abstract class PaintPattern { ...@@ -318,7 +318,7 @@ abstract class PaintPattern {
/// painting has completed, not at the time of the call. If the same [Paint] /// painting has completed, not at the time of the call. If the same [Paint]
/// object is reused multiple times, then this may not match the actual /// object is reused multiple times, then this may not match the actual
/// arguments as they were seen by the method. /// arguments as they were seen by the method.
void arc({ Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style, StrokeCap? strokeCap }); void arc({ Rect? rect, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style, StrokeCap? strokeCap });
/// Indicates that a paragraph is expected next. /// Indicates that a paragraph is expected next.
/// ///
...@@ -769,8 +769,8 @@ class _TestRecordingCanvasPatternMatcher extends _TestRecordingCanvasMatcher imp ...@@ -769,8 +769,8 @@ class _TestRecordingCanvasPatternMatcher extends _TestRecordingCanvasMatcher imp
} }
@override @override
void arc({ Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style, StrokeCap? strokeCap }) { void arc({ Rect? rect, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style, StrokeCap? strokeCap }) {
_predicates.add(_ArcPaintPredicate(color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style, strokeCap: strokeCap)); _predicates.add(_ArcPaintPredicate(rect: rect, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style, strokeCap: strokeCap));
} }
@override @override
...@@ -1273,9 +1273,28 @@ class _LinePaintPredicate extends _DrawCommandPaintPredicate { ...@@ -1273,9 +1273,28 @@ class _LinePaintPredicate extends _DrawCommandPaintPredicate {
} }
class _ArcPaintPredicate extends _DrawCommandPaintPredicate { class _ArcPaintPredicate extends _DrawCommandPaintPredicate {
_ArcPaintPredicate({ Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style, StrokeCap? strokeCap }) : super( _ArcPaintPredicate({ this.rect, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style, StrokeCap? strokeCap }) : super(
#drawArc, 'an arc', 5, 4, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style, strokeCap: strokeCap, #drawArc, 'an arc', 5, 4, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style, strokeCap: strokeCap,
); );
final Rect? rect;
@override
void verifyArguments(List<dynamic> arguments) {
super.verifyArguments(arguments);
final Rect rectArgument = arguments[0] as Rect;
if (rect != null && rectArgument != rect) {
throw 'It called $methodName with a paint whose rect, $rectArgument, was not exactly the expected rect ($rect).';
}
}
@override
void debugFillDescription(List<String> description) {
super.debugFillDescription(description);
if (rect != null) {
description.add('rect $rect');
}
}
} }
class _ShadowPredicate extends _PaintPredicate { class _ShadowPredicate extends _PaintPredicate {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment