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

Keyboard: Add Movable interface to be implemented by page objects #695

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wmanley
Copy link
Contributor

@wmanley wmanley commented Sep 21, 2020

This allows page objects to override the mechanism for doing presses.

Builds on top of #685.

By taking a snapshot of the DUT state in the constructor.  This is
analogous to calling `get_frame()`.
@wmanley wmanley assigned drothlis and wmanley and unassigned drothlis Sep 21, 2020
This can be useful for transparent backgrounds, or to implement other means
of interaction.  I've not made it public for now, so we have more freedom
to play, but we can make it more public later if it turns out to be useful,
even without a new stb-tester release.

I've used a base class here rather than duck typing to make the behaviour
more explicitly opt-in.
stbt.press_and_wait("KEY_OK", mask=self.mask, stable_secs=0.5, # pylint:disable=stbt-unused-return-value
timeout_secs=1)
page = page.refresh()
page = self._move_one(page, "KEY_OK")
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a change in behaviour: We are now asserting the press_and_wait result, and we increased timeout_secs to 10.

If you have specified a mask that excludes the text box where the typed-text goes —a common thing to exclude, because it usually has a blinking cursor that breaks press_and_wait when used for navigation— then this will fail.

It seems that move_one isn't the right abstraction for this operation, which isn't about moving (maybe it "moves" —i.e. changes to a different key— if you're in shift mode or if you're pressing OK on a mode-change key, but most of the time it doesn't). Because of the short timeout and lack of assert, this use of press_and_wait should be OK even for UIs with transparency or some other reason why press_and_wait won't work for navigation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note: This used to be a plain stbt.press("KEY_OK") (sometimes with interpress_delay_secs=1) before I added support for shift modes (see commit 07555d0). I wonder if it would make sense to check whether the node we're on has an outgoing edge labelled with key="KEY_OK" and use that information to choose press vs. press_and_wait. It would make enter_text a tiny bit faster, by not having to call page.refresh().

drothlis added a commit that referenced this pull request Sep 28, 2020
So that callers can override it if they need to provide a custom
implementation (for example to handle live video behind a translucent
background). I won't document this for now, but it gives us some
flexibility without having to make a new Stb-tester release.

This is an interim measure until we iron out the "Movable" API in
<#695>.
drothlis added a commit that referenced this pull request Sep 28, 2020
So that callers can override it if they need to provide a custom
implementation (for example to handle live video behind a translucent
background). I won't document this for now, but it gives us some
flexibility without having to make a new Stb-tester release.

This is an interim measure until we iron out the "Movable" API in
<#695>.
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

Successfully merging this pull request may close these issues.

None yet

2 participants