Add more tests of toStringDeep. (#10346)
* Add more tests of toStringDeep. These tests will help ensure toStringDeep behavior is not regressed by refactoring toStringDeep to support structured data.
This commit is contained in:
parent
e913a51c47
commit
56a556e69f
@ -40,18 +40,19 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
final String dump = tree.toStringDeep().replaceAll(new RegExp(r'#\d+'), '');
|
||||
expect(dump, equals('''TestTree
|
||||
├─child node A: TestTree
|
||||
final String dump =
|
||||
tree.toStringDeep().replaceAll(new RegExp(r'#\d+'), '#000');
|
||||
expect(dump, equals('''TestTree#000
|
||||
├─child node A: TestTree#000
|
||||
│
|
||||
├─child node B: TestTree
|
||||
│ ├─child node B1: TestTree
|
||||
├─child node B: TestTree#000
|
||||
│ ├─child node B1: TestTree#000
|
||||
│ │
|
||||
│ ├─child node B2: TestTree
|
||||
│ ├─child node B2: TestTree#000
|
||||
│ │
|
||||
│ ├─child node B3: TestTree
|
||||
│ ├─child node B3: TestTree#000
|
||||
│ │
|
||||
├─child node C: TestTree
|
||||
├─child node C: TestTree#000
|
||||
│
|
||||
'''));
|
||||
});
|
||||
|
@ -467,4 +467,40 @@ void main() {
|
||||
<Key>[null, key1, null, key2, null],
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Element diagnostics', (WidgetTester tester) async {
|
||||
GlobalKey key0;
|
||||
await tester.pumpWidget(new Column(
|
||||
key: key0 = new GlobalKey(),
|
||||
children: <Widget>[
|
||||
new Container(),
|
||||
new Container(key: new GlobalKey()),
|
||||
new Container(child: new Container()),
|
||||
new Container(key: new GlobalKey()),
|
||||
new Container(),
|
||||
],
|
||||
));
|
||||
final MultiChildRenderObjectElement element = key0.currentContext;
|
||||
|
||||
final String dump =
|
||||
element.toStringDeep().replaceAll(new RegExp(r'#\d+'), '#000');
|
||||
expect(dump, equals('''Column([GlobalKey#000]; renderObject: RenderFlex#000)
|
||||
├Container()
|
||||
│└LimitedBox(maxWidth: 0.0; maxHeight: 0.0; renderObject: RenderLimitedBox#000 relayoutBoundary=up1)
|
||||
│ └ConstrainedBox(BoxConstraints(biggest); renderObject: RenderConstrainedBox#000 relayoutBoundary=up2)
|
||||
├Container([GlobalKey#000])
|
||||
│└LimitedBox(maxWidth: 0.0; maxHeight: 0.0; renderObject: RenderLimitedBox#000 relayoutBoundary=up1)
|
||||
│ └ConstrainedBox(BoxConstraints(biggest); renderObject: RenderConstrainedBox#000 relayoutBoundary=up2)
|
||||
├Container()
|
||||
│└Container()
|
||||
│ └LimitedBox(maxWidth: 0.0; maxHeight: 0.0; renderObject: RenderLimitedBox#000 relayoutBoundary=up1)
|
||||
│ └ConstrainedBox(BoxConstraints(biggest); renderObject: RenderConstrainedBox#000 relayoutBoundary=up2)
|
||||
├Container([GlobalKey#000])
|
||||
│└LimitedBox(maxWidth: 0.0; maxHeight: 0.0; renderObject: RenderLimitedBox#000 relayoutBoundary=up1)
|
||||
│ └ConstrainedBox(BoxConstraints(biggest); renderObject: RenderConstrainedBox#000 relayoutBoundary=up2)
|
||||
└Container()
|
||||
└LimitedBox(maxWidth: 0.0; maxHeight: 0.0; renderObject: RenderLimitedBox#000 relayoutBoundary=up1)
|
||||
└ConstrainedBox(BoxConstraints(biggest); renderObject: RenderConstrainedBox#000 relayoutBoundary=up2)
|
||||
'''));
|
||||
});
|
||||
}
|
||||
|
@ -497,5 +497,55 @@ void main() {
|
||||
expect(table.row(0).length, 2);
|
||||
});
|
||||
|
||||
testWidgets('Table widget diagnostics', (WidgetTester tester) async {
|
||||
GlobalKey key0;
|
||||
final Table table = new Table(
|
||||
key: key0 = new GlobalKey(),
|
||||
defaultColumnWidth: const IntrinsicColumnWidth(),
|
||||
children: <TableRow>[
|
||||
new TableRow(
|
||||
children: <Widget>[
|
||||
const Text('A'), const Text('B'), const Text('C')
|
||||
]
|
||||
),
|
||||
new TableRow(
|
||||
children: <Widget>[
|
||||
const Text('D'), const Text('EEE'), const Text('F')
|
||||
]
|
||||
),
|
||||
new TableRow(
|
||||
children: <Widget>[
|
||||
const Text('G'), const Text('H'), const Text('III')
|
||||
]
|
||||
),
|
||||
]
|
||||
);
|
||||
await tester.pumpWidget(table);
|
||||
final RenderObjectElement element = key0.currentContext;
|
||||
|
||||
final String dump =
|
||||
element.toStringDeep().replaceAll(new RegExp(r'#\d+'), '#000');
|
||||
expect(dump, equals('''Table([GlobalKey#000]; renderObject: RenderTable#000)
|
||||
├Text("A")
|
||||
│└RichText(renderObject: RenderParagraph#000 relayoutBoundary=up1)
|
||||
├Text("B")
|
||||
│└RichText(renderObject: RenderParagraph#000 relayoutBoundary=up1)
|
||||
├Text("C")
|
||||
│└RichText(renderObject: RenderParagraph#000 relayoutBoundary=up1)
|
||||
├Text("D")
|
||||
│└RichText(renderObject: RenderParagraph#000 relayoutBoundary=up1)
|
||||
├Text("EEE")
|
||||
│└RichText(renderObject: RenderParagraph#000 relayoutBoundary=up1)
|
||||
├Text("F")
|
||||
│└RichText(renderObject: RenderParagraph#000 relayoutBoundary=up1)
|
||||
├Text("G")
|
||||
│└RichText(renderObject: RenderParagraph#000 relayoutBoundary=up1)
|
||||
├Text("H")
|
||||
│└RichText(renderObject: RenderParagraph#000 relayoutBoundary=up1)
|
||||
└Text("III")
|
||||
└RichText(renderObject: RenderParagraph#000 relayoutBoundary=up1)
|
||||
'''));
|
||||
});
|
||||
|
||||
// TODO(ianh): Test handling of TableCell object
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user