Skip to content

fix: finish waiting SMS calls and cover the rejection paths - #69

Merged
Tkko merged 5 commits into
mainfrom
test/sms-listener-and-consent-coverage
Nov 6, 2026
Merged

Tkko merged 5 commits into
mainfrom
test/sms-listener-and-consent-coverage

Conversation

@Tkko

@Tkko Tkko commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Problem

The integration tests covered the happy paths, but not rejection, cancel or concurrent calls. Adding those tests exposed real bugs:

  • Hanging calls: removeSmsRetrieverApiListener and removeUserConsentApiListener never finished the waiting call, so its Future stayed pending forever. Starting a second SMS call did the same to the first.
  • Crossed results: the SMS calls and requestPhoneNumberHint shared one pending result. With the hint dialog open, an arriving SMS came back as the phone number (<#> Your code is 888888 ...).
  • Ordering: the SMS calls are suspend functions that start on a later main thread tick, while removal ran immediately. Calling remove...Listener right after get... did nothing and the call hung.

Changes

Plugin

  • Removing a listener, or starting a new SMS call, finishes the waiting call as canceled.
  • SMS and hint keep separate pending results.
  • Listener removal is posted to the main thread, so it runs after a call made just before it.
  • getSmsWithRetrieverApi can now return SmartAuthResult.canceled.

Tests

  • test/sms_api_test.dart: 13 unit tests for the SMS and hint result mapping, custom and invalid matchers, and calls with no native implementation.
  • 11 integration tests: unsigned SMS, Deny, other sender, no sender filter, rotation, backgrounding, hint with an SMS listener, and pending calls.

run_sms_tests.sh

  • adb shell no longer reads stdin. It was swallowing test output, which the script reads its markers from. This bug predates this PR.
  • Moved the dialog tap, hint dismissal and SMS sending into helpers.

Behaviour changes

  • Calls that used to hang now return canceled. It's in the 4.0.0 changelog under Fixes. pubspec.yaml is not bumped.
  • await remove...Listener() can return a moment before the waiting call finishes.

Verification

  • Local: 29 of 29 integration tests and 25 of 25 unit tests passed, and the analyzer is clean. That is one clean run on an API 36 emulator with Play Store disabled and animations off.
  • This PR's CI run is the first on API 35. The rotation and background tests use fixed sleeps and have the most steps, so they're the likeliest to be flaky.

Known gap

If a consent dialog is open and a new SMS call starts, the old call finishes as canceled, but the dialog's result then goes to the new call. Not fixed or tested here.

🤖 Generated with Claude Code

Tkko and others added 5 commits November 6, 2026 18:50
Removing a listener or starting a new SMS call left the waiting Future
pending forever. Both now finish it as canceled, and removal is queued
behind suspend calls, which start on a later main thread tick.

The SMS calls and requestPhoneNumberHint shared one pending result, so
an SMS arriving while the hint dialog was open came back as the phone
number. They now have separate results.

getSmsWithRetrieverApi can now return SmartAuthResult.canceled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add unit tests for the SMS and hint result mapping, and integration
tests for denied consent, other senders, unsigned messages, rotation,
backgrounding, hint and SMS together, and pending calls.

Stop adb from reading stdin in run_sms_tests.sh, where it swallowed the
test output the script reads its markers from.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.0.0 has not been released yet, so the fixes belong in that section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without a credential provider on the device, saving a password or
creating a passkey fails with TYPE_NO_CREATE_OPTIONS. This was only
mentioned for contributors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rotation test timed out on CI. The script rotated back right after
tapping, and each rotation recreates the dialog, which may lose the tap.
Tap after the rotations instead, and report a missing dialog button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Tkko Tkko closed this Nov 6, 2026
@Tkko Tkko reopened this Nov 6, 2026
@Tkko
Tkko merged commit a2756aa into main Nov 6, 2026
18 checks passed
@Tkko
Tkko deleted the test/sms-listener-and-consent-coverage branch November 6, 2026 15:35
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.

1 participant