Skip to content

[local_auth] Convert tests to Kotlin - #12884

Merged
auto-submit[bot] merged 13 commits into
flutter:mainfrom
stuartmorgan-g:kotlin-local-auth-part-2-tests
Sep 16, 2026
Merged

auto-submit[bot] merged 13 commits into
flutter:mainfrom
stuartmorgan-g:kotlin-local-auth-part-2-tests

Conversation

@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

Following up from #12635, this converts the unit tests from Java to Kotlin. As with that PR, this started with a deterministic Android Studio conversion, then made follow-up fixes manually, including suggestions from a local Gemini review.

The non-test changes are to replace @VisibleForTesting with internal now that the tests are Kotlin and can therefore access internal members. (Also, one very minor refactoring to fix a code suggestion warning in Android Studio.)

Part of flutter/flutter#188630

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the Android unit tests (AuthenticationHelperTest and LocalAuthTest) from Java to Kotlin, deleting the obsolete Java test files and the ResultCompat helper class. To support this migration, the mockito-kotlin dependency is added to build.gradle.kts, and @VisibleForTesting annotations in LocalAuthPlugin.kt are replaced with Kotlin's internal visibility modifier. Additionally, a null check in getEnrolledBiometrics is simplified, and the package version is bumped to 2.2.0. There are no review comments, and I have no feedback to provide.

}
}

private val dummyStrings = AuthStrings("a reason", "a hint", "cancel", "sign in")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we put these in a companion object?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Restored the companion object in both places.

FWIW, the reason I removed it originally was that when I asked Gemini to review for idiomatic Kotlin it indicated that private file-level constants are more idiomatic that companion objects for things like this, and that seemed reasonable (and there seemed to be some evidence to support that); I don't have a strong feeling either way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

huh, I would have thought companion objects would be more idiomatic.


private val dummyStrings = AuthStrings("a reason", "a hint", "cancel", "sign in")
private val defaultOptions =
AuthOptions(biometricOnly = false, sensitiveTransaction = false, sticky = false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here.

@@ -1,3 +1,7 @@
## 2.2.0

* Adjusts the code slightly to support the migration of unit tests to Kotlin.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd rather this be a bit more specific to prevent any PR from saying that it "adjusts the code". Maybe:

Adjusts visibility modifiers to support the migration of unit tests to Kotlin.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yep, good call. Fixed.

@mboetger mboetger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oops, too soon :)

@mboetger mboetger left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lol, nevermind. I guess I saw at a cached version of the CHANGELOG.md. Thanks for the update

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 16, 2026
@auto-submit
auto-submit Bot merged commit c6d0c25 into flutter:main Sep 16, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: local_auth platform-android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants