Commit e7fbee66 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Fix clip debugPaint (TextPainter RTL fallout) (#12026)

parent 4262c1e9
...@@ -1039,6 +1039,7 @@ abstract class _RenderCustomClip<T> extends RenderProxyBox { ...@@ -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,6 +260,10 @@ abstract class _TestRecordingCanvasMatcher extends Matcher { ...@@ -260,6 +260,10 @@ 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);
final StringBuffer description = new StringBuffer();
String prefixMessage = 'unexpectedly failed.';
bool result = false;
try {
if (object is _ContextPainterFunction) { if (object is _ContextPainterFunction) {
final _ContextPainterFunction function = object; final _ContextPainterFunction function = object;
function(context, Offset.zero); function(context, Offset.zero);
...@@ -280,14 +284,22 @@ abstract class _TestRecordingCanvasMatcher extends Matcher { ...@@ -280,14 +284,22 @@ abstract class _TestRecordingCanvasMatcher extends Matcher {
return false; return false;
} }
} }
final StringBuffer description = new StringBuffer(); result = _evaluatePredicates(canvas.invocations, description);
final bool 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 @@ ...@@ -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() { ...@@ -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;
});
} }
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