AutofillPickerSpecSelectionTest.kt

1.2 KB · raw

1package com.peachpasswords.autofill23import org.junit.Assert.assertEquals4import org.junit.Assert.assertNull5import org.junit.Test67/**8 * v2.14.6 regression: with only one inline spec offered by the framework9 * (common on 2FA-only pages after username/password submit), the picker10 * spec and OTP spec would both target specs[0] and the picker dataset,11 * being added last, would clobber the OTP chip inline. The picker now12 * falls back to the system menu in the single-spec case so the OTP chip13 * keeps the only inline slot.14 */15class AutofillPickerSpecSelectionTest {16    private val a = "spec-A"17    private val b = "spec-B"18    private val c = "spec-C"1920    @Test fun empty_specs_yield_null_picker() {21        assertNull(pickerSpecFor(emptyList()))22    }2324    @Test fun single_spec_yields_null_picker_so_otp_keeps_the_slot() {25        assertNull(pickerSpecFor(listOf(a)))26    }2728    @Test fun two_specs_put_picker_in_the_first_slot() {29        assertEquals(a, pickerSpecFor(listOf(a, b)))30    }3132    @Test fun three_specs_put_picker_in_the_middle_slot() {33        assertEquals(b, pickerSpecFor(listOf(a, b, c)))34    }3536    @Test fun four_specs_put_picker_in_the_third_slot() {37        assertEquals(c, pickerSpecFor(listOf(a, b, c, "spec-D")))38    }39}