Set default clipBehavior to Clip.none and update tests (#20205)
This fixes https://github.com/flutter/flutter/issues/18057
This commit is contained in:
@@ -1046,6 +1046,11 @@ class _IsMethodCall extends Matcher {
|
||||
/// [RenderClipPath].
|
||||
const Matcher clipsWithBoundingRect = _ClipsWithBoundingRect();
|
||||
|
||||
/// Asserts that a [Finder] locates a single object whose root RenderObject is
|
||||
/// not a [RenderClipRect], [RenderClipRRect], [RenderClipOval], or
|
||||
/// [RenderClipPath].
|
||||
const Matcher hasNoImmediateClip = _MatchAnythingExceptClip();
|
||||
|
||||
/// Asserts that a [Finder] locates a single object whose root RenderObject
|
||||
/// is a [RenderClipRRect] with no clipper set, and border radius equals to
|
||||
/// [borderRadius], or an equivalent [RenderClipPath].
|
||||
@@ -1104,7 +1109,53 @@ Matcher rendersOnPhysicalShape({
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _MatchRenderObject<M extends RenderObject, T extends RenderObject> extends Matcher {
|
||||
abstract class _FailWithDescriptionMatcher extends Matcher {
|
||||
const _FailWithDescriptionMatcher();
|
||||
|
||||
bool failWithDescription(Map<dynamic, dynamic> matchState, String description) {
|
||||
matchState['failure'] = description;
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Description describeMismatch(
|
||||
dynamic item,
|
||||
Description mismatchDescription,
|
||||
Map<dynamic, dynamic> matchState,
|
||||
bool verbose
|
||||
) {
|
||||
return mismatchDescription.add(matchState['failure']);
|
||||
}
|
||||
}
|
||||
|
||||
class _MatchAnythingExceptClip extends _FailWithDescriptionMatcher {
|
||||
const _MatchAnythingExceptClip();
|
||||
|
||||
@override
|
||||
bool matches(covariant Finder finder, Map<dynamic, dynamic> matchState) {
|
||||
final Iterable<Element> nodes = finder.evaluate();
|
||||
if (nodes.length != 1)
|
||||
return failWithDescription(matchState, 'did not have a exactly one child element');
|
||||
final RenderObject renderObject = nodes.single.renderObject;
|
||||
|
||||
switch (renderObject.runtimeType) {
|
||||
case RenderClipPath:
|
||||
case RenderClipOval:
|
||||
case RenderClipRect:
|
||||
case RenderClipRRect:
|
||||
return failWithDescription(matchState, 'had a root render object of type: ${renderObject.runtimeType}');
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Description describe(Description description) {
|
||||
description.add('does not have a clip as an immediate child');
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _MatchRenderObject<M extends RenderObject, T extends RenderObject> extends _FailWithDescriptionMatcher {
|
||||
const _MatchRenderObject();
|
||||
|
||||
bool renderObjectMatchesT(Map<dynamic, dynamic> matchState, T renderObject);
|
||||
@@ -1125,21 +1176,6 @@ abstract class _MatchRenderObject<M extends RenderObject, T extends RenderObject
|
||||
|
||||
return failWithDescription(matchState, 'had a root render object of type: ${renderObject.runtimeType}');
|
||||
}
|
||||
|
||||
bool failWithDescription(Map<dynamic, dynamic> matchState, String description) {
|
||||
matchState['failure'] = description;
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Description describeMismatch(
|
||||
dynamic item,
|
||||
Description mismatchDescription,
|
||||
Map<dynamic, dynamic> matchState,
|
||||
bool verbose
|
||||
) {
|
||||
return mismatchDescription.add(matchState['failure']);
|
||||
}
|
||||
}
|
||||
|
||||
class _RendersOnPhysicalModel extends _MatchRenderObject<RenderPhysicalShape, RenderPhysicalModel> {
|
||||
|
||||
Reference in New Issue
Block a user