|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be
|
3 | 3 | // found in the LICENSE file.
|
4 | 4 |
|
| 5 | +import 'dart:ui'; |
| 6 | + |
5 | 7 | import 'package:flutter/material.dart';
|
6 | 8 | import 'package:flutter/rendering.dart';
|
7 | 9 | import 'package:flutter_test/flutter_test.dart';
|
@@ -1118,4 +1120,47 @@ void main() {
|
1118 | 1120 |
|
1119 | 1121 | expect(tester.testTextInput.isVisible, isFalse);
|
1120 | 1122 | });
|
| 1123 | + |
| 1124 | + testWidgets('keyboardDismissBehavior on scroll without a drag test', (WidgetTester tester) async { |
| 1125 | + await tester.pumpWidget(MaterialApp( |
| 1126 | + home: Scaffold( |
| 1127 | + body: SizedBox( |
| 1128 | + height: 1000, |
| 1129 | + child: SingleChildScrollView( |
| 1130 | + keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, |
| 1131 | + child: Column( |
| 1132 | + children: <Widget>[ |
| 1133 | + Autocomplete<String>( |
| 1134 | + optionsBuilder: (TextEditingValue textEditingValue) { |
| 1135 | + return<String>['aardvark', 'bobcat', 'chameleon'] |
| 1136 | + .where((String option) { |
| 1137 | + return option.contains(textEditingValue.text.toLowerCase()); |
| 1138 | + }); |
| 1139 | + }, |
| 1140 | + ), |
| 1141 | + const SizedBox(height: 2000), |
| 1142 | + ], |
| 1143 | + ), |
| 1144 | + ), |
| 1145 | + ), |
| 1146 | + ), |
| 1147 | + )); |
| 1148 | + |
| 1149 | + await tester.tap(find.byType(Autocomplete<String>)); |
| 1150 | + await tester.pump(); |
| 1151 | + |
| 1152 | + await tester.enterText(find.byType(RawAutocomplete<String>),'aard'); |
| 1153 | + await tester.pump(); |
| 1154 | + |
| 1155 | + expect(find.text('aardvark'), findsOneWidget); |
| 1156 | + |
| 1157 | + final TestPointer testPointer = TestPointer(1, PointerDeviceKind.mouse); |
| 1158 | + final Offset scrollStart = tester.getCenter(find.byType(SingleChildScrollView)); |
| 1159 | + |
| 1160 | + testPointer.hover(scrollStart); |
| 1161 | + await tester.sendEventToBinding(testPointer.scroll(Offset(scrollStart.dx, scrollStart.dy - 100))); |
| 1162 | + await tester.pumpAndSettle(); |
| 1163 | + |
| 1164 | + expect(find.text('aardvark'), findsNothing); |
| 1165 | + }); |
1121 | 1166 | }
|
0 commit comments