fix debug screen zoom control bug#538
Conversation
…er interactive controls were missing from the Android Accessibility tree—causing automated test failures on some devices—due to passing `null` to the `interactionSource` parameter in `clickable` modifiers.
There was a problem hiding this comment.
Code Review
This pull request introduces UI Automator compatibility tests in ExternalAutomationCompatibilityTest, expands the debug overlay tests, and updates several Compose components to use a remembered MutableInteractionSource instead of null in clickable modifiers. The review feedback correctly identifies multiple violations of the repository style guide where JUnit's assertNotNull was used instead of Google Truth's assertWithMessage assertions.
| } | ||
|
|
||
| companion object { | ||
| private const val TIMEOUT_MS = 5000L |
There was a problem hiding this comment.
Since we are waiting for the Capture and Flip buttons right after runMainActivityScenarioTest launches the app, we are subject to the same cold-start emulator delays (like virtual camera HAL initialization) that the rest of the app tests face.
Instead of defining a custom 5000ms timeout here, could we import and use APP_START_TIMEOUT_MILLIS (which is 20,000ms) from UiTestUtil.kt for the initial button checks? We can also use DEFAULT_TIMEOUT_MILLIS for the subsequent dialog checks. Using the centralized timeouts helps keep our CI flakiness mitigations consistent across the codebase!
| @Before | ||
| fun setUp() { | ||
| device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
| } |
There was a problem hiding this comment.
Let's add an @After block to clean up the device state. Since the setZoomRatio test opens a dialog and interacts with a text field, we should ensure the screen is cleared for the next test.
@After
fun tearDown() {
device.pressBack()
device.pressHome()
}| fun verifyUiAutomator_canFindCaptureControls() { | ||
| runMainActivityScenarioTest { | ||
| // Wait for the capture button to be visible to UI Automator via Resource ID | ||
| val captureButton = device.wait(Until.findObject(By.res(CAPTURE_BUTTON)), TIMEOUT_MS) |
There was a problem hiding this comment.
To ensure maximum compatibility across different Android OS versions in ATP/TAP, it's safer to provide the fully-qualified package format for UIAutomator's By.res(). Stricter OS versions will sometimes fail to match bare resource strings.
val pkg = InstrumentationRegistry.getInstrumentation().targetContext.packageName
val captureButton = device.wait(Until.findObject(By.res(pkg, CAPTURE_BUTTON)), TIMEOUT_MS)
fix debug screen zoom control bug where debug zoom controls were missing from accessibility tree, which led to automated test failures on some devices.