Skip to content

Commit 6ab46d6

Browse files
committed
fix: make test more robust, and fail (correctly) more easily if scroll amount changes
1 parent 8541fe1 commit 6ab46d6

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

super_editor/test/super_textfield/super_textfield_gesture_scrolling_test.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -269,27 +269,27 @@ void main() {
269269
);
270270

271271
// Ensure the text field has not yet scrolled.
272-
var textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
273-
var viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
274-
expect(textBottom, lessThanOrEqualTo(viewportBottom));
272+
var textTop = tester.getTopRight(find.byType(SuperTextField)).dy;
273+
var viewportTop = tester.getTopRight(find.byType(SuperText)).dy;
274+
expect(textTop, moreOrLessEquals(viewportTop));
275275

276276
// Scroll down to reveal the last line of text.
277277
await tester.drag(find.byType(SuperTextField), const Offset(0, -1000.0));
278278
await tester.pumpAndSettle();
279279

280280
// Ensure the text field has scrolled to the bottom.
281-
textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
282-
viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
281+
var textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
282+
var viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
283283
expect(textBottom, moreOrLessEquals(viewportBottom));
284284

285285
// Scroll back up to the top of the text field.
286286
await tester.drag(find.byType(SuperTextField), const Offset(0, 1000.0));
287287
await tester.pumpAndSettle();
288288

289289
// Ensure the text field has scrolled back to the top.
290-
textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
291-
viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
292-
expect(textBottom, lessThanOrEqualTo(viewportBottom));
290+
textTop = tester.getTopRight(find.byType(SuperTextField)).dy;
291+
viewportTop = tester.getTopRight(find.byType(SuperText)).dy;
292+
expect(textTop, moreOrLessEquals(viewportTop));
293293
});
294294

295295
testWidgetsOnDesktop("multi-line is vertically scrollable when text spans more lines than maxLines", (tester) async {
@@ -311,9 +311,9 @@ void main() {
311311
);
312312

313313
// Ensure the text field has not yet scrolled.
314-
var textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
315-
var viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
316-
expect(textBottom, lessThanOrEqualTo(viewportBottom));
314+
var textTop = tester.getTopRight(find.byType(SuperTextField)).dy;
315+
var viewportTop = tester.getTopRight(find.byType(SuperText)).dy;
316+
expect(textTop, moreOrLessEquals(viewportTop));
317317

318318
// Scroll down to reveal the last line of text.
319319
await tester.drag(
@@ -324,8 +324,8 @@ void main() {
324324
await tester.pumpAndSettle();
325325

326326
// Ensure the text field has scrolled to the bottom.
327-
textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
328-
viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
327+
var textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
328+
var viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
329329
expect(textBottom, moreOrLessEquals(viewportBottom));
330330

331331
// Scroll back up to the top of the text field.
@@ -337,9 +337,9 @@ void main() {
337337
await tester.pumpAndSettle();
338338

339339
// Ensure the text field has scrolled back to the top.
340-
textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
341-
viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
342-
expect(textBottom, lessThanOrEqualTo(viewportBottom));
340+
textTop = tester.getTopRight(find.byType(SuperTextField)).dy;
341+
viewportTop = tester.getTopRight(find.byType(SuperText)).dy;
342+
expect(textTop, moreOrLessEquals(viewportTop));
343343
});
344344
});
345345
}

0 commit comments

Comments
 (0)