Skip to content

test: add end-to-end smoke tests covering every demo activity - #1007

Draft
kikoso wants to merge 1 commit into
mainfrom
test/demo-app-smoke-tests
Draft

kikoso wants to merge 1 commit into
mainfrom
test/demo-app-smoke-tests

Conversation

@kikoso

@kikoso kikoso commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Problem

Following up on a pull request currently means cloning it, building it, and clicking through every screen of the sample app to confirm nothing regressed. That is slow, easy to skip, and the coverage varies with whoever is reviewing.

What this adds

Two instrumentation tests in maps-app, both driven off allActivityGroups in Demo.kt, the single registry that already builds the on-screen demo list. A demo added to the app is covered automatically, with no change to either test. That is the property that makes this worth having rather than another list to keep in sync.

DemoAppSmokeTest

Parameterized over all 22 demos, two checks each:

  • demoLaunchesAndShowsMap: the activity reaches RESUMED, a MapView or StreetViewPanoramaView is attached, visible and non-zero sized, and nothing crashed on a background thread. The map surface is polled rather than checked once, because AndroidView lays it out a frame or more after the activity resumes.
  • demoSurvivesConfigurationChange: the same checks, then recreate(), then the same checks again. Configuration changes are where camera and marker state holders tend to regress and are tedious to verify by hand.

Map content is deliberately not asserted. Whether a particular marker or overlay is drawn belongs in the focused tests alongside this one; the value here is breadth.

DemoRegistryTest

Guards the registry itself. A demo is described in two places that have to agree: allActivityGroups and AndroidManifest.xml. Adding it to one and not the other compiles, builds, and only fails when someone taps the entry. Four checks: every demo resolves via PackageManager, is enabled, has non-blank title and description strings, and is not registered twice.

Verification

Run against a Pixel 8 emulator (API 36) with a valid Maps API key:

Suite Result
DemoAppSmokeTest 44 tests, 0 failures, 0 errors, 0 skipped, 138.6s
DemoRegistryTest 4 tests, 0 failures
:maps-app:lintDebug BUILD SUCCESSFUL, 0 issues

All 22 demos launch, show a map surface, and survive recreation today, so no demo needed an exemption and DEMOS_WITHOUT_MAP_SURFACE is empty.

Cost

DemoAppSmokeTest adds about 2.5 minutes to the emulator job, which currently runs 16 to 28 minutes. If that proves too much for the pull request gate, demoSurvivesConfigurationChange is the half to move to a nightly run: it roughly doubles the class's runtime and catches the rarer class of bug.

Notes

Both tests skip rather than fail when no Maps API key is configured, via assumeTrue(hasValidApiKey), matching how forks run CI without access to the secret. Worth knowing when reading a green run from a fork: the emulator job injects the key, so skipping only happens where the secret is genuinely unavailable.

Reviewing a pull request currently means cloning it and clicking through
the sample app by hand to confirm nothing regressed. These two tests do
that walk automatically.

DemoAppSmokeTest is parameterized over allActivityGroups, the same
registry that builds the on-screen demo list, so a demo added to the app
is covered with no change to the test. Each demo is launched and checked
for three things: it reaches RESUMED, a MapView or StreetViewPanoramaView
is attached and laid out, and nothing crashes on a background thread. It
then recreates the activity and checks again, which is where camera and
marker state holders tend to regress.

DemoRegistryTest guards the registry itself. A demo is described both in
allActivityGroups and in AndroidManifest.xml; adding it to one and not
the other builds cleanly and only fails when someone taps the entry.

Map content is deliberately not asserted. Verifying that a particular
marker or overlay is drawn belongs in the focused tests alongside these;
the value here is breadth.
@github-actions

Copy link
Copy Markdown

Coverage (unit tests)

No unit baseline recorded in coverage/history.csv yet, so this run only reports absolute numbers.

Module Line % Change Branch % Change
maps-compose 0.00% new 0.00% new
maps-compose-utils 2.04% new 0.49% new
maps-compose-widgets 0.00% new 0.00% new
TOTAL 0.42% new 0.09% new

Line and branch coverage from unit test reports. History is recorded in coverage/history.csv after each merge to main.

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