Repository navigation
test(widgets): add ScaleBar Robolectric tests and migrate GoogleMapTest to KTX helpers - #1001
Conversation
0985765 to
34f2003
Compare
Coverage (unit tests)Compared against
Line and branch coverage from unit test reports. History is recorded on the |
Code Coverage
|
34f2003 to
57c2723
Compare
57c2723 to
a63c557
Compare
a63c557 to
1a8f666
Compare
df2a0d9 to
ee29efc
Compare
5dcab93 to
6134e13
Compare
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
32bc253 to
f217943
Compare
Coverage (instrumentation tests)
|
| --> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <application> | ||
| <activity |
There was a problem hiding this comment.
nit: in maps-compose we get this activity from libs.androidx.test.compose.ui.manifest. Could we delete this file and add the same dependency as testImplementation in the widgets module? I tried it locally and ScaleBarTest keeps passing.
There was a problem hiding this comment.
Done in 50602e48 — deleted maps-compose-widgets/src/debug/AndroidManifest.xml and switched to testImplementation(libs.androidx.test.compose.ui.manifest). All :maps-compose-widgets unit tests pass.
| testImplementation(libs.androidx.test.core) | ||
| testImplementation(libs.kotlinx.coroutines.test) |
There was a problem hiding this comment.
nit: androidx.test.core and kotlinx-coroutines-test are not used anywhere in the widgets tests, I think we can remove both.
| testImplementation(libs.androidx.test.core) | |
| testImplementation(libs.kotlinx.coroutines.test) |
There was a problem hiding this comment.
Removed both unused dependencies (androidx.test.core and kotlinx-coroutines-test) in 50602e48 — :maps-compose-widgets:testDebugUnitTest and lint remain green.
| } | ||
|
|
||
| composeTestRule.waitForIdle() | ||
| composeTestRule.onNodeWithText("0 ft").assertIsDisplayed() |
There was a problem hiding this comment.
Just to understand it: the state is never attached to a map, so the projection is null and we render always the 0 fallback, right? Would it make sense to add a comment here, so nobody thinks we are checking a real label?
There was a problem hiding this comment.
Yes, exactly — cameraState isn't attached to a GoogleMap in that test, so projection is null and ScaleBar renders the 0 fallback labels. Added an explicit comment in 50602e48 to make that clear (and I'm adding live GoogleMap-bound ScaleBar and adversarial edge-case tests in a follow-up PR).
…s Testing Toolkit
* test(widgets): add JVM unit and composable tests for ScaleBar * test(widgets): address review feedback in ScaleBarTest - Assert calculateDistance against known ground-truth values (mocked equatorial span = 98m, plus Mercator zoom 12 checks at 0 deg and 60 deg latitude) instead of repeating the implementation formula. - Remove unused sphericalDistance import from ScaleBarTest. - Add displayed text assertions in ScaleBar test and mainClock-driven show/hide/re-show/hide assertions in DisappearingScaleBar test.
- Delete maps-compose-widgets/src/debug/AndroidManifest.xml and use testImplementation(libs.androidx.test.compose.ui.manifest). - Remove unused androidx.test.core and kotlinx-coroutines-test dependencies from maps-compose-widgets/build.gradle.kts. - Document null-projection fallback behavior in ScaleBarTest.
f217943 to
50602e4
Compare
Summary
Adds JVM unit and Jetpack Compose Robolectric tests for
:maps-compose-widgets(ScaleBarandDisappearingScaleBar) and migrates existing:maps-composeGoogleMapTestassertions to themaps-testing-robolectricKTX and Truth helpers.Changes
:maps-compose-widgets: Configure Robolectric Android resources,androidx.test.compose.ui.manifest, andmaps-testing-robolectrictest dependencies; addScaleBarTestcoveringcalculateDistanceground-truth assertions,ScaleBarnull-projection fallback rendering, andDisappearingScaleBarvisibility transitions.:maps-compose: RefactorGoogleMapTestto usecreateTestMap(),map.markers,map.circles,map.clickMarker(), andGoogleMapSubject.assertThat(map)instead ofShadow.extract/ShadowGoogleMap.