
Since our build function depends on scrollBehavior.isScrollable, any time we update scrollBehavior we are implicitly updating our state. As such, we must do so during a setState() call, or else we won't rebuild and might not bother to listen to the scroll gestures. This probably broke when we made Block not listen to gestures if it wasn't overflowing.
65 lines
2.0 KiB
Dart
65 lines
2.0 KiB
Dart
import 'package:quiver/testing/async.dart';
|
|
import 'package:sky/widgets.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import '../engine/mock_events.dart';
|
|
import 'widget_tester.dart';
|
|
|
|
final Key blockKey = new Key('test');
|
|
|
|
void main() {
|
|
test('Cannot scroll a non-overflowing block', () {
|
|
WidgetTester tester = new WidgetTester();
|
|
|
|
tester.pumpFrame(() {
|
|
return new Block([
|
|
new Container(
|
|
height: 200.0, // less than 600, the height of the test area
|
|
child: new Text('Hello')
|
|
)
|
|
],
|
|
key: blockKey);
|
|
});
|
|
tester.pumpFrameWithoutChange(); // for SizeObservers
|
|
|
|
Point middleOfContainer = tester.getCenter(tester.findText('Hello'));
|
|
Point target = tester.getCenter(tester.findWidget((widget) => widget.key == blockKey));
|
|
TestPointer pointer = new TestPointer();
|
|
tester.dispatchEvent(pointer.down(target), target);
|
|
tester.dispatchEvent(pointer.move(target + const Offset(0.0, -10.0)), target);
|
|
|
|
tester.pumpFrameWithoutChange(1.0);
|
|
|
|
expect(tester.getCenter(tester.findText('Hello')) == middleOfContainer, isTrue);
|
|
|
|
tester.dispatchEvent(pointer.up(), target);
|
|
});
|
|
|
|
test('Can scroll an overflowing block', () {
|
|
WidgetTester tester = new WidgetTester();
|
|
|
|
tester.pumpFrame(() {
|
|
return new Block([
|
|
new Container(
|
|
height: 2000.0, // more than 600, the height of the test area
|
|
child: new Text('Hello')
|
|
)
|
|
],
|
|
key: blockKey);
|
|
});
|
|
tester.pumpFrameWithoutChange(); // for SizeObservers
|
|
|
|
Point middleOfContainer = tester.getCenter(tester.findText('Hello'));
|
|
Point target = tester.getCenter(tester.findWidget((widget) => widget.key == blockKey));
|
|
TestPointer pointer = new TestPointer();
|
|
tester.dispatchEvent(pointer.down(target), target);
|
|
tester.dispatchEvent(pointer.move(target + const Offset(0.0, -10.0)), target);
|
|
|
|
tester.pumpFrameWithoutChange(1.0);
|
|
|
|
expect(tester.getCenter(tester.findText('Hello')) == middleOfContainer, isFalse);
|
|
|
|
tester.dispatchEvent(pointer.up(), target);
|
|
});
|
|
}
|