package com.peachpasswords import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Test class PeachIntentRouterTest { @Test fun maps_every_declared_shortcut_action() { assertEquals(PendingAction.Search, routeAction(PeachActions.SEARCH)) assertEquals(PendingAction.AddEntry, routeAction(PeachActions.ADD)) assertEquals(PendingAction.Pair, routeAction(PeachActions.PAIR)) assertEquals(PendingAction.PasskeyUnlock, routeAction(PeachActions.PASSKEY_UNLOCK)) } /** The action strings are a contract with shortcuts.xml — a rename there must fail here. */ @Test fun action_strings_match_the_shortcuts_manifest() { assertEquals("com.peachpasswords.action.SEARCH", PeachActions.SEARCH) assertEquals("com.peachpasswords.action.ADD", PeachActions.ADD) assertEquals("com.peachpasswords.action.PAIR", PeachActions.PAIR) assertEquals("com.peachpasswords.passkeys.ACTION_PASSKEY_UNLOCK", PeachActions.PASSKEY_UNLOCK) } @Test fun plain_launch_and_unknown_actions_route_nowhere() { assertNull(routeAction(null)) assertNull(routeAction("android.intent.action.MAIN")) assertNull(routeAction("")) } @Test fun queue_holds_one_request_until_consumed() { PendingActionQueue.request(PendingAction.Search) PendingActionQueue.request(PendingAction.Pair) assertEquals(PendingAction.Pair, PendingActionQueue.pending.value) PendingActionQueue.consume() assertNull(PendingActionQueue.pending.value) } }