Migrate some tests from Block to ListView (#8055)
This commit is contained in:
parent
63964f4887
commit
8cde68d79f
@ -78,7 +78,7 @@ void main() {
|
|||||||
home: new Scaffold(
|
home: new Scaffold(
|
||||||
key: scaffoldKey,
|
key: scaffoldKey,
|
||||||
drawer: new Drawer(
|
drawer: new Drawer(
|
||||||
child: new Block(
|
child: new ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Text('drawer'),
|
new Text('drawer'),
|
||||||
new Container(
|
new Container(
|
||||||
@ -115,7 +115,7 @@ void main() {
|
|||||||
await tester.pump(const Duration(milliseconds: 10));
|
await tester.pump(const Duration(milliseconds: 10));
|
||||||
expect(textBox.localToGlobal(Point.origin).x, equals(textLeft));
|
expect(textBox.localToGlobal(Point.origin).x, equals(textLeft));
|
||||||
|
|
||||||
await gesture.moveBy(const Offset(0.0, -50.0));
|
await gesture.moveBy(const Offset(0.0, 50.0));
|
||||||
// drawer should be returning to visible
|
// drawer should be returning to visible
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
@ -62,19 +62,19 @@ void main() {
|
|||||||
await gesture.up();
|
await gesture.up();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Scroll anchor', (WidgetTester tester) async {
|
testWidgets('ListView reverse', (WidgetTester tester) async {
|
||||||
int first = 0;
|
int first = 0;
|
||||||
int second = 0;
|
int second = 0;
|
||||||
|
|
||||||
Widget buildBlock(ViewportAnchor scrollAnchor) {
|
Widget buildBlock({ bool reverse: false }) {
|
||||||
return new Block(
|
return new ListView(
|
||||||
key: new UniqueKey(),
|
key: new UniqueKey(),
|
||||||
scrollAnchor: scrollAnchor,
|
reverse: reverse,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new GestureDetector(
|
new GestureDetector(
|
||||||
onTap: () { ++first; },
|
onTap: () { ++first; },
|
||||||
child: new Container(
|
child: new Container(
|
||||||
height: 2000.0, // more than 600, the height of the test area
|
height: 350.0, // more than half the height of the test area
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
backgroundColor: const Color(0xFF00FF00)
|
backgroundColor: const Color(0xFF00FF00)
|
||||||
)
|
)
|
||||||
@ -83,7 +83,7 @@ void main() {
|
|||||||
new GestureDetector(
|
new GestureDetector(
|
||||||
onTap: () { ++second; },
|
onTap: () { ++second; },
|
||||||
child: new Container(
|
child: new Container(
|
||||||
height: 2000.0, // more than 600, the height of the test area
|
height: 350.0, // more than half the height of the test area
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
backgroundColor: const Color(0xFF0000FF)
|
backgroundColor: const Color(0xFF0000FF)
|
||||||
)
|
)
|
||||||
@ -93,32 +93,31 @@ void main() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await tester.pumpWidget(buildBlock(ViewportAnchor.end));
|
await tester.pumpWidget(buildBlock(reverse: true));
|
||||||
|
|
||||||
Point target = const Point(200.0, 200.0);
|
Point target = const Point(200.0, 200.0);
|
||||||
await tester.tapAt(target);
|
await tester.tapAt(target);
|
||||||
expect(first, equals(0));
|
expect(first, equals(0));
|
||||||
expect(second, equals(1));
|
expect(second, equals(1));
|
||||||
|
|
||||||
await tester.pumpWidget(buildBlock(ViewportAnchor.start));
|
await tester.pumpWidget(buildBlock(reverse: false));
|
||||||
|
|
||||||
await tester.tapAt(target);
|
await tester.tapAt(target);
|
||||||
expect(first, equals(1));
|
expect(first, equals(1));
|
||||||
expect(second, equals(1));
|
expect(second, equals(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Block scrollableKey', (WidgetTester tester) async {
|
testWidgets('ListView controller', (WidgetTester tester) async {
|
||||||
// Regression test for https://github.com/flutter/flutter/issues/4046
|
ScrollController controller = new ScrollController();
|
||||||
// The Block's scrollableKey needs to become its Scrollable descendant's key.
|
|
||||||
final GlobalKey<ScrollableState<Scrollable>> key = new GlobalKey<ScrollableState<Scrollable>>();
|
|
||||||
Widget buildBlock() {
|
Widget buildBlock() {
|
||||||
return new Block(
|
return new ListView(
|
||||||
scrollableKey: key,
|
controller: controller,
|
||||||
children: <Widget>[new Text("A"), new Text("B"), new Text("C")]
|
children: <Widget>[new Text("A"), new Text("B"), new Text("C")]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await tester.pumpWidget(buildBlock());
|
await tester.pumpWidget(buildBlock());
|
||||||
expect(key.currentState.scrollOffset, 0.0);
|
expect(controller.offset, equals(0.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('SliverBlockChildListDelegate.estimateMaxScrollOffset hits end', (WidgetTester tester) async {
|
testWidgets('SliverBlockChildListDelegate.estimateMaxScrollOffset hits end', (WidgetTester tester) async {
|
Loading…
x
Reference in New Issue
Block a user