Skip to content

Commit aaa5fd4

Browse files
committed
chore: remove inline functions to calculate top and bottom positions; equals() -> moreOrLessEquals()
1 parent d8c836a commit aaa5fd4

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

super_editor/test/super_textfield/super_textfield_gesture_scrolling_test.dart

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -268,30 +268,28 @@ void main() {
268268
maxHeight: 40,
269269
);
270270

271-
double getTextBottom() {
272-
return tester.getBottomRight(find.byType(SuperTextField)).dy;
273-
}
274-
275-
double getViewportBottom() {
276-
return tester.getBottomRight(find.byType(SuperText)).dy;
277-
}
278-
279271
// Ensure the text field has not yet scrolled.
280-
expect(getTextBottom(), lessThan(getViewportBottom()));
272+
var textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
273+
var viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
274+
expect(textBottom, lessThan(viewportBottom));
281275

282276
// Scroll down to reveal the last line of text.
283277
await tester.drag(find.byType(SuperTextField), const Offset(0, -1000.0));
284278
await tester.pumpAndSettle();
285279

286280
// Ensure the text field has scrolled to the bottom.
287-
expect(getTextBottom(), equals(getViewportBottom()));
281+
textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
282+
viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
283+
expect(textBottom, moreOrLessEquals(viewportBottom));
288284

289285
// Scroll back up to the top of the text field.
290286
await tester.drag(find.byType(SuperTextField), const Offset(0, 1000.0));
291287
await tester.pumpAndSettle();
292288

293289
// Ensure the text field has scrolled back to the top.
294-
expect(getTextBottom(), lessThan(getViewportBottom()));
290+
textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
291+
viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
292+
expect(textBottom, lessThan(viewportBottom));
295293
});
296294

297295
testWidgetsOnDesktop("multi-line is vertically scrollable when text spans more lines than maxLines", (tester) async {
@@ -312,16 +310,10 @@ void main() {
312310
maxHeight: 40,
313311
);
314312

315-
double getTextBottom() {
316-
return tester.getBottomRight(find.byType(SuperTextField)).dy;
317-
}
318-
319-
double getViewportBottom() {
320-
return tester.getBottomRight(find.byType(SuperText)).dy;
321-
}
322-
323313
// Ensure the text field has not yet scrolled.
324-
expect(getTextBottom(), lessThan(getViewportBottom()));
314+
var textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
315+
var viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
316+
expect(textBottom, lessThan(viewportBottom));
325317

326318
// Scroll down to reveal the last line of text.
327319
await tester.drag(
@@ -332,7 +324,9 @@ void main() {
332324
await tester.pumpAndSettle();
333325

334326
// Ensure the text field has scrolled to the bottom.
335-
expect(getTextBottom(), equals(getViewportBottom()));
327+
textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
328+
viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
329+
expect(textBottom, moreOrLessEquals(viewportBottom));
336330

337331
// Scroll back up to the top of the text field.
338332
await tester.drag(
@@ -343,7 +337,9 @@ void main() {
343337
await tester.pumpAndSettle();
344338

345339
// Ensure the text field has scrolled back to the top.
346-
expect(getTextBottom(), lessThan(getViewportBottom()));
340+
textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
341+
viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
342+
expect(textBottom, lessThan(viewportBottom));
347343
});
348344
});
349345
}

0 commit comments

Comments
 (0)