diff options
Diffstat (limited to 'tools/tests')
| -rw-r--r-- | tools/tests/test_gen_fixture_wrap.py | 8 | ||||
| -rw-r--r-- | tools/tests/test_ui_flow.py | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/tools/tests/test_gen_fixture_wrap.py b/tools/tests/test_gen_fixture_wrap.py index c7b11d5..cc8e907 100644 --- a/tools/tests/test_gen_fixture_wrap.py +++ b/tools/tests/test_gen_fixture_wrap.py @@ -33,6 +33,14 @@ def test_generated_wrap_matches_the_fixture() -> None: assert gen_fixture_wrap.MASTER_KEY.hex() == fixture_constant("FIXTURE_MASTER_KEY") +@pytest.mark.skipif(shutil.which("openssl") is None, reason="needs openssl for AES") +def test_generated_legacy_wrap_matches_the_fixture() -> None: + legacy = gen_fixture_wrap.LEGACY_PIN + assert gen_fixture_wrap.fixture_wrap(legacy).hex() == fixture_constant("FIXTURE_LEGACY_WRAP") + assert legacy.decode() == fixture_constant("FIXTURE_LEGACY_PIN") + assert len(legacy) > gen_fixture_wrap.PIN_DIGITS # a legacy length: shows the extra dots + + def test_fixture_pin_has_the_new_pin_length() -> None: assert gen_fixture_wrap.PIN.decode() == fixture_constant("FIXTURE_PIN") assert len(gen_fixture_wrap.PIN) == gen_fixture_wrap.PIN_DIGITS diff --git a/tools/tests/test_ui_flow.py b/tools/tests/test_ui_flow.py index d98b4c2..5e359c2 100644 --- a/tools/tests/test_ui_flow.py +++ b/tools/tests/test_ui_flow.py @@ -81,3 +81,13 @@ def test_barcodes_on_reads_a_drawn_code(tmp_path: Path) -> None: screen = Image.open(path).convert("RGB") assert ui_flow.barcodes_on(screen) == ["OTPW stress"] assert ui_flow.barcodes_on(Image.new("RGB", (100, 100), "white")) == [] + + +def test_vertical_shift_measures_a_scrolled_list() -> None: + rows = Image.new("L", (60, 400), 0) + for top in range(0, 400, 50): # bands of different shades, like menu items + rows.paste(40 + top // 2, (5, top + 5, 55, top + 40)) + before = rows.crop((0, 0, 60, 200)) + assert ui_flow.vertical_shift(before, rows.crop((0, 37, 60, 237))) == 37 + assert ui_flow.vertical_shift(rows.crop((0, 37, 60, 237)), before) == -37 + assert ui_flow.vertical_shift(before, before) == 0 |
