Summary
When working on the Map In Column Activity in the demo app (PR #94), I encountered a strange issue that seemed to prevent testing the map in the column as I wanted.
This test is currently commented out because it fails, but it should pass:
https://github.com/googlemaps/android-maps-compose/blob/main/app/src/androidTest/java/com/google/maps/android/compose/MapInColumnTests.kt#L127
@Test
fun testPanMapUp_MapCameraChangesColumnDoesNotScroll() {
initMap()
// Swipe the map up
// FIXME - for some reason this scrolls the entire column instead of just the map
composeTestRule.onNodeWithTag("Map").performTouchInput { swipeUp() }
composeTestRule.waitForIdle()
// Make sure that the map changed (i.e., we can scroll the map in the column)
startingPosition.assertNotEquals(cameraPositionState.position.target) // This assertion fails when it should pass
// Check to make sure column didn't scroll
composeTestRule.onNodeWithTag("Item 1").assertIsDisplayed()
}
I was trying to test the scenario where the user pans the map within the column, and the map camera moves but the column itself doesn't scroll (i.e., the desired behavior).
However, I can't seem to perform composeTestRule.onNodeWithTag("Map").performTouchInput { swipeUp() } on the map - the entire column just scrolls. This is strange because when you test the app manually it works as intended (i.e., the map moves and the column doesn't scroll). I've tried moving the tag around to different elements (GoogleMap, Box that contains map, etc.) and referencing the composable with other selectors as well (e.g., onChild()) but behavior is same.
I'm not sure if I'm missing something in this test, or if this is a larger issue with UI testing and maps-compose (possibly related to #126?).
Environment details
Main branch as of 1bf8cb0
Steps to reproduce
- Uncomment
testPanMapUp_MapCameraChangesColumnDoesNotScroll() and run the test
What I see
Test fails
What I expect
Test pass
Stack trace
java.lang.AssertionError: Values should be different. Actual: 1.2302615506247394
at org.junit.Assert.fail(Assert.java:89)
at org.junit.Assert.failEquals(Assert.java:187)
at org.junit.Assert.assertNotEquals(Assert.java:234)
at org.junit.Assert.assertNotEquals(Assert.java:251)
at com.google.maps.android.compose.TestUtilsKt.assertNotEquals(TestUtils.kt:15)
at com.google.maps.android.compose.MapInColumnTests.testPanMapUp_MapCameraChangesColumnDoesNotScroll(MapInColumnTests.kt:136)
Summary
When working on the Map In Column Activity in the demo app (PR #94), I encountered a strange issue that seemed to prevent testing the map in the column as I wanted.
This test is currently commented out because it fails, but it should pass:
https://github.com/googlemaps/android-maps-compose/blob/main/app/src/androidTest/java/com/google/maps/android/compose/MapInColumnTests.kt#L127
@Test fun testPanMapUp_MapCameraChangesColumnDoesNotScroll() { initMap() // Swipe the map up // FIXME - for some reason this scrolls the entire column instead of just the map composeTestRule.onNodeWithTag("Map").performTouchInput { swipeUp() } composeTestRule.waitForIdle() // Make sure that the map changed (i.e., we can scroll the map in the column) startingPosition.assertNotEquals(cameraPositionState.position.target) // This assertion fails when it should pass // Check to make sure column didn't scroll composeTestRule.onNodeWithTag("Item 1").assertIsDisplayed() }I was trying to test the scenario where the user pans the map within the column, and the map camera moves but the column itself doesn't scroll (i.e., the desired behavior).
However, I can't seem to perform
composeTestRule.onNodeWithTag("Map").performTouchInput { swipeUp() }on the map - the entire column just scrolls. This is strange because when you test the app manually it works as intended (i.e., the map moves and the column doesn't scroll). I've tried moving the tag around to different elements (GoogleMap, Box that contains map, etc.) and referencing the composable with other selectors as well (e.g.,onChild()) but behavior is same.I'm not sure if I'm missing something in this test, or if this is a larger issue with UI testing and maps-compose (possibly related to #126?).
Environment details
Main branch as of 1bf8cb0
Steps to reproduce
testPanMapUp_MapCameraChangesColumnDoesNotScroll()and run the testWhat I see
Test fails
What I expect
Test pass
Stack trace