package com.peachpasswords.autofill import org.junit.Assert.assertEquals import org.junit.Test /** * Chip-slot budget after the v2.14.8 refinement. The "+ Save to Peach" create * chip was removed in v2.14.6, but its reserved inline slot lingered -- with * 2 specs and no 2FA chip the user saw ONLY the "Search Peach" chip and an * empty slot. Now the picker reserves one slot (plus one more for the 2FA * chip when eligible) and entries get everything else. */ class AutofillChipBudgetTest { @Test fun no_specs_means_no_chips() { assertEquals(0, inlineSystemChipCount(0, otpEligible = false)) assertEquals(0, inlineSystemChipCount(0, otpEligible = true)) assertEquals(0, inlineChipBudget(0, otpEligible = false)) assertEquals(0, inlineChipBudget(0, otpEligible = true)) } @Test fun without_otp_only_the_picker_slot_is_reserved() { assertEquals(1, inlineSystemChipCount(1, otpEligible = false)) assertEquals(1, inlineSystemChipCount(2, otpEligible = false)) assertEquals(1, inlineSystemChipCount(5, otpEligible = false)) assertEquals(1, inlineSystemChipCount(9, otpEligible = false)) // Every non-reserved slot goes to entry chips. assertEquals(0, inlineChipBudget(1, otpEligible = false)) assertEquals(1, inlineChipBudget(2, otpEligible = false)) assertEquals(2, inlineChipBudget(3, otpEligible = false)) assertEquals(4, inlineChipBudget(5, otpEligible = false)) assertEquals(8, inlineChipBudget(9, otpEligible = false)) } @Test fun with_otp_the_picker_and_2fa_chip_are_reserved() { assertEquals(2, inlineSystemChipCount(2, otpEligible = true)) assertEquals(2, inlineSystemChipCount(3, otpEligible = true)) assertEquals(2, inlineSystemChipCount(9, otpEligible = true)) assertEquals(0, inlineChipBudget(1, otpEligible = true)) assertEquals(0, inlineChipBudget(2, otpEligible = true)) assertEquals(1, inlineChipBudget(3, otpEligible = true)) assertEquals(7, inlineChipBudget(9, otpEligible = true)) } }