Commit 9dab2268 authored by Jacob Richman's avatar Jacob Richman Committed by GitHub

More toStringDeep and toString tests. (#11028)

parent 6841ab22
...@@ -39,6 +39,18 @@ void main() { ...@@ -39,6 +39,18 @@ void main() {
expect(interpolated.color, equals(side2.color.withOpacity(0.2))); expect(interpolated.color, equals(side2.color.withOpacity(0.2)));
}); });
test('BorderSide toString test', () {
final BorderSide side1 = const BorderSide();
final BorderSide side2 = side1.copyWith(
color: const Color(0xFF00FFFF),
width: 2.0,
style: BorderStyle.solid,
);
expect(side1.toString(), equals('BorderSide(Color(0xff000000), 1.0, BorderStyle.solid)'));
expect(side2.toString(), equals('BorderSide(Color(0xff00ffff), 2.0, BorderStyle.solid)'));
});
test('Border control test', () { test('Border control test', () {
final Border border1 = new Border.all(width: 4.0); final Border border1 = new Border.all(width: 4.0);
final Border border2 = Border.lerp(null, border1, 0.25); final Border border2 = Border.lerp(null, border1, 0.25);
...@@ -54,6 +66,15 @@ void main() { ...@@ -54,6 +66,15 @@ void main() {
expect(border4.left.width, equals(2.0)); expect(border4.left.width, equals(2.0));
}); });
test('Border toString test', () {
expect(
new Border.all(width: 4.0).toString(),
equals(
'Border(BorderSide(Color(0xff000000), 4.0, BorderStyle.solid), BorderSide(Color(0xff000000), 4.0, BorderStyle.solid), BorderSide(Color(0xff000000), 4.0, BorderStyle.solid), BorderSide(Color(0xff000000), 4.0, BorderStyle.solid))',
),
);
});
test('BoxShadow control test', () { test('BoxShadow control test', () {
final BoxShadow shadow1 = const BoxShadow(blurRadius: 4.0); final BoxShadow shadow1 = const BoxShadow(blurRadius: 4.0);
final BoxShadow shadow2 = BoxShadow.lerp(null, shadow1, 0.25); final BoxShadow shadow2 = BoxShadow.lerp(null, shadow1, 0.25);
...@@ -77,6 +98,10 @@ void main() { ...@@ -77,6 +98,10 @@ void main() {
expect(shadowList, equals(<BoxShadow>[shadow4, shadow1.scale(0.5)])); expect(shadowList, equals(<BoxShadow>[shadow4, shadow1.scale(0.5)]));
}); });
test('BoxShadow toString test', () {
expect(const BoxShadow(blurRadius: 4.0).toString(), equals('BoxShadow(Color(0xff000000), Offset(0.0, 0.0), 4.0, 0.0)'));
});
test('LinearGradient scale test', () { test('LinearGradient scale test', () {
final LinearGradient testGradient = const LinearGradient( final LinearGradient testGradient = const LinearGradient(
begin: FractionalOffset.bottomRight, begin: FractionalOffset.bottomRight,
...@@ -130,4 +155,20 @@ void main() { ...@@ -130,4 +155,20 @@ void main() {
], ],
)); ));
}); });
test('LinearGradient toString', () {
expect(
const LinearGradient(
begin: FractionalOffset.topLeft,
end: FractionalOffset.bottomLeft,
colors: const <Color>[
const Color(0x33333333),
const Color(0x66666666),
],
).toString(),
equals(
'LinearGradient(FractionalOffset(0.0, 0.0), FractionalOffset(0.0, 1.0), [Color(0x33333333), Color(0x66666666)], null, TileMode.clamp)',
),
);
});
} }
...@@ -63,4 +63,19 @@ void main() { ...@@ -63,4 +63,19 @@ void main() {
logo = FlutterLogoDecoration.lerp(start, end, 0.5); logo = FlutterLogoDecoration.lerp(start, end, 0.5);
expect(logo.style, end.style); expect(logo.style, end.style);
}); });
test('FlutterLogoDecoration toString', () {
expect(
start.toString(),
equals(
'FlutterLogoDecoration(Color(0xff000000)/Color(0xffffffff) on Color(0xffd4f144), FlutterLogoStyle.stacked)'
),
);
expect(
FlutterLogoDecoration.lerp(null, end, 0.5).toString(),
equals(
'FlutterLogoDecoration(Color(0xffffffff)/Color(0xff000000) on Color(0xff81d4fa), FlutterLogoStyle.stacked, transition -1.0:0.5)',
),
);
});
} }
...@@ -9,6 +9,11 @@ import 'package:test/test.dart'; ...@@ -9,6 +9,11 @@ import 'package:test/test.dart';
void main() { void main() {
test("TextStyle control test", () { test("TextStyle control test", () {
expect(const TextStyle(inherit: false).toString(), equals(
'inherit: false'));
expect(const TextStyle(inherit: true).toString(), equals(
'inherit: true'));
final TextStyle s1 = const TextStyle( final TextStyle s1 = const TextStyle(
fontSize: 10.0, fontSize: 10.0,
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
...@@ -20,6 +25,15 @@ void main() { ...@@ -20,6 +25,15 @@ void main() {
expect(s1.fontWeight, FontWeight.w800); expect(s1.fontWeight, FontWeight.w800);
expect(s1.height, 123.0); expect(s1.height, 123.0);
expect(s1, equals(s1)); expect(s1, equals(s1));
expect(
s1.toString(),
equals(
'inherit: true\n'
'size: 10.0\n'
'weight: 800\n'
'height: 123.0x',
),
);
final TextStyle s2 = s1.copyWith(color: const Color(0xFF00FF00), height: 100.0); final TextStyle s2 = s1.copyWith(color: const Color(0xFF00FF00), height: 100.0);
expect(s1.fontFamily, isNull); expect(s1.fontFamily, isNull);
...@@ -33,6 +47,16 @@ void main() { ...@@ -33,6 +47,16 @@ void main() {
expect(s2.height, 100.0); expect(s2.height, 100.0);
expect(s2.color, const Color(0xFF00FF00)); expect(s2.color, const Color(0xFF00FF00));
expect(s2, isNot(equals(s1))); expect(s2, isNot(equals(s1)));
expect(
s2.toString(),
equals(
'inherit: true\n'
'color: Color(0xff00ff00)\n'
'size: 10.0\n'
'weight: 800\n'
'height: 100.0x',
),
);
final TextStyle s3 = s1.apply(fontSizeFactor: 2.0, fontSizeDelta: -2.0, fontWeightDelta: -4); final TextStyle s3 = s1.apply(fontSizeFactor: 2.0, fontSizeDelta: -2.0, fontWeightDelta: -4);
expect(s1.fontFamily, isNull); expect(s1.fontFamily, isNull);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import 'dart:ui' as ui show Image; import 'dart:ui' as ui show Image;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:test/test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'rendering_tester.dart'; import 'rendering_tester.dart';
...@@ -16,6 +16,9 @@ class SquareImage implements ui.Image { ...@@ -16,6 +16,9 @@ class SquareImage implements ui.Image {
@override @override
int get height => 10; int get height => 10;
@override
String toString() => '[$width\u00D7$height]';
@override @override
void dispose() { } void dispose() { }
} }
...@@ -27,6 +30,9 @@ class WideImage implements ui.Image { ...@@ -27,6 +30,9 @@ class WideImage implements ui.Image {
@override @override
int get height => 10; int get height => 10;
@override
String toString() => '[$width\u00D7$height]';
@override @override
void dispose() { } void dispose() { }
} }
...@@ -38,6 +44,9 @@ class TallImage implements ui.Image { ...@@ -38,6 +44,9 @@ class TallImage implements ui.Image {
@override @override
int get height => 20; int get height => 20;
@override
String toString() => '[$width\u00D7$height]';
@override @override
void dispose() { } void dispose() { }
} }
...@@ -56,6 +65,18 @@ void main() { ...@@ -56,6 +65,18 @@ void main() {
expect(image.size.width, equals(25.0)); expect(image.size.width, equals(25.0));
expect(image.size.height, equals(25.0)); expect(image.size.height, equals(25.0));
expect(image, hasAGoodToStringDeep);
expect(
image.toStringDeep(),
equalsIgnoringHashCodes(
'RenderImage#00000 relayoutBoundary=up2 NEEDS-PAINT\n'
' parentData: <none> (can use size)\n'
' constraints: BoxConstraints(25.0<=w<=100.0, 25.0<=h<=100.0)\n'
' size: Size(25.0, 25.0)\n'
' image: [10×10]\n'
),
);
image = new RenderImage(image: new WideImage()); image = new RenderImage(image: new WideImage());
layout(image, layout(image,
constraints: const BoxConstraints( constraints: const BoxConstraints(
......
...@@ -181,10 +181,7 @@ void main() { ...@@ -181,10 +181,7 @@ void main() {
final RenderParagraph paragraph = new RenderParagraph( final RenderParagraph paragraph = new RenderParagraph(
const TextSpan(text: _kText), const TextSpan(text: _kText),
); );
// TODO(jacobr): the toStringDeep method for RenderParagraph needs to be // TODO(jacobr): fix handling of text spans with line breaks.
// fixed to not emit a spurious line of trailing whitespace and fixed so
// that the \n within the TextSpan content does not interfere with the box
// border.
expect(paragraph, isNot(hasAGoodToStringDeep)); expect(paragraph, isNot(hasAGoodToStringDeep));
expect( expect(
paragraph.toStringDeep(), paragraph.toStringDeep(),
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:test/test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'rendering_tester.dart'; import 'rendering_tester.dart';
...@@ -13,8 +13,39 @@ void main() { ...@@ -13,8 +13,39 @@ void main() {
final RenderViewport root = new RenderViewport( final RenderViewport root = new RenderViewport(
offset: new ViewportOffset.zero(), offset: new ViewportOffset.zero(),
); );
// TODO(jacobr): remove extra trailing line break.
expect(root, isNot(hasAGoodToStringDeep));
expect(
root.toStringDeep(),
equalsIgnoringHashCodes(
'RenderViewport#00000 NEEDS-LAYOUT NEEDS-PAINT DETACHED\n'
' │ parentData: null\n'
' │ constraints: null\n'
' │ size: MISSING\n'
' │ AxisDirection.down\n'
' │ offset: _FixedViewportOffset#da23b(offset: 0.0)\n'
' │ anchor: 0.0\n'
'\n'
),
);
layout(root); layout(root);
root.offset = new ViewportOffset.fixed(900.0); root.offset = new ViewportOffset.fixed(900.0);
// TODO(jacobr): remove extra trailing line break.
expect(root, isNot(hasAGoodToStringDeep));
expect(
root.toStringDeep(),
equalsIgnoringHashCodes(
'RenderViewport#00000 NEEDS-LAYOUT NEEDS-PAINT\n'
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │ AxisDirection.down\n'
' │ offset: _FixedViewportOffset#00000(offset: 900.0)\n'
' │ anchor: 0.0\n'
'\n',
),
);
pumpFrame(); pumpFrame();
}); });
...@@ -30,11 +61,95 @@ void main() { ...@@ -30,11 +61,95 @@ void main() {
new RenderSliverToBoxAdapter(child: e = new RenderSizedBox(const Size(100.0, 400.0))), new RenderSliverToBoxAdapter(child: e = new RenderSizedBox(const Size(100.0, 400.0))),
], ],
); );
expect(root, hasAGoodToStringDeep);
layout(root); layout(root);
expect(root.size.width, equals(800.0)); expect(root.size.width, equals(800.0));
expect(root.size.height, equals(600.0)); expect(root.size.height, equals(600.0));
expect(root, hasAGoodToStringDeep);
expect(
root.toStringDeep(),
equalsIgnoringHashCodes(
'RenderViewport#00000 NEEDS-PAINT\n'
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │ AxisDirection.down\n'
' │ offset: _FixedViewportOffset#00000(offset: 0.0)\n'
' │ anchor: 0.0\n'
' │\n'
' ├─center child: RenderSliverToBoxAdapter#00000 relayoutBoundary=up1 NEEDS-PAINT\n'
' │ │ parentData: paintOffset=Offset(0.0, 0.0) (can use size)\n'
' │ │ constraints: SliverConstraints(AxisDirection.down,\n'
' │ │ GrowthDirection.forward, ScrollDirection.idle, scrollOffset:\n'
' │ │ 0.0, remainingPaintExtent: 600.0, crossAxisExtent: 800.0,\n'
' │ │ viewportMainAxisExtent: 600.0)\n'
' │ │ geometry: SliverGeometry(scrollExtent: 400.0, paintExtent: 400.0,\n'
' │ │ maxPaintExtent: 400.0, )\n'
' │ │\n'
' │ └─child: RenderSizedBox#00000 NEEDS-PAINT\n'
' │ parentData: paintOffset=Offset(0.0, -0.0) (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, 0.0<=h<=Infinity)\n'
' │ size: Size(800.0, 400.0)\n'
' │\n'
' ├─child 1: RenderSliverToBoxAdapter#00000 relayoutBoundary=up1 NEEDS-PAINT\n'
' │ │ parentData: paintOffset=Offset(0.0, 400.0) (can use size)\n'
' │ │ constraints: SliverConstraints(AxisDirection.down,\n'
' │ │ GrowthDirection.forward, ScrollDirection.idle, scrollOffset:\n'
' │ │ 0.0, remainingPaintExtent: 200.0, crossAxisExtent: 800.0,\n'
' │ │ viewportMainAxisExtent: 600.0)\n'
' │ │ geometry: SliverGeometry(scrollExtent: 400.0, paintExtent: 200.0,\n'
' │ │ maxPaintExtent: 400.0, hasVisualOverflow: true, )\n'
' │ │\n'
' │ └─child: RenderSizedBox#00000 NEEDS-PAINT\n'
' │ parentData: paintOffset=Offset(0.0, -0.0) (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, 0.0<=h<=Infinity)\n'
' │ size: Size(800.0, 400.0)\n'
' │\n'
' ├─child 2: RenderSliverToBoxAdapter#00000 relayoutBoundary=up1 NEEDS-PAINT\n'
' │ │ parentData: paintOffset=Offset(0.0, 600.0) (can use size)\n'
' │ │ constraints: SliverConstraints(AxisDirection.down,\n'
' │ │ GrowthDirection.forward, ScrollDirection.idle, scrollOffset:\n'
' │ │ 0.0, remainingPaintExtent: 0.0, crossAxisExtent: 800.0,\n'
' │ │ viewportMainAxisExtent: 600.0)\n'
' │ │ geometry: SliverGeometry(scrollExtent: 400.0, hidden,\n'
' │ │ maxPaintExtent: 400.0, hasVisualOverflow: true, )\n'
' │ │\n'
' │ └─child: RenderSizedBox#00000 NEEDS-PAINT\n'
' │ parentData: paintOffset=Offset(0.0, -0.0) (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, 0.0<=h<=Infinity)\n'
' │ size: Size(800.0, 400.0)\n'
' │\n'
' ├─child 3: RenderSliverToBoxAdapter#00000 relayoutBoundary=up1 NEEDS-PAINT\n'
' │ │ parentData: paintOffset=Offset(0.0, 600.0) (can use size)\n'
' │ │ constraints: SliverConstraints(AxisDirection.down,\n'
' │ │ GrowthDirection.forward, ScrollDirection.idle, scrollOffset:\n'
' │ │ 0.0, remainingPaintExtent: 0.0, crossAxisExtent: 800.0,\n'
' │ │ viewportMainAxisExtent: 600.0)\n'
' │ │ geometry: SliverGeometry(scrollExtent: 400.0, hidden,\n'
' │ │ maxPaintExtent: 400.0, hasVisualOverflow: true, )\n'
' │ │\n'
' │ └─child: RenderSizedBox#00000 NEEDS-PAINT\n'
' │ parentData: paintOffset=Offset(0.0, -0.0) (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, 0.0<=h<=Infinity)\n'
' │ size: Size(800.0, 400.0)\n'
' │\n'
' └─child 4: RenderSliverToBoxAdapter#00000 relayoutBoundary=up1 NEEDS-PAINT\n'
' │ parentData: paintOffset=Offset(0.0, 600.0) (can use size)\n'
' │ constraints: SliverConstraints(AxisDirection.down,\n'
' │ GrowthDirection.forward, ScrollDirection.idle, scrollOffset:\n'
' │ 0.0, remainingPaintExtent: 0.0, crossAxisExtent: 800.0,\n'
' │ viewportMainAxisExtent: 600.0)\n'
' │ geometry: SliverGeometry(scrollExtent: 400.0, hidden,\n'
' │ maxPaintExtent: 400.0, hasVisualOverflow: true, )\n'
' │\n'
' └─child: RenderSizedBox#00000 NEEDS-PAINT\n'
' parentData: paintOffset=Offset(0.0, -0.0) (can use size)\n'
' constraints: BoxConstraints(w=800.0, 0.0<=h<=Infinity)\n'
' size: Size(800.0, 400.0)\n',
),
);
expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 0.0)); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 0.0));
expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 400.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 400.0));
expect(c.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 600.0)); expect(c.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 600.0));
...@@ -278,6 +393,8 @@ void main() { ...@@ -278,6 +393,8 @@ void main() {
final RenderShrinkWrappingViewport root = new RenderShrinkWrappingViewport( final RenderShrinkWrappingViewport root = new RenderShrinkWrappingViewport(
offset: new ViewportOffset.zero(), offset: new ViewportOffset.zero(),
); );
// TODO(jacobr): remove extra trailing line break.
expect(root, isNot(hasAGoodToStringDeep));
layout(root); layout(root);
root.offset = new ViewportOffset.fixed(900.0); root.offset = new ViewportOffset.fixed(900.0);
pumpFrame(); pumpFrame();
...@@ -538,4 +655,17 @@ void main() { ...@@ -538,4 +655,17 @@ void main() {
expect(child.size.width, equals(450.0)); expect(child.size.width, equals(450.0));
expect(child.size.height, equals(600.0)); expect(child.size.height, equals(600.0));
}); });
test('SliverGeometry toString', () {
// TODO(jacobr): cleanup the spurious trailing commas from the toString for
// SliverGeometry.
expect(
const SliverGeometry().toString(),
equals('SliverGeometry(scrollExtent: 0.0, hidden, maxPaintExtent: 0.0, )'));
expect(
const SliverGeometry(scrollExtent: 100.0, paintExtent: 50.0, layoutExtent: 20.0, visible: true).toString(),
equals('SliverGeometry(scrollExtent: 100.0, paintExtent: 50.0, layoutExtent: 20.0, maxPaintExtent: 0.0, )'));
expect(const SliverGeometry(scrollExtent: 100.0, paintExtent: 0.0, layoutExtent: 20.0).toString(),
equals('SliverGeometry(scrollExtent: 100.0, hidden, layoutExtent: 20.0, maxPaintExtent: 0.0, )'));
});
} }
...@@ -20,6 +20,23 @@ void main() { ...@@ -20,6 +20,23 @@ void main() {
expect(table.size.width, equals(800.0)); expect(table.size.width, equals(800.0));
expect(table.size.height, equals(600.0)); expect(table.size.height, equals(600.0));
expect(table, hasAGoodToStringDeep);
expect(
table.toStringDeep(),
equalsIgnoringHashCodes(
'RenderTable#00000 NEEDS-PAINT\n'
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │ default column width: FlexColumnWidth(1.0)\n'
' │ table size: 0×0\n'
' │ column offsets: unknown\n'
' │ row offsets: []\n'
' │\n'
' └─table is empty\n',
),
);
}); });
test('Table control test; loose', () { test('Table control test; loose', () {
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('Wrap test; toStringDeep', () {
final RenderWrap renderWrap = new RenderWrap();
expect(renderWrap, hasAGoodToStringDeep);
expect(
renderWrap.toStringDeep(),
equalsIgnoringHashCodes(
'RenderWrap#00000 NEEDS-LAYOUT NEEDS-PAINT DETACHED\n'
' parentData: null\n'
' constraints: null\n'
' size: MISSING\n'
' direction: Axis.horizontal\n'
' alignment: WrapAlignment.start\n'
' spacing: 0.0\n'
' runAlignment: WrapAlignment.start\n'
' runSpacing: 0.0\n'
' crossAxisAlignment: 0.0\n'
),
);
});
}
...@@ -167,6 +167,25 @@ void main() { ...@@ -167,6 +167,25 @@ void main() {
expect(find.text('a'), findsNothing); expect(find.text('a'), findsNothing);
expect(find.text('A FOCUSED'), findsOneWidget); expect(find.text('A FOCUSED'), findsOneWidget);
expect(parentFocusScope, hasAGoodToStringDeep);
expect(
parentFocusScope.toStringDeep(),
equalsIgnoringHashCodes(
'FocusScopeNode#00000\n'
' focus: FocusNode#00000(FOCUSED)\n'
),
);
expect(WidgetsBinding.instance.focusManager.rootScope, hasAGoodToStringDeep);
expect(
WidgetsBinding.instance.focusManager.rootScope.toStringDeep(),
equalsIgnoringHashCodes(
'FocusScopeNode#00000\n'
' └─child 1: FocusScopeNode#00000\n'
' focus: FocusNode#00000(FOCUSED)\n'
),
);
parentFocusScope.setFirstFocus(childFocusScope); parentFocusScope.setFirstFocus(childFocusScope);
await tester.idle(); await tester.idle();
......
...@@ -21,13 +21,13 @@ void main() { ...@@ -21,13 +21,13 @@ void main() {
expect(overlay.key, equals(overlayKey)); expect(overlay.key, equals(overlayKey));
return new Container(); return new Container();
}, },
) ),
], ],
)); ));
expect(didBuild, isTrue); expect(didBuild, isTrue);
final RenderObject theater = overlayKey.currentContext.findRenderObject(); final RenderObject theater = overlayKey.currentContext.findRenderObject();
// TODO(jacobr): toStringDeep output is missing a trailing line break. // TODO(jacobr): toStringDeep is missing a trailing \n on the last line.
expect(theater, isNot(hasAGoodToStringDeep)); expect(theater, isNot(hasAGoodToStringDeep));
expect( expect(
theater.toStringDeep(), theater.toStringDeep(),
...@@ -71,7 +71,110 @@ void main() { ...@@ -71,7 +71,110 @@ void main() {
' └╌no offstage children', ' └╌no offstage children',
), ),
); );
});
// TODO(jacobr): add a test with offstage children. testWidgets('Offstage overlay', (WidgetTester tester) async {
final GlobalKey overlayKey = new GlobalKey();
await tester.pumpWidget(new Overlay(
key: overlayKey,
initialEntries: <OverlayEntry>[
new OverlayEntry(
opaque: true,
maintainState: true,
builder: (BuildContext context) => new Container(),
),
new OverlayEntry(
opaque: true,
maintainState: true,
builder: (BuildContext context) => new Container(),
),
new OverlayEntry(
opaque: true,
maintainState: true,
builder: (BuildContext context) => new Container(),
),
],
));
final RenderObject theater = overlayKey.currentContext.findRenderObject();
expect(theater, hasAGoodToStringDeep);
expect(
theater.toStringDeep(),
equalsIgnoringHashCodes(
'_RenderTheatre#00000\n'
' │ creator: _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n'
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │\n'
' ├─onstage: RenderStack#00000\n'
' ╎ │ creator: Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n'
' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n'
' ╎ │ size)\n'
' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ │ size: Size(800.0, 600.0)\n'
' ╎ │ alignment: FractionalOffset(0.0, 0.0)\n'
' ╎ │ fit: StackFit.expand\n'
' ╎ │ overflow: Overflow.clip\n'
' ╎ │\n'
' ╎ └─child 1: RenderLimitedBox#00000\n'
' ╎ │ creator: LimitedBox ← Container ←\n'
' ╎ │ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n'
' ╎ │ Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n'
' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n'
' ╎ │ size)\n'
' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ │ size: Size(800.0, 600.0)\n'
' ╎ │ maxWidth: 0.0\n'
' ╎ │ maxHeight: 0.0\n'
' ╎ │\n'
' ╎ └─child: RenderConstrainedBox#00000\n'
' ╎ creator: ConstrainedBox ← LimitedBox ← Container ←\n'
' ╎ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n'
' ╎ Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n'
' ╎ parentData: <none> (can use size)\n'
' ╎ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ size: Size(800.0, 600.0)\n'
' ╎ additionalConstraints: BoxConstraints(biggest)\n'
' ╎\n'
' ╎╌offstage 1: RenderLimitedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n'
' ╎ │ creator: LimitedBox ← Container ←\n'
' ╎ │ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n'
' ╎ │ TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n'
' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0)\n'
' ╎ │ constraints: null\n'
' ╎ │ size: MISSING\n'
' ╎ │ maxWidth: 0.0\n'
' ╎ │ maxHeight: 0.0\n'
' ╎ │\n'
' ╎ └─child: RenderConstrainedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n'
' ╎ creator: ConstrainedBox ← LimitedBox ← Container ←\n'
' ╎ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n'
' ╎ TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n'
' ╎ parentData: <none>\n'
' ╎ constraints: null\n'
' ╎ size: MISSING\n'
' ╎ additionalConstraints: BoxConstraints(biggest)\n'
' ╎\n'
' └╌offstage 2: RenderLimitedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n'
' │ creator: LimitedBox ← Container ←\n'
' │ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n'
' │ TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n'
' │ parentData: not positioned; offset=Offset(0.0, 0.0)\n'
' │ constraints: null\n'
' │ size: MISSING\n'
' │ maxWidth: 0.0\n'
' │ maxHeight: 0.0\n'
' │\n'
' └─child: RenderConstrainedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n'
' creator: ConstrainedBox ← LimitedBox ← Container ←\n'
' _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n'
' TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n'
' parentData: <none>\n'
' constraints: null\n'
' size: MISSING\n'
' additionalConstraints: BoxConstraints(biggest)\n'
),
);
}); });
} }
...@@ -57,8 +57,7 @@ void main() { ...@@ -57,8 +57,7 @@ void main() {
expect(find.text('3'), findsNothing); expect(find.text('3'), findsNothing);
final RenderObject viewport = tester.renderObject<RenderObject>(find.byType(SliverFillViewport).first); final RenderObject viewport = tester.renderObject<RenderObject>(find.byType(SliverFillViewport).first);
// Unfortunately this toStringDeep method currently has an extra line break // TODO(jacobr): toStringDeep has an extra trailing \n.
// at the end.
expect(viewport, isNot(hasAGoodToStringDeep)); expect(viewport, isNot(hasAGoodToStringDeep));
expect( expect(
viewport.toStringDeep(), viewport.toStringDeep(),
......
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