Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate issue where SuperTextFieldInspector.findScrollOffset() value is incorrect #2256

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ void main() {
var textTop = tester.getTopRight(find.byType(SuperTextField)).dy;
var viewportTop = tester.getTopRight(find.byType(SuperText)).dy;
expect(textTop, moreOrLessEquals(viewportTop));
expect(SuperTextFieldInspector.findScrollOffset(), 0.0);

// Scroll down to reveal the last line of text.
await tester.drag(find.byType(SuperTextField), const Offset(0, -1000.0));
Expand All @@ -281,6 +282,10 @@ void main() {
var textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
var viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
expect(textBottom, moreOrLessEquals(viewportBottom));
// Since the scrollable content is taller than the viewport, and since
// the bottom of the text field is aligned with the bottom of the
// viewport, the scroll offset should be greater than 0.
expect(SuperTextFieldInspector.findScrollOffset(), greaterThan(0.0));
Comment on lines +285 to +288
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the test:

testWidgetsOnMobile("multi-line is vertically scrollable when text spans more lines than maxLines", (tester) async {

And for both Android and iOS, the test fails because the value for SuperTextFieldInspector.findScrollOffset() is 0


// Scroll back up to the top of the text field.
await tester.drag(find.byType(SuperTextField), const Offset(0, 1000.0));
Expand All @@ -290,6 +295,7 @@ void main() {
textTop = tester.getTopRight(find.byType(SuperTextField)).dy;
viewportTop = tester.getTopRight(find.byType(SuperText)).dy;
expect(textTop, moreOrLessEquals(viewportTop));
expect(SuperTextFieldInspector.findScrollOffset(), 0.0);
});

testWidgetsOnDesktop("multi-line is vertically scrollable when text spans more lines than maxLines", (tester) async {
Expand All @@ -314,6 +320,7 @@ void main() {
var textTop = tester.getTopRight(find.byType(SuperTextField)).dy;
var viewportTop = tester.getTopRight(find.byType(SuperText)).dy;
expect(textTop, moreOrLessEquals(viewportTop));
expect(SuperTextFieldInspector.findScrollOffset(), 0.0);

// Scroll down to reveal the last line of text.
await tester.drag(
Expand All @@ -327,6 +334,10 @@ void main() {
var textBottom = tester.getBottomRight(find.byType(SuperTextField)).dy;
var viewportBottom = tester.getBottomRight(find.byType(SuperText)).dy;
expect(textBottom, moreOrLessEquals(viewportBottom));
// Issue is not present on desktop, further leading me to think that the
// issue is somehow related to that comment about the scroll offsets
// being out of sync in the mobile scroll view.
expect(SuperTextFieldInspector.findScrollOffset(), greaterThan(0.0));
Comment on lines +337 to +340
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Desktop equivalents pass (so the value is > 0)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Printed the actual value here as 20, which makes sense considering we have a scrollable of height 40 with content of height 60


// Scroll back up to the top of the text field.
await tester.drag(
Expand All @@ -340,6 +351,7 @@ void main() {
textTop = tester.getTopRight(find.byType(SuperTextField)).dy;
viewportTop = tester.getTopRight(find.byType(SuperText)).dy;
expect(textTop, moreOrLessEquals(viewportTop));
expect(SuperTextFieldInspector.findScrollOffset(), 0.0);
});
});
}
Expand Down
Loading