flutter/packages/unit/test/widget/mimic_test.dart
Hixie 9047830c2e Rationalise the Key API.
Add a way of having keys based on numeric types or DateTimes by having a ValueKey<T> class.
Remove the redundant ways of declaring things, except for leaving one shorthand -- you can say `new Key(s)` instead of `new ValueKey<String>(s)`.
2015-08-28 13:17:34 -07:00

75 lines
1.5 KiB
Dart

import 'package:sky/widgets.dart';
import 'package:test/test.dart';
import 'widget_tester.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('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('outer'),
height: 10.0,
width: 10.0,
child: new Mimicable(
key: globalKey,
child: new Container(
key: new Key('inner'),
height: 10.0,
width: 10.0
)
)
),
new SizedBox(
height: 10.0,
width: 10.0,
child: new Mimic(original: globalKey)
)
]);
});
});
}