PeachIntentRouterTest.kt

1.5 KB · raw

1package com.peachpasswords23import org.junit.Assert.assertEquals4import org.junit.Assert.assertNull5import org.junit.Test67class PeachIntentRouterTest {89    @Test fun maps_every_declared_shortcut_action() {10        assertEquals(PendingAction.Search, routeAction(PeachActions.SEARCH))11        assertEquals(PendingAction.AddEntry, routeAction(PeachActions.ADD))12        assertEquals(PendingAction.Pair, routeAction(PeachActions.PAIR))13        assertEquals(PendingAction.PasskeyUnlock, routeAction(PeachActions.PASSKEY_UNLOCK))14    }1516    /** The action strings are a contract with shortcuts.xml — a rename there must fail here. */17    @Test fun action_strings_match_the_shortcuts_manifest() {18        assertEquals("com.peachpasswords.action.SEARCH", PeachActions.SEARCH)19        assertEquals("com.peachpasswords.action.ADD", PeachActions.ADD)20        assertEquals("com.peachpasswords.action.PAIR", PeachActions.PAIR)21        assertEquals("com.peachpasswords.passkeys.ACTION_PASSKEY_UNLOCK", PeachActions.PASSKEY_UNLOCK)22    }2324    @Test fun plain_launch_and_unknown_actions_route_nowhere() {25        assertNull(routeAction(null))26        assertNull(routeAction("android.intent.action.MAIN"))27        assertNull(routeAction(""))28    }2930    @Test fun queue_holds_one_request_until_consumed() {31        PendingActionQueue.request(PendingAction.Search)32        PendingActionQueue.request(PendingAction.Pair)33        assertEquals(PendingAction.Pair, PendingActionQueue.pending.value)34        PendingActionQueue.consume()35        assertNull(PendingActionQueue.pending.value)36    }37}