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

Add alignment parameter to $.tap #2484

Open
pdenert opened this issue Jan 10, 2025 · 2 comments
Open

Add alignment parameter to $.tap #2484

pdenert opened this issue Jan 10, 2025 · 2 comments

Comments

@pdenert
Copy link
Collaborator

pdenert commented Jan 10, 2025

As FritzMatthaeus noticed in: this comment, after adding option to pass Alignment to waitUntilVisible, we need to enhance other methods with that option. So user can tap, on something that was found as visible with alignment different than center.
We need to:

  1. Add alignment to tap.
  2. Replace tap with tapAt when using alignment.
@FritzMatthaeus
Copy link
Contributor

Please notice, that adding the alignment other than Alignment.center to tap or tapAt will throw an error in the flutter_test library. I have tested it and it threw some Offset-Error from the underlying flutter.

the tap method from flutter_test seems to look out for the center of the provided finder and an Offset Error is thrown. I have no knowledge on flutter_test and i do not know, if the provided finder can be changed to make it work.

  Future<void> tap(
    finders.FinderBase<Element> finder, {
    int? pointer,
    int buttons = kPrimaryButton,
    bool warnIfMissed = true,
    PointerDeviceKind kind = PointerDeviceKind.touch,
  }) {
    return tapAt(getCenter(finder, warnIfMissed: warnIfMissed, callee: 'tap'), pointer: pointer, buttons: buttons, kind: kind);
  }

copied from flutter_test/lib/src/controller.dart/WidgetController

Unfortunately i did not save the test. But it was similar to the waitUntilVisible Test with Alignment. Just try to tap it with Alignment.topCenter and it should thrown an Error.

patrolWidgetTest('waits until widget is only visible at the topCenter alignment', ($) async {
        await $.pumpWidget(
          MaterialApp(
            home: FutureBuilder(
              future: Future<void>.delayed(const Duration(seconds: 3)),
              builder: (context, snapshot) {
                if (snapshot.connectionState == ConnectionState.done) {
                  return const Column(children: [
                    Text('some text'),
                    SizedBox(height: 60),
                    Text('some other text'),
                  ],);
                } else {
                  return const Text('in progress');
                }
              },
            ),
          ),
        );
        await $(Column).waitUntilVisible(alignment: Alignment.topCenter);
        expect($(Column).visible, false);
        expect($(Column).isVisibleAt(alignment: Alignment.topCenter), true);
        await expectLater(
            $(Column).waitUntilVisible,
            throwsA(isA<WaitUntilVisibleTimeoutException>()),
          );
      });
    });

@pdenert
Copy link
Collaborator Author

pdenert commented Jan 13, 2025

You're right, but we can handle this. Just need to use tapAt from flutter_test directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants