AutofillChipBudgetTest.kt

2.1 KB · raw

1package com.peachpasswords.autofill23import org.junit.Assert.assertEquals4import org.junit.Test56/**7 * Chip-slot budget after the v2.14.8 refinement. The "+ Save to Peach" create8 * chip was removed in v2.14.6, but its reserved inline slot lingered -- with9 * 2 specs and no 2FA chip the user saw ONLY the "Search Peach" chip and an10 * empty slot. Now the picker reserves one slot (plus one more for the 2FA11 * chip when eligible) and entries get everything else.12 */13class AutofillChipBudgetTest {14    @Test fun no_specs_means_no_chips() {15        assertEquals(0, inlineSystemChipCount(0, otpEligible = false))16        assertEquals(0, inlineSystemChipCount(0, otpEligible = true))17        assertEquals(0, inlineChipBudget(0, otpEligible = false))18        assertEquals(0, inlineChipBudget(0, otpEligible = true))19    }2021    @Test fun without_otp_only_the_picker_slot_is_reserved() {22        assertEquals(1, inlineSystemChipCount(1, otpEligible = false))23        assertEquals(1, inlineSystemChipCount(2, otpEligible = false))24        assertEquals(1, inlineSystemChipCount(5, otpEligible = false))25        assertEquals(1, inlineSystemChipCount(9, otpEligible = false))26        // Every non-reserved slot goes to entry chips.27        assertEquals(0, inlineChipBudget(1, otpEligible = false))28        assertEquals(1, inlineChipBudget(2, otpEligible = false))29        assertEquals(2, inlineChipBudget(3, otpEligible = false))30        assertEquals(4, inlineChipBudget(5, otpEligible = false))31        assertEquals(8, inlineChipBudget(9, otpEligible = false))32    }3334    @Test fun with_otp_the_picker_and_2fa_chip_are_reserved() {35        assertEquals(2, inlineSystemChipCount(2, otpEligible = true))36        assertEquals(2, inlineSystemChipCount(3, otpEligible = true))37        assertEquals(2, inlineSystemChipCount(9, otpEligible = true))38        assertEquals(0, inlineChipBudget(1, otpEligible = true))39        assertEquals(0, inlineChipBudget(2, otpEligible = true))40        assertEquals(1, inlineChipBudget(3, otpEligible = true))41        assertEquals(7, inlineChipBudget(9, otpEligible = true))42    }43}