Skip to content

test(utils): add JVM unit and composable integration tests for Clustering and WmsTileOverlay - #1004

Draft
dkhawk wants to merge 1 commit into
feature/robolectric-widgets-testsfrom
feature/robolectric-utils-tests
Draft

dkhawk wants to merge 1 commit into
feature/robolectric-widgets-testsfrom
feature/robolectric-utils-tests

Conversation

@dkhawk

@dkhawk dkhawk commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Description

Stacked PR on top of #1003 (feature/robolectric-widgets-tests), which stacks on #1001 (feature/robolectric-tests).

Introduces comprehensive JVM unit and Compose integration tests for maps-compose-utils using Robolectric and the local shadow library, raising module line coverage from 2.04% to 69.19% (instruction coverage from 0.78% to 64.11%). Across all three published library modules (maps-compose, maps-compose-widgets, maps-compose-utils), total JVM line coverage reaches 44.95%.

Summary of Changes

  • Added test dependencies (robolectric, truth, mockk, androidx.test.compose.ui, maps.robolectric.shadows) to maps-compose-utils/build.gradle.kts.
  • Configured Robolectric Android resource processing and Java 21 test runner toolchain.
  • Added debug manifest with ComponentActivity for Robolectric Compose rule hosting.
  • Added WmsTileOverlayTest.kt verifying WmsTileOverlay composable rendering, tile overlay attributes (transparency, fade-in, visibility, z-index), and tile cache clearing.
  • Expanded WmsUrlTileProviderTest.kt covering valid URL formatting and malformed URL handling.
  • Added ClusteringTest.kt covering:
    • ClusteringMarkerProperties composition local propagation and mutation.
    • Clustering default renderer marker placement and manager callbacks.
    • Custom Compose UI content rendering (clusterContent, clusterItemContent, clusterItemDecoration).
    • Dynamic item updates (clearing, adding, re-clustering on state change).
    • rememberClusterManager and rememberClusterRenderer lifecycle initialization.

cc @LoyalAbbas @kikoso

@dkhawk
dkhawk requested a review from kikoso September 15, 2026 21:59
@googlemaps-bot

googlemaps-bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 44.43% 🍏

There is no coverage information present for the Files changed

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Coverage (unit tests)

Compared against cb74115 on feature/robolectric-widgets-tests (#1031).

Module Line % Change Branch % Change
maps-compose 36.95% 🔺 +36.95 10.42% 🔺 +10.42
maps-compose-utils 69.19% 🔺 +67.15 24.03% 🔺 +23.54
maps-compose-widgets 67.12% 🔺 +67.12 52.94% 🔺 +52.94
TOTAL 45.19% 🔺 +44.78 14.14% 🔺 +14.05

Line and branch coverage from unit test reports. History is recorded on the coverage-history branch after each merge to feature/robolectric-widgets-tests.

@dkhawk
dkhawk force-pushed the feature/robolectric-widgets-tests branch from 9f260d3 to bab4d05 Compare October 1, 2026 21:07
@dkhawk
dkhawk force-pushed the feature/robolectric-utils-tests branch from 7741e9d to b0fbce9 Compare October 1, 2026 21:07

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding these, @dkhawk ! Can you take a look at the comments? CI is also red, so let's get that green before merging.

Comment thread maps-compose-utils/build.gradle.kts Outdated
Comment on lines +105 to +109
tasks.withType<Test>().configureEach {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(21))
})
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you elaborate on why do we need to force a Java 21 launcher for the tests? If the CI runners don't provide JDK 21 (or toolchain auto-provisioning isn't enabled), this could be what is breaking the build. Would it make sense to align it with the toolchain the rest of the project uses?

Comment on lines +97 to +101
testImplementation(libs.mockk)
testImplementation(libs.androidx.test.compose.ui)
testImplementation(libs.androidx.activity.compose)
testImplementation(libs.androidx.test.core)
testImplementation(libs.kotlinx.coroutines.test)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I can't see mockk or kotlinx-coroutines-test used in any of the new tests. Should we drop them until we actually need them?

android:name="androidx.activity.ComponentActivity"
android:exported="true" />
</application>
</manifest>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if we could avoid shipping a debug manifest in the library just for the tests. The androidx.compose.ui:ui-test-manifest artefact registers ComponentActivity for us. What do you think?

Comment on lines +76 to +78
assertThat(tileUrl).isEqualTo(
URL("https://example.com/wms?bbox=-${worldSize},0.0,0.0,${worldSize}&zoom=1")
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

URL.equals() can do host name resolution, which makes this test depend on the network (see the note here). Shouldn't we favour comparing the string representation?

Suggested change
assertThat(tileUrl).isEqualTo(
URL("https://example.com/wms?bbox=-${worldSize},0.0,0.0,${worldSize}&zoom=1")
)
assertThat(tileUrl?.toString()).isEqualTo(
"https://example.com/wms?bbox=-${worldSize},0.0,0.0,${worldSize}&zoom=1"
)

import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

// [START maps_compose_utils_clustering_test]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just to understand it: are these [START ...]/[END ...] region tags meant to be pulled into some documentation? If not, I would remove them from the tests.

@dkhawk
dkhawk force-pushed the feature/robolectric-widgets-tests branch from bab4d05 to d74586e Compare October 9, 2026 15:32
@dkhawk
dkhawk force-pushed the feature/robolectric-utils-tests branch from b0fbce9 to 8b96198 Compare October 9, 2026 15:32

This branch has not been deployed

No deployments
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.

3 participants