Skip to content

Commit 1e4bdda

Browse files
committed
Revert "Revert "Update paragraph_test.dart""
This reverts commit 138cbdd6dd74b479ecc3ce04f8a98b1b32dec374.
1 parent 4a44e84 commit 1e4bdda

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/flutter/test/rendering/paragraph_test.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,14 @@ void main() {
805805
expect(paintingContext.canvas.drawnRect, isNull);
806806
expect(paintingContext.canvas.drawnRectPaint, isNull);
807807
selectionParagraph(paragraph, const TextPosition(offset: 1), const TextPosition(offset: 5));
808+
809+
paintingContext.canvas.clear();
808810
paragraph.paint(paintingContext, Offset.zero);
809811
expect(paintingContext.canvas.drawnRect, const Rect.fromLTWH(14.0, 0.0, 56.0, 14.0));
810812
expect(paintingContext.canvas.drawnRectPaint!.style, PaintingStyle.fill);
811813
expect(paintingContext.canvas.drawnRectPaint!.color, selectionColor);
814+
// Selection highlight is painted before text.
815+
expect(paintingContext.canvas.drawnItemTypes, <Type>[Rect, ui.Paragraph]);
812816

813817
selectionParagraph(paragraph, const TextPosition(offset: 2), const TextPosition(offset: 4));
814818
paragraph.paint(paintingContext, Offset.zero);
@@ -1293,15 +1297,24 @@ void main() {
12931297
class MockCanvas extends Fake implements Canvas {
12941298
Rect? drawnRect;
12951299
Paint? drawnRectPaint;
1300+
List<Type> drawnItemTypes=<Type>[];
12961301

12971302
@override
12981303
void drawRect(Rect rect, Paint paint) {
12991304
drawnRect = rect;
13001305
drawnRectPaint = paint;
1306+
drawnItemTypes.add(Rect);
13011307
}
13021308

13031309
@override
1304-
void drawParagraph(ui.Paragraph paragraph, Offset offset) { }
1310+
void drawParagraph(ui.Paragraph paragraph, Offset offset) {
1311+
drawnItemTypes.add(ui.Paragraph);
1312+
}
1313+
void clear() {
1314+
drawnRect = null;
1315+
drawnRectPaint = null;
1316+
drawnItemTypes.clear();
1317+
}
13051318
}
13061319

13071320
class MockPaintingContext extends Fake implements PaintingContext {

0 commit comments

Comments
 (0)