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

Fix off-by-one when specifying count with inputText #2123

Open
wants to merge 2 commits 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 @@ -273,8 +273,9 @@ class Service(
val charactersToErase = request.charactersToErase
Log.d("Maestro", "Erasing text $charactersToErase")

for (i in 0..charactersToErase) {
for (i in 1..charactersToErase) {
uiDevice.pressDelete()
Thread.sleep(50) // Attempt to ensure perfect count of taps on emulators
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't encourage doing this. Let's avoid having random sleeps in the code. It becomes very hard to reason about slowness and failures due to these.

Can you explain why is this exactly needed and if there is something other than a sleep we could do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before this sleep was in, I'd occasionally see 1 extra or 1 too few presses of the delete key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a chance that shorter sleeps would be sufficient, or that the API could be improved to block until ready?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup I'd vote for choosing an API that reasons about that and includes wait as much in needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the way forward with this change?
Would you accept a //TODO?

}

responseObserver.onNext(eraseAllTextResponse { })
Expand Down
Loading