Commit c9e4541c authored by Adam Barth's avatar Adam Barth Committed by GitHub

Port LazyBlock tests to ListView (#8026)

parent 1a61a76e
// Copyright 2016 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_test/flutter_test.dart';
import 'package:flutter/material.dart';
void main() {
testWidgets('Block inside LazyBlock', (WidgetTester tester) async {
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new Block(
children: <Widget>[
new Text('1'),
new Text('2'),
new Text('3'),
]
),
new Block(
children: <Widget>[
new Text('4'),
new Text('5'),
new Text('6'),
]
),
]
)
));
});
testWidgets('Underflowing LazyBlock should relayout for additional children', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/5950
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
]
)
));
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
new SizedBox(height: 200.0, child: new Text('200')),
]
)
));
expect(find.text('200'), findsOneWidget);
});
testWidgets('Underflowing LazyBlock contentExtent should track additional children', (WidgetTester tester) async {
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
]
)
));
StatefulElement statefulElement = tester.element(find.byType(Scrollable));
ScrollableState scrollable = statefulElement.state;
OverscrollWhenScrollableBehavior scrollBehavior = scrollable.scrollBehavior;
expect(scrollBehavior.contentExtent, equals(100.0));
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
new SizedBox(height: 200.0, child: new Text('200')),
]
)
));
expect(scrollBehavior.contentExtent, equals(300.0));
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
]
)
));
expect(scrollBehavior.contentExtent, equals(0.0));
});
testWidgets('Overflowing LazyBlock should relayout for missing children', (WidgetTester tester) async {
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new SizedBox(height: 300.0, child: new Text('300')),
new SizedBox(height: 400.0, child: new Text('400')),
]
)
));
expect(find.text('300'), findsOneWidget);
expect(find.text('400'), findsOneWidget);
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new SizedBox(height: 300.0, child: new Text('300')),
]
)
));
expect(find.text('300'), findsOneWidget);
expect(find.text('400'), findsNothing);
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
]
)
));
expect(find.text('300'), findsNothing);
expect(find.text('400'), findsNothing);
});
testWidgets('Overflowing LazyBlock should not relayout for additional children', (WidgetTester tester) async {
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new SizedBox(height: 300.0, child: new Text('300')),
new SizedBox(height: 400.0, child: new Text('400')),
]
)
));
expect(find.text('300'), findsOneWidget);
expect(find.text('400'), findsOneWidget);
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new SizedBox(height: 300.0, child: new Text('300')),
new SizedBox(height: 400.0, child: new Text('400')),
new SizedBox(height: 100.0, child: new Text('100')),
]
)
));
expect(find.text('300'), findsOneWidget);
expect(find.text('400'), findsOneWidget);
expect(find.text('100'), findsNothing);
StatefulElement statefulElement = tester.element(find.byType(Scrollable));
ScrollableState scrollable = statefulElement.state;
OverscrollWhenScrollableBehavior scrollBehavior = scrollable.scrollBehavior;
expect(scrollBehavior.contentExtent, equals(700.0));
});
testWidgets('Overflowing LazyBlock should become scrollable', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/5920
// When a LazyBlock's viewport hasn't overflowed, scrolling is disabled.
// When children are added that cause it to overflow, scrolling should
// be enabled.
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
]
)
));
StatefulElement statefulElement = tester.element(find.byType(Scrollable));
ScrollableState scrollable = statefulElement.state;
OverscrollWhenScrollableBehavior scrollBehavior = scrollable.scrollBehavior;
expect(scrollBehavior.isScrollable, isFalse);
await tester.pumpWidget(new LazyBlock(
delegate: new LazyBlockChildren(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
new SizedBox(height: 200.0, child: new Text('200')),
new SizedBox(height: 400.0, child: new Text('400')),
]
)
));
expect(scrollBehavior.isScrollable, isTrue);
});
}
......@@ -8,35 +8,24 @@ import 'package:flutter/material.dart';
const double kHeight = 10.0;
const double kFlingOffset = kHeight * 20.0;
class TestDelegate extends LazyBlockDelegate {
@override
Widget buildItem(BuildContext context, int index) {
void main() {
testWidgets('Flings don\'t stutter', (WidgetTester tester) async {
await tester.pumpWidget(new ListView.builder(
itemBuilder: (BuildContext context, int index) {
return new Container(height: kHeight);
}
},
));
@override
double estimateTotalExtent(int firstIndex, int lastIndex, double minOffset, double firstStartOffset, double lastEndOffset) {
return double.INFINITY;
double getCurrentOffset() {
return tester.state<Scrollable2State>(find.byType(Scrollable2)).position.pixels;
}
@override
bool shouldRebuild(LazyBlockDelegate oldDelegate) => false;
}
double currentOffset;
void main() {
testWidgets('Flings don\'t stutter', (WidgetTester tester) async {
await tester.pumpWidget(new LazyBlock(
delegate: new TestDelegate(),
onScroll: (double scrollOffset) { currentOffset = scrollOffset; },
));
await tester.fling(find.byType(LazyBlock), const Offset(0.0, -kFlingOffset), 1000.0);
expect(currentOffset, kFlingOffset);
await tester.fling(find.byType(ListView), const Offset(0.0, -kFlingOffset), 1000.0);
expect(getCurrentOffset(), kFlingOffset);
while (tester.binding.transientCallbackCount > 0) {
double lastOffset = currentOffset;
double lastOffset = getCurrentOffset();
await tester.pump(const Duration(milliseconds: 20));
expect(currentOffset, greaterThan(lastOffset));
expect(getCurrentOffset(), greaterThan(lastOffset));
}
}, skip: true); // see https://github.com/flutter/flutter/issues/5339
}
// Copyright 2016 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_test/flutter_test.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
testWidgets('Nested ListView with shrinkWrap', (WidgetTester tester) async {
await tester.pumpWidget(new ListView(
shrinkWrap: true,
children: <Widget>[
new ListView(
shrinkWrap: true,
children: <Widget>[
new Text('1'),
new Text('2'),
new Text('3'),
],
),
new ListView(
shrinkWrap: true,
children: <Widget>[
new Text('4'),
new Text('5'),
new Text('6'),
],
),
],
));
});
testWidgets('Underflowing ListView should relayout for additional children', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/5950
await tester.pumpWidget(new ListView(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
],
));
await tester.pumpWidget(new ListView(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
new SizedBox(height: 200.0, child: new Text('200')),
],
));
expect(find.text('200'), findsOneWidget);
});
testWidgets('Underflowing ListView contentExtent should track additional children', (WidgetTester tester) async {
await tester.pumpWidget(new ListView(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
],
));
RenderSliverList list = tester.renderObject(find.byType(SliverList));
expect(list.geometry.scrollExtent, equals(100.0));
await tester.pumpWidget(new ListView(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
new SizedBox(height: 200.0, child: new Text('200')),
],
));
expect(list.geometry.scrollExtent, equals(300.0));
await tester.pumpWidget(new ListView(
children: <Widget>[]
));
expect(list.geometry.scrollExtent, equals(0.0));
});
testWidgets('Overflowing ListView should relayout for missing children', (WidgetTester tester) async {
await tester.pumpWidget(new ListView(
children: <Widget>[
new SizedBox(height: 300.0, child: new Text('300')),
new SizedBox(height: 400.0, child: new Text('400')),
],
));
expect(find.text('300'), findsOneWidget);
expect(find.text('400'), findsOneWidget);
await tester.pumpWidget(new ListView(
children: <Widget>[
new SizedBox(height: 300.0, child: new Text('300')),
],
));
expect(find.text('300'), findsOneWidget);
expect(find.text('400'), findsNothing);
await tester.pumpWidget(new ListView(
children: <Widget>[]
));
expect(find.text('300'), findsNothing);
expect(find.text('400'), findsNothing);
});
testWidgets('Overflowing ListView should not relayout for additional children', (WidgetTester tester) async {
await tester.pumpWidget(new ListView(
children: <Widget>[
new SizedBox(height: 300.0, child: new Text('300')),
new SizedBox(height: 400.0, child: new Text('400')),
],
));
expect(find.text('300'), findsOneWidget);
expect(find.text('400'), findsOneWidget);
await tester.pumpWidget(new ListView(
children: <Widget>[
new SizedBox(height: 300.0, child: new Text('300')),
new SizedBox(height: 400.0, child: new Text('400')),
new SizedBox(height: 100.0, child: new Text('100')),
],
));
expect(find.text('300'), findsOneWidget);
expect(find.text('400'), findsOneWidget);
expect(find.text('100'), findsNothing);
RenderSliverList list = tester.renderObject(find.byType(SliverList));
expect(list.geometry.scrollExtent, equals(700.0));
});
testWidgets('Overflowing ListView should become scrollable', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/5920
// When a ListView's viewport hasn't overflowed, scrolling is disabled.
// When children are added that cause it to overflow, scrolling should
// be enabled.
await tester.pumpWidget(new ListView(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
],
));
Scrollable2State scrollable = tester.state(find.byType(Scrollable2));
expect(scrollable.position.maxScrollExtent, 0.0);
await tester.pumpWidget(new ListView(
children: <Widget>[
new SizedBox(height: 100.0, child: new Text('100')),
new SizedBox(height: 200.0, child: new Text('200')),
new SizedBox(height: 400.0, child: new Text('400')),
],
));
expect(scrollable.position.maxScrollExtent, 100.0);
});
}
......@@ -9,7 +9,7 @@ import 'package:flutter/rendering.dart';
import 'test_widgets.dart';
void main() {
testWidgets('LazyBlockViewport mount/dismount smoke test', (WidgetTester tester) async {
testWidgets('ListView mount/dismount smoke test', (WidgetTester tester) async {
List<int> callbackTracker = <int>[];
// the root view is 800x600 in the test environment
......@@ -17,18 +17,17 @@ void main() {
Widget builder() {
return new FlipWidget(
left: new LazyBlockViewport(
delegate: new LazyBlockBuilder(builder: (BuildContext context, int i) {
callbackTracker.add(i);
left: new ListView.builder(
itemBuilder: (BuildContext context, int index) {
callbackTracker.add(index);
return new Container(
key: new ValueKey<int>(i),
key: new ValueKey<int>(index),
height: 100.0,
child: new Text("$i")
child: new Text("$index"),
);
}),
startOffset: 0.0
},
),
right: new Text('Not Today')
right: new Text('Not Today'),
);
}
......@@ -51,32 +50,30 @@ void main() {
expect(callbackTracker, equals(<int>[0, 1, 2, 3, 4, 5]));
});
testWidgets('LazyBlockViewport vertical', (WidgetTester tester) async {
testWidgets('ListView vertical', (WidgetTester tester) async {
List<int> callbackTracker = <int>[];
// the root view is 800x600 in the test environment
// so if our widget is 200 pixels tall, it should fit exactly 3 times.
// but if we are offset by 300 pixels, there will be 4, numbered 1-4.
double offset = 300.0;
IndexedWidgetBuilder itemBuilder = (BuildContext context, int i) {
callbackTracker.add(i);
IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) {
callbackTracker.add(index);
return new Container(
key: new ValueKey<int>(i),
key: new ValueKey<int>(index),
width: 500.0, // this should be ignored
height: 200.0,
child: new Text("$i")
child: new Text('$index'),
);
};
Widget builder() {
return new FlipWidget(
left: new LazyBlockViewport(
delegate: new LazyBlockBuilder(builder: itemBuilder),
startOffset: offset
left: new ListView.builder(
controller: new ScrollController(initialScrollOffset: 300.0),
itemBuilder: itemBuilder,
),
right: new Text('Not Today')
right: new Text('Not Today'),
);
}
......@@ -86,12 +83,13 @@ void main() {
expect(callbackTracker, equals(<int>[0, 1, 2, 3, 4]));
callbackTracker.clear();
offset = 400.0; // now only 3 should fit, numbered 2-4.
Scrollable2State scrollable = tester.state(find.byType(Scrollable2));
scrollable.position.jumpTo(400.0); // now only 3 should fit, numbered 2-4.
await tester.pumpWidget(builder());
// We build all the children to find their new size.
expect(callbackTracker, equals(<int>[0, 1, 2, 3, 4]));
// We build the visible children to find their new size.
expect(callbackTracker, equals(<int>[1, 2, 3, 4]));
callbackTracker.clear();
await tester.pumpWidget(builder());
......@@ -101,33 +99,31 @@ void main() {
callbackTracker.clear();
});
testWidgets('LazyBlockViewport horizontal', (WidgetTester tester) async {
testWidgets('ListView horizontal', (WidgetTester tester) async {
List<int> callbackTracker = <int>[];
// the root view is 800x600 in the test environment
// so if our widget is 200 pixels wide, it should fit exactly 4 times.
// but if we are offset by 300 pixels, there will be 5, numbered 1-5.
double offset = 300.0;
IndexedWidgetBuilder itemBuilder = (BuildContext context, int i) {
callbackTracker.add(i);
IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) {
callbackTracker.add(index);
return new Container(
key: new ValueKey<int>(i),
key: new ValueKey<int>(index),
height: 500.0, // this should be ignored
width: 200.0,
child: new Text("$i")
child: new Text('$index'),
);
};
Widget builder() {
return new FlipWidget(
left: new LazyBlockViewport(
delegate: new LazyBlockBuilder(builder: itemBuilder),
startOffset: offset,
mainAxis: Axis.horizontal
left: new ListView.builder(
scrollDirection: Axis.horizontal,
controller: new ScrollController(initialScrollOffset: 300.0),
itemBuilder: itemBuilder,
),
right: new Text('Not Today')
right: new Text('Not Today'),
);
}
......@@ -138,12 +134,13 @@ void main() {
callbackTracker.clear();
offset = 400.0; // now only 4 should fit, numbered 2-5.
Scrollable2State scrollable = tester.state(find.byType(Scrollable2));
scrollable.position.jumpTo(400.0); // now only 4 should fit, numbered 2-5.
await tester.pumpWidget(builder());
// We build all the children to find their new size.
expect(callbackTracker, equals(<int>[0, 1, 2, 3, 4, 5]));
// We build the visible children to find their new size.
expect(callbackTracker, equals(<int>[1, 2, 3, 4, 5]));
callbackTracker.clear();
await tester.pumpWidget(builder());
......@@ -153,17 +150,17 @@ void main() {
callbackTracker.clear();
});
testWidgets('LazyBlockViewport reinvoke builders', (WidgetTester tester) async {
testWidgets('ListView reinvoke builders', (WidgetTester tester) async {
List<int> callbackTracker = <int>[];
List<String> text = <String>[];
IndexedWidgetBuilder itemBuilder = (BuildContext context, int i) {
callbackTracker.add(i);
IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) {
callbackTracker.add(index);
return new Container(
key: new ValueKey<int>(i),
key: new ValueKey<int>(index),
width: 500.0, // this should be ignored
height: 220.0,
child: new Text("$i")
child: new Text('$index')
);
};
......@@ -173,9 +170,8 @@ void main() {
}
Widget builder() {
return new LazyBlockViewport(
delegate: new LazyBlockBuilder(builder: itemBuilder),
startOffset: 0.0
return new ListView.builder(
itemBuilder: itemBuilder,
);
}
......@@ -196,24 +192,24 @@ void main() {
text.clear();
});
testWidgets('LazyBlockViewport reinvoke builders', (WidgetTester tester) async {
testWidgets('ListView reinvoke builders', (WidgetTester tester) async {
StateSetter setState;
ThemeData themeData = new ThemeData.light();
IndexedWidgetBuilder itemBuilder = (BuildContext context, int i) {
IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) {
return new Container(
key: new ValueKey<int>(i),
key: new ValueKey<int>(index),
width: 500.0, // this should be ignored
height: 220.0,
decoration: new BoxDecoration(
backgroundColor: Theme.of(context).primaryColor
backgroundColor: Theme.of(context).primaryColor,
),
child: new Text("$i")
child: new Text('$index'),
);
};
Widget viewport = new LazyBlockViewport(
delegate: new LazyBlockBuilder(builder: itemBuilder)
Widget viewport = new ListView.builder(
itemBuilder: itemBuilder,
);
await tester.pumpWidget(
......@@ -240,24 +236,24 @@ void main() {
expect(decoraton.backgroundColor, equals(Colors.green[500]));
});
testWidgets('LazyBlockViewport padding', (WidgetTester tester) async {
IndexedWidgetBuilder itemBuilder = (BuildContext context, int i) {
testWidgets('ListView padding', (WidgetTester tester) async {
IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) {
return new Container(
key: new ValueKey<int>(i),
key: new ValueKey<int>(index),
width: 500.0, // this should be ignored
height: 220.0,
decoration: new BoxDecoration(
backgroundColor: Colors.green[500]
),
child: new Text("$i")
child: new Text('$index'),
);
};
await tester.pumpWidget(
new LazyBlockViewport(
new ListView.builder(
padding: const EdgeInsets.fromLTRB(7.0, 3.0, 5.0, 11.0),
delegate: new LazyBlockBuilder(builder: itemBuilder)
)
itemBuilder: itemBuilder,
),
);
RenderBox firstBox = tester.renderObject(find.text('0'));
......@@ -266,38 +262,25 @@ void main() {
expect(firstBox.size.width, equals(800.0 - 12.0));
});
testWidgets('Underflow extents', (WidgetTester tester) async {
int lastFirstIndex;
int lastLastIndex;
double lastFirstStartOffset;
double lastLastEndOffset;
double lastMinScrollOffset;
double lastContainerExtent;
void handleExtendsChanged(int firstIndex, int lastIndex, double firstStartOffset, double lastEndOffset, double minScrollOffset, double containerExtent) {
lastFirstIndex = firstIndex;
lastLastIndex = lastIndex;
lastFirstStartOffset = firstStartOffset;
lastLastEndOffset = lastEndOffset;
lastMinScrollOffset = minScrollOffset;
lastContainerExtent = containerExtent;
}
await tester.pumpWidget(new LazyBlockViewport(
onExtentsChanged: handleExtendsChanged,
delegate: new LazyBlockChildren(
testWidgets('ListView underflow extents', (WidgetTester tester) async {
await tester.pumpWidget(new ListView(
children: <Widget>[
new Container(height: 100.0),
new Container(height: 100.0),
new Container(height: 100.0),
]
)
],
));
expect(lastFirstIndex, 0);
expect(lastLastIndex, 2);
expect(lastFirstStartOffset, 0.0);
expect(lastLastEndOffset, 300.0);
expect(lastContainerExtent, 600.0);
expect(lastMinScrollOffset, 0.0);
RenderSliverList list = tester.renderObject(find.byType(SliverList));
expect(list.indexOf(list.firstChild), equals(0));
expect(list.indexOf(list.lastChild), equals(2));
expect(list.childScrollOffset(list.firstChild), equals(0.0));
expect(list.geometry.scrollExtent, equals(300.0));
ScrollPosition position = tester.state<Scrollable2State>(find.byType(Scrollable2)).position;
expect(position.viewportDimension, equals(600.0));
expect(position.minScrollExtent, equals(0.0));
});
}
......@@ -27,7 +27,7 @@ Widget buildFrame() {
}
void main() {
testWidgets('LazyBlock is a build function (smoketest)', (WidgetTester tester) async {
testWidgets('ListView is a build function (smoketest)', (WidgetTester tester) async {
await tester.pumpWidget(buildFrame());
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsOneWidget);
......
......@@ -7,32 +7,16 @@ import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
class TestDelegate extends LazyBlockDelegate {
@override
Widget buildItem(BuildContext context, int index) {
return new Text('$index');
}
@override
double estimateTotalExtent(int firstIndex, int lastIndex, double minOffset, double firstStartOffset, double lastEndOffset) {
return double.INFINITY;
}
@override
bool shouldRebuild(LazyBlockDelegate oldDelegate) => false;
}
double currentOffset;
Future<Null> pumpTest(WidgetTester tester, TargetPlatform platform) async {
await tester.pumpWidget(new Container());
await tester.pumpWidget(new MaterialApp(
theme: new ThemeData(
platform: platform
),
home: new LazyBlock(
delegate: new TestDelegate(),
onScroll: (double scrollOffset) { currentOffset = scrollOffset; },
home: new ListView.builder(
itemBuilder: (BuildContext context, int index) {
return new Text('$index');
},
),
));
return null;
......@@ -42,21 +26,25 @@ const double dragOffset = 213.82;
void main() {
testWidgets('Flings on different platforms', (WidgetTester tester) async {
double getCurrentOffset() {
return tester.state<Scrollable2State>(find.byType(Scrollable2)).position.pixels;
}
await pumpTest(tester, TargetPlatform.android);
await tester.fling(find.byType(LazyBlock), const Offset(0.0, -dragOffset), 1000.0);
expect(currentOffset, dragOffset);
await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0);
expect(getCurrentOffset(), dragOffset);
await tester.pump(); // trigger fling
expect(currentOffset, dragOffset);
expect(getCurrentOffset(), dragOffset);
await tester.pump(const Duration(seconds: 5));
final double result1 = currentOffset;
final double result1 = getCurrentOffset();
await pumpTest(tester, TargetPlatform.iOS);
await tester.fling(find.byType(LazyBlock), const Offset(0.0, -dragOffset), 1000.0);
expect(currentOffset, dragOffset);
await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0);
expect(getCurrentOffset(), dragOffset);
await tester.pump(); // trigger fling
expect(currentOffset, dragOffset);
expect(getCurrentOffset(), dragOffset);
await tester.pump(const Duration(seconds: 5));
final double result2 = currentOffset;
final double result2 = getCurrentOffset();
expect(result1, lessThan(result2)); // iOS (result2) is slipperier than Android (result1)
});
......@@ -67,19 +55,19 @@ void main() {
List<Widget> textWidgets = <Widget>[];
for (int i = 0; i < 250; i++)
textWidgets.add(new GestureDetector(onTap: () { log.add('tap $i'); }, child: new Text('$i')));
await tester.pumpWidget(new Block(children: textWidgets));
await tester.pumpWidget(new ListView(children: textWidgets));
expect(log, equals(<String>[]));
await tester.tap(find.byType(Scrollable));
await tester.tap(find.byType(Scrollable2));
await tester.pump(const Duration(milliseconds: 50));
expect(log, equals(<String>['tap 18']));
await tester.fling(find.byType(Scrollable), const Offset(0.0, -200.0), 1000.0);
await tester.fling(find.byType(Scrollable2), const Offset(0.0, -200.0), 1000.0);
await tester.pump(const Duration(milliseconds: 50));
expect(log, equals(<String>['tap 18']));
await tester.tap(find.byType(Scrollable));
await tester.tap(find.byType(Scrollable2));
await tester.pump(const Duration(milliseconds: 50));
expect(log, equals(<String>['tap 18']));
await tester.tap(find.byType(Scrollable));
await tester.tap(find.byType(Scrollable2));
await tester.pump(const Duration(milliseconds: 50));
expect(log, equals(<String>['tap 18', 'tap 31']));
}, skip: Platform.isMacOS); // Skip due to https://github.com/flutter/flutter/issues/6961
......@@ -90,18 +78,18 @@ void main() {
List<Widget> textWidgets = <Widget>[];
for (int i = 0; i < 250; i++)
textWidgets.add(new GestureDetector(onTap: () { log.add('tap $i'); }, child: new Text('$i')));
await tester.pumpWidget(new Block(children: textWidgets));
await tester.pumpWidget(new ListView(children: textWidgets));
expect(log, equals(<String>[]));
await tester.tap(find.byType(Scrollable));
await tester.tap(find.byType(Scrollable2));
await tester.pump(const Duration(milliseconds: 50));
expect(log, equals(<String>['tap 18']));
await tester.fling(find.byType(Scrollable), const Offset(0.0, -200.0), 1000.0);
await tester.fling(find.byType(Scrollable2), const Offset(0.0, -200.0), 1000.0);
await tester.pump(const Duration(milliseconds: 50));
expect(log, equals(<String>['tap 18']));
await tester.pump(const Duration(seconds: 50));
expect(log, equals(<String>['tap 18']));
await tester.tap(find.byType(Scrollable));
await tester.tap(find.byType(Scrollable2));
await tester.pump(const Duration(milliseconds: 50));
expect(log, equals(<String>['tap 18', 'tap 43']));
}, skip: Platform.isMacOS); // Skip due to https://github.com/flutter/flutter/issues/6961
......
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