@@ -249,6 +249,80 @@ void main() {
249
249
// Ensure the selection didn't change.
250
250
expect (SuperTextFieldInspector .findSelection (), TextRange .empty);
251
251
});
252
+
253
+ testWidgetsOnMobile ("multi-line is vertically scrollable when text spans more lines than maxLines" , (tester) async {
254
+ final controller = AttributedTextEditingController (
255
+ text: AttributedText ("A\n B\n C" ),
256
+ );
257
+
258
+ // Pump the widget tree with a SuperTextField with a maxHeight of 2 lines
259
+ // of text, which should overflow considering there are 3 lines of text.
260
+ await _pumpTestApp (
261
+ tester,
262
+ textController: controller,
263
+ minLines: 1 ,
264
+ maxLines: 2 ,
265
+ maxHeight: 40 ,
266
+ );
267
+
268
+ // Move selection to the end of the text
269
+ // TODO: change to simulate user input when IME simulation is available
270
+ controller.selection = const TextSelection .collapsed (offset: 5 );
271
+ await tester.pumpAndSettle ();
272
+
273
+ // Ensure the text field has scrolled to the bottom.
274
+ expect (
275
+ SuperTextFieldInspector .findScrollOffset (),
276
+ greaterThan (0.0 ),
277
+ );
278
+
279
+ // Scroll upwards towards the top of the text field.
280
+ await tester.drag (find.byType (SuperTextField ), const Offset (0 , - 1000 ));
281
+ await tester.pumpAndSettle ();
282
+
283
+ // Ensure the text field has scrolled back to the top.
284
+ expect (
285
+ SuperTextFieldInspector .findScrollOffset (),
286
+ 0.0 ,
287
+ );
288
+ });
289
+
290
+ testWidgetsOnDesktop ("multi-line is vertically scrollable when text spans more lines than maxLines" , (tester) async {
291
+ final controller = AttributedTextEditingController (
292
+ text: AttributedText ("A\n B\n C" ),
293
+ );
294
+
295
+ // Pump the widget tree with a SuperTextField with a maxHeight of 2 lines
296
+ // of text, which should overflow considering there are 3 lines of text.
297
+ await _pumpTestApp (
298
+ tester,
299
+ textController: controller,
300
+ minLines: 1 ,
301
+ maxLines: 2 ,
302
+ maxHeight: 40 ,
303
+ );
304
+
305
+ // Move selection to the end of the text
306
+ // TODO: change to simulate user input when IME simulation is available
307
+ controller.selection = const TextSelection .collapsed (offset: 5 );
308
+ await tester.pumpAndSettle ();
309
+
310
+ // Ensure the text field has scrolled to the bottom.
311
+ expect (
312
+ SuperTextFieldInspector .findScrollOffset (),
313
+ greaterThan (0.0 ),
314
+ );
315
+
316
+ // Scroll upwards towards the top of the text field.
317
+ await tester.drag (find.byType (SuperTextField ), const Offset (0 , - 1000 ));
318
+ await tester.pumpAndSettle ();
319
+
320
+ // Ensure the text field has scrolled back to the top.
321
+ expect (
322
+ SuperTextFieldInspector .findScrollOffset (),
323
+ 0.0 ,
324
+ );
325
+ });
252
326
});
253
327
}
254
328
0 commit comments