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 {
fontSize: 14.0,
),
),
textDirection: TextDirection.rtl, // doesn't matter, it's one character
)
..layout();
return true;
......
......@@ -260,34 +260,46 @@ abstract class _TestRecordingCanvasMatcher extends Matcher {
bool matches(Object object, Map<dynamic, dynamic> matchState) {
final TestRecordingCanvas canvas = new TestRecordingCanvas();
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);
final StringBuffer description = new StringBuffer();
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 {
matchState[this] = 'was not one of the supported objects for the "paints" matcher.';
return false;
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;
}
final StringBuffer description = new StringBuffer();
final bool result = _evaluatePredicates(canvas.invocations, description);
if (!result) {
if (canvas.invocations.isNotEmpty)
if (canvas.invocations.isNotEmpty) {
description.write('The complete display list was:');
for (RecordedInvocation call in canvas.invocations)
description.write('\n * $call');
matchState[this] = 'did not match the pattern.\n$description';
}
matchState[this] = '$prefixMessage\n$description';
}
return result;
}
......
......@@ -4,6 +4,9 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import '../rendering/mock_canvas.dart';
final List<String> log = <String>[];
......@@ -223,4 +226,25 @@ void main() {
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