Fix clip debugPaint (TextPainter RTL fallout) (#12026)
This commit is contained in:
parent
4262c1e9d3
commit
e7fbee6624
@ -1039,6 +1039,7 @@ abstract class _RenderCustomClip<T> extends RenderProxyBox {
|
|||||||
fontSize: 14.0,
|
fontSize: 14.0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
textDirection: TextDirection.rtl, // doesn't matter, it's one character
|
||||||
)
|
)
|
||||||
..layout();
|
..layout();
|
||||||
return true;
|
return true;
|
||||||
|
@ -260,34 +260,46 @@ abstract class _TestRecordingCanvasMatcher extends Matcher {
|
|||||||
bool matches(Object object, Map<dynamic, dynamic> matchState) {
|
bool matches(Object object, Map<dynamic, dynamic> matchState) {
|
||||||
final TestRecordingCanvas canvas = new TestRecordingCanvas();
|
final TestRecordingCanvas canvas = new TestRecordingCanvas();
|
||||||
final TestRecordingPaintingContext context = new TestRecordingPaintingContext(canvas);
|
final TestRecordingPaintingContext context = new TestRecordingPaintingContext(canvas);
|
||||||
if (object is _ContextPainterFunction) {
|
|
||||||
final _ContextPainterFunction function = object;
|
|
||||||
function(context, Offset.zero);
|
|
||||||
} else if (object is _CanvasPainterFunction) {
|
|
||||||
final _CanvasPainterFunction function = object;
|
|
||||||
function(canvas);
|
|
||||||
} else {
|
|
||||||
if (object is Finder) {
|
|
||||||
TestAsyncUtils.guardSync();
|
|
||||||
final Finder finder = object;
|
|
||||||
object = finder.evaluate().single.renderObject;
|
|
||||||
}
|
|
||||||
if (object is RenderObject) {
|
|
||||||
final RenderObject renderObject = object;
|
|
||||||
renderObject.paint(context, Offset.zero);
|
|
||||||
} else {
|
|
||||||
matchState[this] = 'was not one of the supported objects for the "paints" matcher.';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final StringBuffer description = new StringBuffer();
|
final StringBuffer description = new StringBuffer();
|
||||||
final bool result = _evaluatePredicates(canvas.invocations, description);
|
String prefixMessage = 'unexpectedly failed.';
|
||||||
|
bool result = false;
|
||||||
|
try {
|
||||||
|
if (object is _ContextPainterFunction) {
|
||||||
|
final _ContextPainterFunction function = object;
|
||||||
|
function(context, Offset.zero);
|
||||||
|
} else if (object is _CanvasPainterFunction) {
|
||||||
|
final _CanvasPainterFunction function = object;
|
||||||
|
function(canvas);
|
||||||
|
} else {
|
||||||
|
if (object is Finder) {
|
||||||
|
TestAsyncUtils.guardSync();
|
||||||
|
final Finder finder = object;
|
||||||
|
object = finder.evaluate().single.renderObject;
|
||||||
|
}
|
||||||
|
if (object is RenderObject) {
|
||||||
|
final RenderObject renderObject = object;
|
||||||
|
renderObject.paint(context, Offset.zero);
|
||||||
|
} else {
|
||||||
|
matchState[this] = 'was not one of the supported objects for the "paints" matcher.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = _evaluatePredicates(canvas.invocations, description);
|
||||||
|
if (!result)
|
||||||
|
prefixMessage = 'did not match the pattern.';
|
||||||
|
} catch (error, stack) {
|
||||||
|
prefixMessage = 'threw the following exception:';
|
||||||
|
description.writeln(error.toString());
|
||||||
|
description.write(stack.toString());
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
if (canvas.invocations.isNotEmpty)
|
if (canvas.invocations.isNotEmpty) {
|
||||||
description.write('The complete display list was:');
|
description.write('The complete display list was:');
|
||||||
for (RecordedInvocation call in canvas.invocations)
|
for (RecordedInvocation call in canvas.invocations)
|
||||||
description.write('\n * $call');
|
description.write('\n * $call');
|
||||||
matchState[this] = 'did not match the pattern.\n$description';
|
}
|
||||||
|
matchState[this] = '$prefixMessage\n$description';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
|
import '../rendering/mock_canvas.dart';
|
||||||
|
|
||||||
final List<String> log = <String>[];
|
final List<String> log = <String>[];
|
||||||
|
|
||||||
@ -223,4 +226,25 @@ void main() {
|
|||||||
expect(log, equals(<String>['a', 'tap', 'a', 'b', 'c', 'tap']));
|
expect(log, equals(<String>['a', 'tap', 'a', 'b', 'c', 'tap']));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('debugPaintSizeEnabled', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const ClipRect(
|
||||||
|
child: const Placeholder(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(tester.renderObject(find.byType(ClipRect)).paint, paints
|
||||||
|
..save()
|
||||||
|
..clipRect(rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 600.0))
|
||||||
|
..save()
|
||||||
|
..path() // Placeholder
|
||||||
|
..restore()
|
||||||
|
..restore()
|
||||||
|
);
|
||||||
|
debugPaintSizeEnabled = true;
|
||||||
|
expect(tester.renderObject(find.byType(ClipRect)).debugPaint, paints // ignore: INVALID_USE_OF_PROTECTED_MEMBER
|
||||||
|
..rect(rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 600.0))
|
||||||
|
..paragraph()
|
||||||
|
);
|
||||||
|
debugPaintSizeEnabled = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user