Skip to content

Conversation

Kota-Jagadeesh
Copy link
Contributor

Contributor checklist


Description

This PR adds tests to check how the Enter key works in the Scribe keyboard for Issue #440:

  • Added a unit test (testEnterKeyBehavior) in KeyboardTest to verify that KeyHandler does not call commitText or sendKeyEvent for KEYCODE_ENTER in IDLE state.
  • Added an Espresso test (testEnterKeyBehaviorInCommandBar) in EnterKeyTest to test the command_bar EditText, assuming it clears after pressing Enter.
  • Fixed an error where the Espresso test failed due to no activity by moving it to EnterKeyTest with ActivityScenarioRule.
  • Kept all existing tests unchanged.

Related issue

Copy link

Thank you for the pull request! ❤️

The Scribe-Android team will do our best to address your contribution as soon as we can. If you're not already a member of our public Matrix community, please consider joining! We'd suggest that you use the Element client as well as Element X for a mobile app, and definitely join the General and Android rooms once you're in. Also consider attending our bi-weekly Saturday dev syncs. It'd be great to meet you 😊

Copy link

github-actions bot commented Aug 25, 2025

Maintainer Checklist

The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

  • The linting, formatting and testing workflows within the PR checks do not indicate new errors in the files changed

    • Tests may need to be reran as they're at times not deterministic
  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@andrewtavis
Copy link
Member

Thanks so much for the PR, @Kota-Jagadeesh! Would be great if you can look into the instrumentation tests as well as the Ktlint and Detekt errors. Please let us know if there's anything we can do to support! :)

@Kota-Jagadeesh
Copy link
Contributor Author

Thanks so much for the PR, @Kota-Jagadeesh! Would be great if you can look into the instrumentation tests as well as the Ktlint and Detekt errors. Please let us know if there's anything we can do to support! :)

Yeah sure 👍

@angrezichatterbox
Copy link
Member

@Kota-Jagadeesh

Just checking in. Could you fix those linting issues and then we could have a check and merge this in : )

@Kota-Jagadeesh
Copy link
Contributor Author

@Kota-Jagadeesh

Just checking in. Could you fix those linting issues and then we could have a check and merge this in : )

Yeah, Fixed all the lint issues.

  • All the tests will be passed in few minutes ,you can merge the PR : )

@Kota-Jagadeesh
Copy link
Contributor Author

This PR improvees the keyboard's reliability by adding a full set of unit tests for the KeyHandler class. It includes a fix for the Enter key issue, ensuering it correctly inserts a new line. I've also added comprehensive tests for the backspace key to ensure it works correctly in all states, and new tests to prevent crashes with null inputs.

@angrezichatterbox
Copy link
Member

@Kota-Jagadeesh

Could you base the enter key tests on basis of the IME actions like search or note application so that depending on the application it fulfills the purpose like adding a new line sending a message or searching.

@Kota-Jagadeesh
Copy link
Contributor Author

@angrezichatterbox Updated the PR, please review it : )

Changes Made

  • ffixed the Enter key logic in KeyHandler.kt so it knows what to do based on the app.
  • Instead of just doin' one thing, it now checks the EditorInfo.IME_MASK_ACTION flag.
  • If the app wants it to be a search, send, or done button, it'll do that. Otherwise, it just adds a new line like a regular keyboard.
  • also wrote some new tests in KeyboardTest.kt to make sure all these new actions work right.

Testing

  • tested it and the search test passed, the send test passed, and the new line test also passed.
  • It all works now and the old stuff is still fine.

Fixes #440

@andrewtavis
Copy link
Member

Thanks so much for your efforts to finalize this, @Kota-Jagadeesh!

@Kota-Jagadeesh
Copy link
Contributor Author

@angrezichatterbox Thanks for tha feedback! I've made the updates you requested.

  • Logic Fix (KeyHandler.kt): I fixed the Enter key to prioritize the keyboard's state (e.g., CONJUGATE, TRANSLATE). It now correctly defers to ime.handleKeycodeEnter() for commands and only uses EditorInfo.IME_ACTION logic when the state is IDLE.
  • Test Refactor (KeyboardTest.kt): I deleted the four repetitive tests and replaced them with a single, good parameterized test. This is much cleaner and verifies the command state logic too.

All tha tests are passed. Ready for your review!

@angrezichatterbox
Copy link
Member

@Kota-Jagadeesh

The tests I meant was Junit Parametrized tests. Could you look into that.

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.

Test for Enter key inserts new line correctly
3 participants