1package com.peachpasswords.autofill23import android.content.Intent4import android.view.WindowManager5import androidx.test.core.app.ActivityScenario6import androidx.test.core.app.ApplicationProvider7import androidx.test.ext.junit.runners.AndroidJUnit48import androidx.test.platform.app.InstrumentationRegistry9import org.junit.Assert.assertTrue10import org.junit.Test11import org.junit.runner.RunWith121314151617181920212223@RunWith(AndroidJUnit4::class)24class AutofillFlagSecureTest {25 @Test26 fun pickerWindowActuallyEnablesFlagSecure() {27 val context = InstrumentationRegistry.getInstrumentation().targetContext28 assertTrue(29 "target must be release or its correctly suffixed debug id",30 context.packageName == "com.peachpasswords" ||31 context.packageName == "com.peachpasswords.debug",32 )33 34 35 val intent = Intent(context, AutofillEntryPickerActivity::class.java)36 val scenario = ActivityScenario.launch<AutofillEntryPickerActivity>(intent)37 try {38 scenario.onActivity { activity ->39 assertTrue(40 "autofill picker window must set FLAG_SECURE",41 activity.window.attributes.flags and WindowManager.LayoutParams.FLAG_SECURE != 0,42 )43 }44 } finally {45 scenario.close()46 }47 }48}