Merge pull request #842 from abarth/test_mimic
Add a basic test for Mimic tree movement
This commit is contained in:
commit
31a1886a5a
@ -40,6 +40,15 @@ class WidgetTester {
|
||||
TestApp _app;
|
||||
RenderView _renderView;
|
||||
|
||||
void walkWidgets(WidgetTreeWalker walker) {
|
||||
void walk(Widget widget) {
|
||||
walker(widget);
|
||||
widget.walkChildren(walk);
|
||||
}
|
||||
|
||||
_app.walkChildren(walk);
|
||||
}
|
||||
|
||||
void pumpFrame(WidgetBuilder builder) {
|
||||
_app.builder = builder;
|
||||
Component.flushBuild();
|
||||
|
74
packages/unit/test/widget/mimic_test.dart
Normal file
74
packages/unit/test/widget/mimic_test.dart
Normal file
@ -0,0 +1,74 @@
|
||||
import 'package:sky/widgets.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'build_utils.dart';
|
||||
|
||||
void main() {
|
||||
test('Mimic can track tree movements', () {
|
||||
GlobalKey globalKey = new GlobalKey();
|
||||
WidgetTester tester = new WidgetTester();
|
||||
|
||||
tester.pumpFrame(() {
|
||||
return new Flex([
|
||||
new Mimicable(
|
||||
key: globalKey,
|
||||
child: new Container(
|
||||
key: new Key.stringify('inner'),
|
||||
height: 10.0,
|
||||
width: 10.0
|
||||
)
|
||||
)
|
||||
]);
|
||||
});
|
||||
|
||||
bool mimicReady = false;
|
||||
|
||||
tester.pumpFrame(() {
|
||||
return new Flex([
|
||||
new Mimicable(
|
||||
key: globalKey,
|
||||
child: new Container(
|
||||
height: 10.0,
|
||||
width: 10.0
|
||||
)
|
||||
),
|
||||
new SizedBox(
|
||||
height: 10.0,
|
||||
width: 10.0,
|
||||
child: new Mimic(
|
||||
original: globalKey,
|
||||
onMimicReady: () {
|
||||
mimicReady = true;
|
||||
}
|
||||
)
|
||||
)
|
||||
]);
|
||||
});
|
||||
|
||||
expect(mimicReady, isTrue);
|
||||
|
||||
tester.pumpFrame(() {
|
||||
return new Flex([
|
||||
new Container(
|
||||
key: new Key.stringify('outer'),
|
||||
height: 10.0,
|
||||
width: 10.0,
|
||||
child: new Mimicable(
|
||||
key: globalKey,
|
||||
child: new Container(
|
||||
key: new Key.stringify('inner'),
|
||||
height: 10.0,
|
||||
width: 10.0
|
||||
)
|
||||
)
|
||||
),
|
||||
new SizedBox(
|
||||
height: 10.0,
|
||||
width: 10.0,
|
||||
child: new Mimic(original: globalKey)
|
||||
)
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user