package com.peachpasswords.qa import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import java.io.BufferedReader import java.io.InputStreamReader import org.junit.Assert.assertTrue import org.junit.Test import org.junit.runner.RunWith /** * Emulator-QA probe: does the autofill framework issue fill requests for a * native form at all? Launches [QaFormActivity] in the TEST package (a * different package from the Peach autofill service, so the framework will * fill it), taps the username field, then reads `dumpsys autofill` * (shell-priv via UiAutomation) and asserts a session mentions the test * package. If this fails, autofill is blocked emulator-wide; if it passes, * a Chrome-specific problem is confirmed. */ @RunWith(AndroidJUnit4::class) class QaFormAutofillTest { @Test fun frameworkIssuesFillRequestForNativeForm() { shell("am start -n com.peachpasswords.debug.test/com.peachpasswords.qa.QaFormActivity") Thread.sleep(3000) // Username EditText: top of screen, full width (padding 48/96 in the activity). shell("input tap 360 150") Thread.sleep(4000) val dump = shell("dumpsys autofill") val mentions = dump.lineSequence() .filter { it.contains("com.peachpasswords.debug.test") } .take(10) .joinToString("\n") assertTrue( "no autofill session for the QA form — framework never issued a fill request.\n" + "dumpsys excerpt:\n$mentions", mentions.isNotEmpty(), ) } private fun shell(command: String): String { val instrumentation = InstrumentationRegistry.getInstrumentation() instrumentation.uiAutomation.executeShellCommand(command).use { pfd -> BufferedReader(InputStreamReader(android.os.ParcelFileDescriptor.AutoCloseInputStream(pfd))).use { return it.readText() } } } }