package com.peachpasswords import android.content.Intent import android.net.Uri import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class MainActivityDeepLinkTest { @Test fun merged_manifest_keeps_main_activity_launcher_only_and_rejects_peach_uri() { val context = InstrumentationRegistry.getInstrumentation().targetContext val packageManager = context.packageManager val launcher = Intent(Intent.ACTION_MAIN) .addCategory(Intent.CATEGORY_LAUNCHER) .setPackage(context.packageName) val launcherMatches = packageManager.queryIntentActivities(launcher, 0) assertEquals(1, launcherMatches.count { it.activityInfo.name == MainActivity::class.java.name }) val peachUri = Intent(Intent.ACTION_VIEW, Uri.parse("peach://anything")) .addCategory(Intent.CATEGORY_BROWSABLE) assertFalse( "peach://anything must not resolve to Peach", packageManager.queryIntentActivities(peachUri, 0).any { it.activityInfo.packageName == context.packageName }, ) } }