1package com.peachpasswords.qa23import androidx.test.ext.junit.runners.AndroidJUnit44import androidx.test.platform.app.InstrumentationRegistry5import java.io.BufferedReader6import java.io.InputStreamReader7import org.junit.Assert.assertTrue8import org.junit.Test9import org.junit.runner.RunWith1011121314151617181920@RunWith(AndroidJUnit4::class)21class QaFormAutofillTest {2223 @Test24 fun frameworkIssuesFillRequestForNativeForm() {25 shell("am start -n com.peachpasswords.debug.test/com.peachpasswords.qa.QaFormActivity")26 Thread.sleep(3000)27 28 shell("input tap 360 150")29 Thread.sleep(4000)30 val dump = shell("dumpsys autofill")31 val mentions = dump.lineSequence()32 .filter { it.contains("com.peachpasswords.debug.test") }33 .take(10)34 .joinToString("\n")35 assertTrue(36 "no autofill session for the QA form — framework never issued a fill request.\n" +37 "dumpsys excerpt:\n$mentions",38 mentions.isNotEmpty(),39 )40 }4142 private fun shell(command: String): String {43 val instrumentation = InstrumentationRegistry.getInstrumentation()44 instrumentation.uiAutomation.executeShellCommand(command).use { pfd ->45 BufferedReader(InputStreamReader(android.os.ParcelFileDescriptor.AutoCloseInputStream(pfd))).use {46 return it.readText()47 }48 }49 }50}