diff --git a/tests/integration/nano/snapshots/nanos/home.png b/tests/integration/nano/snapshots/nanos/test_menu/test_home_menu/00000.png similarity index 100% rename from tests/integration/nano/snapshots/nanos/home.png rename to tests/integration/nano/snapshots/nanos/test_menu/test_home_menu/00000.png diff --git a/tests/integration/nano/snapshots/nanos/version.png b/tests/integration/nano/snapshots/nanos/test_menu/test_home_menu/00001.png similarity index 100% rename from tests/integration/nano/snapshots/nanos/version.png rename to tests/integration/nano/snapshots/nanos/test_menu/test_home_menu/00001.png diff --git a/tests/integration/nano/snapshots/nanos/settings.png b/tests/integration/nano/snapshots/nanos/test_menu/test_home_menu/00002.png similarity index 100% rename from tests/integration/nano/snapshots/nanos/settings.png rename to tests/integration/nano/snapshots/nanos/test_menu/test_home_menu/00002.png diff --git a/tests/integration/nano/snapshots/nanos/quit.png b/tests/integration/nano/snapshots/nanos/test_menu/test_home_menu/00003.png similarity index 100% rename from tests/integration/nano/snapshots/nanos/quit.png rename to tests/integration/nano/snapshots/nanos/test_menu/test_home_menu/00003.png diff --git a/tests/integration/nano/snapshots/nanos/settings_expert_mode_disabled.png b/tests/integration/nano/snapshots/nanos/test_menu/test_settings_menu/00000.png similarity index 100% rename from tests/integration/nano/snapshots/nanos/settings_expert_mode_disabled.png rename to tests/integration/nano/snapshots/nanos/test_menu/test_settings_menu/00000.png diff --git a/tests/integration/nano/snapshots/nanos/settings_blindsign_off.png b/tests/integration/nano/snapshots/nanos/test_menu/test_settings_menu/00001.png similarity index 100% rename from tests/integration/nano/snapshots/nanos/settings_blindsign_off.png rename to tests/integration/nano/snapshots/nanos/test_menu/test_settings_menu/00001.png diff --git a/tests/integration/nano/snapshots/nanos/back.png b/tests/integration/nano/snapshots/nanos/test_menu/test_settings_menu/00002.png similarity index 100% rename from tests/integration/nano/snapshots/nanos/back.png rename to tests/integration/nano/snapshots/nanos/test_menu/test_settings_menu/00002.png diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_settings_menu/00003.png b/tests/integration/nano/snapshots/nanos/test_menu/test_settings_menu/00003.png new file mode 100644 index 000000000..056ffc401 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_settings_menu/00003.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00000.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00000.png new file mode 100644 index 000000000..056ffc401 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00000.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00001.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00001.png new file mode 100644 index 000000000..13709e273 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00001.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00002.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00002.png new file mode 100644 index 000000000..34cf547a2 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00002.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00003.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00003.png new file mode 100644 index 000000000..a10bdaeac Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00003.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00004.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00004.png new file mode 100644 index 000000000..834142cf8 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00004.png differ diff --git a/tests/integration/nano/snapshots/nanos/settings_blindsign_on.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00005.png similarity index 100% rename from tests/integration/nano/snapshots/nanos/settings_blindsign_on.png rename to tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00005.png diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00006.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00006.png new file mode 100644 index 000000000..b5c1b1cbe Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00006.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00007.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00007.png new file mode 100644 index 000000000..056ffc401 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00007.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00008.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00008.png new file mode 100644 index 000000000..13709e273 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00008.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00009.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00009.png new file mode 100644 index 000000000..34cf547a2 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00009.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00010.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00010.png new file mode 100644 index 000000000..a10bdaeac Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00010.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00011.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00011.png new file mode 100644 index 000000000..1e5bfd2a1 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00011.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00012.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00012.png new file mode 100644 index 000000000..834142cf8 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00012.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00013.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00013.png new file mode 100644 index 000000000..b5c1b1cbe Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00013.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00014.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00014.png new file mode 100644 index 000000000..056ffc401 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_blindsign/00014.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00000.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00000.png new file mode 100644 index 000000000..056ffc401 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00000.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00001.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00001.png new file mode 100644 index 000000000..13709e273 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00001.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00002.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00002.png new file mode 100644 index 000000000..34cf547a2 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00002.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00003.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00003.png new file mode 100644 index 000000000..a10bdaeac Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00003.png differ diff --git a/tests/integration/nano/snapshots/nanos/settings_expert_mode_enabled.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00004.png similarity index 100% rename from tests/integration/nano/snapshots/nanos/settings_expert_mode_enabled.png rename to tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00004.png diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00005.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00005.png new file mode 100644 index 000000000..834142cf8 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00005.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00006.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00006.png new file mode 100644 index 000000000..b5c1b1cbe Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00006.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00007.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00007.png new file mode 100644 index 000000000..056ffc401 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00007.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00008.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00008.png new file mode 100644 index 000000000..13709e273 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00008.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00009.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00009.png new file mode 100644 index 000000000..34cf547a2 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00009.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00010.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00010.png new file mode 100644 index 000000000..1b968b6c2 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00010.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00011.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00011.png new file mode 100644 index 000000000..a10bdaeac Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00011.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00012.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00012.png new file mode 100644 index 000000000..834142cf8 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00012.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00013.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00013.png new file mode 100644 index 000000000..b5c1b1cbe Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00013.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00014.png b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00014.png new file mode 100644 index 000000000..056ffc401 Binary files /dev/null and b/tests/integration/nano/snapshots/nanos/test_menu/test_toggle_expert_mode/00014.png differ diff --git a/tests/integration/nano/snapshots/nanosp/home.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_home_menu/00000.png similarity index 100% rename from tests/integration/nano/snapshots/nanosp/home.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_home_menu/00000.png diff --git a/tests/integration/nano/snapshots/nanosp/version.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_home_menu/00001.png similarity index 100% rename from tests/integration/nano/snapshots/nanosp/version.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_home_menu/00001.png diff --git a/tests/integration/nano/snapshots/nanosp/settings.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_home_menu/00002.png similarity index 100% rename from tests/integration/nano/snapshots/nanosp/settings.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_home_menu/00002.png diff --git a/tests/integration/nano/snapshots/nanosp/quit.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_home_menu/00003.png similarity index 100% rename from tests/integration/nano/snapshots/nanosp/quit.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_home_menu/00003.png diff --git a/tests/integration/nano/snapshots/nanosp/settings_expert_mode_disabled.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_settings_menu/00000.png similarity index 100% rename from tests/integration/nano/snapshots/nanosp/settings_expert_mode_disabled.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_settings_menu/00000.png diff --git a/tests/integration/nano/snapshots/nanosp/settings_blindsign_off.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_settings_menu/00001.png similarity index 100% rename from tests/integration/nano/snapshots/nanosp/settings_blindsign_off.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_settings_menu/00001.png diff --git a/tests/integration/nano/snapshots/nanosp/back.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_settings_menu/00002.png similarity index 100% rename from tests/integration/nano/snapshots/nanosp/back.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_settings_menu/00002.png diff --git a/tests/integration/nano/snapshots/nanox/home.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_settings_menu/00003.png similarity index 100% rename from tests/integration/nano/snapshots/nanox/home.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_settings_menu/00003.png diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00000.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00000.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00000.png differ diff --git a/tests/integration/nano/snapshots/nanox/version.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00001.png similarity index 100% rename from tests/integration/nano/snapshots/nanox/version.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00001.png diff --git a/tests/integration/nano/snapshots/nanox/settings.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00002.png similarity index 100% rename from tests/integration/nano/snapshots/nanox/settings.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00002.png diff --git a/tests/integration/nano/snapshots/nanox/settings_expert_mode_disabled.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00003.png similarity index 100% rename from tests/integration/nano/snapshots/nanox/settings_expert_mode_disabled.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00003.png diff --git a/tests/integration/nano/snapshots/nanox/settings_blindsign_off.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00004.png similarity index 100% rename from tests/integration/nano/snapshots/nanox/settings_blindsign_off.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00004.png diff --git a/tests/integration/nano/snapshots/nanosp/settings_blindsign_on.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00005.png similarity index 100% rename from tests/integration/nano/snapshots/nanosp/settings_blindsign_on.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00005.png diff --git a/tests/integration/nano/snapshots/nanox/back.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00006.png similarity index 100% rename from tests/integration/nano/snapshots/nanox/back.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00006.png diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00007.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00007.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00007.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00008.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00008.png new file mode 100644 index 000000000..235d4f516 Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00008.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00009.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00009.png new file mode 100644 index 000000000..d885fe67b Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00009.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00010.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00010.png new file mode 100644 index 000000000..22d3f5c2e Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00010.png differ diff --git a/tests/integration/nano/snapshots/nanox/settings_blindsign_on.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00011.png similarity index 100% rename from tests/integration/nano/snapshots/nanox/settings_blindsign_on.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00011.png diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00012.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00012.png new file mode 100644 index 000000000..3ea6ff33a Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00012.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00013.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00013.png new file mode 100644 index 000000000..e06738f46 Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00013.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00014.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00014.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_blindsign/00014.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00000.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00000.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00000.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00001.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00001.png new file mode 100644 index 000000000..235d4f516 Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00001.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00002.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00002.png new file mode 100644 index 000000000..d885fe67b Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00002.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00003.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00003.png new file mode 100644 index 000000000..22d3f5c2e Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00003.png differ diff --git a/tests/integration/nano/snapshots/nanosp/settings_expert_mode_enabled.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00004.png similarity index 100% rename from tests/integration/nano/snapshots/nanosp/settings_expert_mode_enabled.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00004.png diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00005.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00005.png new file mode 100644 index 000000000..3ea6ff33a Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00005.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00006.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00006.png new file mode 100644 index 000000000..e06738f46 Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00006.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00007.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00007.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00007.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00008.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00008.png new file mode 100644 index 000000000..235d4f516 Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00008.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00009.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00009.png new file mode 100644 index 000000000..d885fe67b Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00009.png differ diff --git a/tests/integration/nano/snapshots/nanox/settings_expert_mode_enabled.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00010.png similarity index 100% rename from tests/integration/nano/snapshots/nanox/settings_expert_mode_enabled.png rename to tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00010.png diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00011.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00011.png new file mode 100644 index 000000000..22d3f5c2e Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00011.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00012.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00012.png new file mode 100644 index 000000000..3ea6ff33a Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00012.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00013.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00013.png new file mode 100644 index 000000000..e06738f46 Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00013.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00014.png b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00014.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanosp/test_menu/test_toggle_expert_mode/00014.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00000.png b/tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00000.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00000.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00001.png b/tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00001.png new file mode 100644 index 000000000..235d4f516 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00001.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00002.png b/tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00002.png new file mode 100644 index 000000000..d885fe67b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00002.png differ diff --git a/tests/integration/nano/snapshots/nanox/quit.png b/tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00003.png similarity index 100% rename from tests/integration/nano/snapshots/nanox/quit.png rename to tests/integration/nano/snapshots/nanox/test_menu/test_home_menu/00003.png diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00000.png b/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00000.png new file mode 100644 index 000000000..22d3f5c2e Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00000.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00001.png b/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00001.png new file mode 100644 index 000000000..3ea6ff33a Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00001.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00002.png b/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00002.png new file mode 100644 index 000000000..e06738f46 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00002.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00003.png b/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00003.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_settings_menu/00003.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00000.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00000.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00000.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00001.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00001.png new file mode 100644 index 000000000..235d4f516 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00001.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00002.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00002.png new file mode 100644 index 000000000..d885fe67b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00002.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00003.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00003.png new file mode 100644 index 000000000..22d3f5c2e Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00003.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00004.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00004.png new file mode 100644 index 000000000..3ea6ff33a Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00004.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00005.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00005.png new file mode 100644 index 000000000..94d6d85b3 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00005.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00006.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00006.png new file mode 100644 index 000000000..e06738f46 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00006.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00007.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00007.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00007.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00008.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00008.png new file mode 100644 index 000000000..235d4f516 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00008.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00009.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00009.png new file mode 100644 index 000000000..d885fe67b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00009.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00010.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00010.png new file mode 100644 index 000000000..22d3f5c2e Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00010.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00011.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00011.png new file mode 100644 index 000000000..94d6d85b3 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00011.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00012.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00012.png new file mode 100644 index 000000000..3ea6ff33a Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00012.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00013.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00013.png new file mode 100644 index 000000000..e06738f46 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00013.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00014.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00014.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_blindsign/00014.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00000.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00000.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00000.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00001.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00001.png new file mode 100644 index 000000000..235d4f516 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00001.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00002.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00002.png new file mode 100644 index 000000000..d885fe67b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00002.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00003.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00003.png new file mode 100644 index 000000000..22d3f5c2e Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00003.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00004.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00004.png new file mode 100644 index 000000000..f7e9acdbd Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00004.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00005.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00005.png new file mode 100644 index 000000000..3ea6ff33a Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00005.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00006.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00006.png new file mode 100644 index 000000000..e06738f46 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00006.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00007.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00007.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00007.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00008.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00008.png new file mode 100644 index 000000000..235d4f516 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00008.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00009.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00009.png new file mode 100644 index 000000000..d885fe67b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00009.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00010.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00010.png new file mode 100644 index 000000000..f7e9acdbd Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00010.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00011.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00011.png new file mode 100644 index 000000000..22d3f5c2e Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00011.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00012.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00012.png new file mode 100644 index 000000000..3ea6ff33a Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00012.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00013.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00013.png new file mode 100644 index 000000000..e06738f46 Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00013.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00014.png b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00014.png new file mode 100644 index 000000000..08e112b5b Binary files /dev/null and b/tests/integration/nano/snapshots/nanox/test_menu/test_toggle_expert_mode/00014.png differ diff --git a/tests/integration/nano/test_menu.py b/tests/integration/nano/test_menu.py index 722e04e3b..97ceb37bd 100755 --- a/tests/integration/nano/test_menu.py +++ b/tests/integration/nano/test_menu.py @@ -16,68 +16,67 @@ """Gathering of tests related to app menu.""" -from utils.app import Screen, TezosAppScreen - -def test_menu(app: TezosAppScreen): - """Check main menu flow""" - app.assert_screen(Screen.HOME) - app.backend.right_click() - app.assert_screen(Screen.VERSION) - app.backend.both_click() - app.assert_screen(Screen.VERSION) - app.backend.right_click() - app.assert_screen(Screen.SETTINGS) - app.backend.right_click() - app.assert_screen(Screen.QUIT) - app.backend.left_click() - app.assert_screen(Screen.SETTINGS) - app.backend.left_click() - app.assert_screen(Screen.VERSION) - app.backend.left_click() - app.assert_screen(Screen.HOME) - app.backend.both_click() - app.assert_screen(Screen.HOME) - app.backend.left_click() - app.assert_screen(Screen.QUIT) - app.backend.right_click() - app.assert_screen(Screen.HOME) - app.backend.right_click() - app.assert_screen(Screen.VERSION) - app.backend.right_click() - app.assert_screen(Screen.SETTINGS) - app.backend.right_click() - app.assert_screen(Screen.QUIT) - app.backend.right_click() - app.assert_screen(Screen.HOME) - app.backend.right_click() - app.assert_screen(Screen.VERSION) - - # Check Settings menu operation - app.backend.right_click() - app.assert_screen(Screen.SETTINGS) - app.backend.both_click() - app.assert_screen(Screen.SETTINGS_EXPERT_MODE_DISABLED) - app.backend.both_click() - app.assert_screen(Screen.SETTINGS_EXPERT_MODE_ENABLED) - app.backend.right_click() - app.assert_screen(Screen.SETTINGS_BLINDSIGN_OFF) - app.backend.both_click() - app.assert_screen(Screen.SETTINGS_BLINDSIGN_ON) - app.backend.both_click() - app.assert_screen(Screen.SETTINGS_BLINDSIGN_OFF) - app.backend.right_click() - app.assert_screen(Screen.SETTINGS_BACK) - app.backend.left_click() - app.assert_screen(Screen.SETTINGS_BLINDSIGN_OFF) - app.backend.left_click() - app.assert_screen(Screen.SETTINGS_EXPERT_MODE_ENABLED) - app.backend.left_click() - app.assert_screen(Screen.SETTINGS_BACK) - app.backend.right_click() - app.assert_screen(Screen.SETTINGS_EXPERT_MODE_ENABLED) - app.backend.left_click() - app.assert_screen(Screen.SETTINGS_BACK) - app.backend.both_click() - app.assert_screen(Screen.HOME) +from pathlib import Path +from typing import List, Union + +import requests + +from ragger.navigator import NavIns, NavInsID + +from utils.backend import TezosBackend +from utils.app import TezosAppScreen + + +def test_home_menu(app: TezosAppScreen, snapshot_dir: Path): + """Check home menu flow""" + instructions: List[Union[NavIns, NavInsID]] = [ + # Home + NavInsID.RIGHT_CLICK, # Version + NavInsID.RIGHT_CLICK, # Settings + NavInsID.RIGHT_CLICK, # Quit + ] + app.navigate( + instructions=instructions, + snap_path=snapshot_dir, + ) + + +def test_settings_menu(app: TezosAppScreen, snapshot_dir: Path): + """Check settings menu flow""" + app.navigate_to_settings() + instructions: List[Union[NavIns, NavInsID]] = [ + # Expert Mode + NavInsID.RIGHT_CLICK, # Blind Sign + NavInsID.RIGHT_CLICK, # Back + NavInsID.BOTH_CLICK, # Home + ] + app.navigate( + instructions=instructions, + snap_path=snapshot_dir + ) + + +def test_toggle_expert_mode(app: TezosAppScreen, snapshot_dir: Path): + """Check settings' expert_mode toggle""" + snap_idx = app.toggle_expert_mode(snap_path=snapshot_dir) + # Toggle back + app.toggle_expert_mode(snap_start_idx=snap_idx, snap_path=snapshot_dir) + + +def test_toggle_blindsign(app: TezosAppScreen, snapshot_dir: Path): + """Check settings' blindsign toggle""" + snap_idx = app.toggle_blindsign(snap_path=snapshot_dir) + # Toggle back + app.toggle_blindsign(snap_start_idx=snap_idx, snap_path=snapshot_dir) + + +def test_quit(app: TezosAppScreen): + """Check quit app""" + # Home app.backend.left_click() - app._quit() + app.backend.wait_for_screen_change() # Quit + try: + app.backend.both_click() + assert False, "Must have lost connection with speculos" + except requests.exceptions.ConnectionError: + pass diff --git a/tests/integration/nano/test_public_key.py b/tests/integration/nano/test_public_key.py index c175568dc..1670e5f7e 100644 --- a/tests/integration/nano/test_public_key.py +++ b/tests/integration/nano/test_public_key.py @@ -21,7 +21,7 @@ import pytest from utils.account import Account, PublicKey, SigType -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.backend import StatusCode accounts = [ diff --git a/tests/integration/nano/test_sign/operations/test_sign_ballot.py b/tests/integration/nano/test_sign/operations/test_sign_ballot.py index cc1270013..c6ab3ad5c 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_ballot.py +++ b/tests/integration/nano/test_sign/operations/test_sign_ballot.py @@ -18,7 +18,7 @@ from pathlib import Path -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.message import Ballot def test_sign_ballot(app: TezosAppScreen, snapshot_dir: Path): diff --git a/tests/integration/nano/test_sign/operations/test_sign_batched_operations.py b/tests/integration/nano/test_sign/operations/test_sign_batched_operations.py index 5d0b2a990..0b289d627 100644 --- a/tests/integration/nano/test_sign/operations/test_sign_batched_operations.py +++ b/tests/integration/nano/test_sign/operations/test_sign_batched_operations.py @@ -20,7 +20,7 @@ from conftest import requires_device -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.message import ( OperationGroup, Origination, @@ -32,7 +32,7 @@ def test_nanos_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path): """Check signing batch operation""" - app.setup_expert_mode() + app.toggle_expert_mode() message = OperationGroup([ Transaction( @@ -71,7 +71,7 @@ def test_nanos_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path): def test_nanox_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path): """Check signing batch operation""" - app.setup_expert_mode() + app.toggle_expert_mode() message = OperationGroup([ Transaction( @@ -109,7 +109,7 @@ def test_nanox_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path): def test_sign_complex_operation(app: TezosAppScreen, snapshot_dir: Path): """Check signing complex operation""" - app.setup_expert_mode() + app.toggle_expert_mode() message = OperationGroup([ Origination( diff --git a/tests/integration/nano/test_sign/operations/test_sign_delegation.py b/tests/integration/nano/test_sign/operations/test_sign_delegation.py index acf55cd50..75d3241ef 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_delegation.py +++ b/tests/integration/nano/test_sign/operations/test_sign_delegation.py @@ -18,7 +18,7 @@ from pathlib import Path -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.message import Delegation def test_sign_delegation(app: TezosAppScreen, snapshot_dir: Path): diff --git a/tests/integration/nano/test_sign/operations/test_sign_failing_noop.py b/tests/integration/nano/test_sign/operations/test_sign_failing_noop.py index de1233ef6..609c9ef11 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_failing_noop.py +++ b/tests/integration/nano/test_sign/operations/test_sign_failing_noop.py @@ -18,7 +18,7 @@ from pathlib import Path -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.message import FailingNoop def test_sign_failing_noop(app: TezosAppScreen, snapshot_dir: Path): diff --git a/tests/integration/nano/test_sign/operations/test_sign_increase_paid_storage.py b/tests/integration/nano/test_sign/operations/test_sign_increase_paid_storage.py index ade361c0b..b18fc1703 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_increase_paid_storage.py +++ b/tests/integration/nano/test_sign/operations/test_sign_increase_paid_storage.py @@ -18,7 +18,7 @@ from pathlib import Path -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.message import IncreasePaidStorage def test_sign_increase_paid_storage(app: TezosAppScreen, snapshot_dir: Path): diff --git a/tests/integration/nano/test_sign/operations/test_sign_origination.py b/tests/integration/nano/test_sign/operations/test_sign_origination.py index 05a611bfb..53a6a92f7 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_origination.py +++ b/tests/integration/nano/test_sign/operations/test_sign_origination.py @@ -24,7 +24,7 @@ def test_sign_origination(app: TezosAppScreen, snapshot_dir: Path): """Check signing origination""" - app.setup_expert_mode() + app.toggle_expert_mode() message = Origination( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', diff --git a/tests/integration/nano/test_sign/operations/test_sign_proposals.py b/tests/integration/nano/test_sign/operations/test_sign_proposals.py index 2662a796d..948182f71 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_proposals.py +++ b/tests/integration/nano/test_sign/operations/test_sign_proposals.py @@ -18,7 +18,7 @@ from pathlib import Path -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.message import Proposals def test_sign_proposals(app: TezosAppScreen, snapshot_dir: Path): diff --git a/tests/integration/nano/test_sign/operations/test_sign_register_global_constant.py b/tests/integration/nano/test_sign/operations/test_sign_register_global_constant.py index ecdf8e736..ef485011f 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_register_global_constant.py +++ b/tests/integration/nano/test_sign/operations/test_sign_register_global_constant.py @@ -24,7 +24,7 @@ def test_sign_register_global_constant(app: TezosAppScreen, snapshot_dir: Path): """Check signing register global constant""" - app.setup_expert_mode() + app.toggle_expert_mode() message = RegisterGlobalConstant( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', diff --git a/tests/integration/nano/test_sign/operations/test_sign_reveal.py b/tests/integration/nano/test_sign/operations/test_sign_reveal.py index ad8e4f827..05b2bfb83 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_reveal.py +++ b/tests/integration/nano/test_sign/operations/test_sign_reveal.py @@ -18,7 +18,7 @@ from pathlib import Path -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.message import Reveal def test_sign_reveal(app: TezosAppScreen, snapshot_dir: Path): diff --git a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_add_messages.py b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_add_messages.py index 519a7150a..6a0372f7b 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_add_messages.py +++ b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_add_messages.py @@ -18,7 +18,7 @@ from pathlib import Path -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.message import ScRollupAddMessage def test_sign_sc_rollup_add_messages(app: TezosAppScreen, snapshot_dir: Path): diff --git a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_execute_outbox_message.py b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_execute_outbox_message.py index 522152354..f391921a2 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_execute_outbox_message.py +++ b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_execute_outbox_message.py @@ -24,7 +24,7 @@ def test_sign_sc_rollup_execute_outbox_message(app: TezosAppScreen, snapshot_dir: Path): """Check signing smart rollup execute outbox message""" - app.setup_expert_mode() + app.toggle_expert_mode() message = ScRollupExecuteOutboxMessage( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', diff --git a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_originate.py b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_originate.py index 7090c497b..0e9e1c12a 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_originate.py +++ b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_originate.py @@ -44,7 +44,7 @@ def test_sign_sc_rollup_originate(app: TezosAppScreen, whitelist: Optional[List[str]], snapshot_dir: Path): """Check signing smart rollup originate""" - app.setup_expert_mode() + app.toggle_expert_mode() message = ScRollupOriginate( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', diff --git a/tests/integration/nano/test_sign/operations/test_sign_set_consensus_key.py b/tests/integration/nano/test_sign/operations/test_sign_set_consensus_key.py index 2077d1cde..61d8db686 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_set_consensus_key.py +++ b/tests/integration/nano/test_sign/operations/test_sign_set_consensus_key.py @@ -18,7 +18,7 @@ from pathlib import Path -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.message import UpdateConsensusKey def test_sign_set_consensus_key(app: TezosAppScreen, snapshot_dir: Path): diff --git a/tests/integration/nano/test_sign/operations/test_sign_set_deposit_limit.py b/tests/integration/nano/test_sign/operations/test_sign_set_deposit_limit.py index 6ce1ad6cb..4bda6ec6c 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_set_deposit_limit.py +++ b/tests/integration/nano/test_sign/operations/test_sign_set_deposit_limit.py @@ -18,7 +18,7 @@ from pathlib import Path -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.message import SetDepositLimit def test_sign_set_deposit_limit(app: TezosAppScreen, snapshot_dir: Path): diff --git a/tests/integration/nano/test_sign/operations/test_sign_transaction.py b/tests/integration/nano/test_sign/operations/test_sign_transaction.py index cb9171866..18198cfc8 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_transaction.py +++ b/tests/integration/nano/test_sign/operations/test_sign_transaction.py @@ -18,14 +18,14 @@ from pathlib import Path -from utils.app import Screen, ScreenText, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import ScreenText, TezosAppScreen, DEFAULT_ACCOUNT from utils.backend import StatusCode from utils.message import Transaction def test_sign_transaction(app: TezosAppScreen, snapshot_dir: Path): """Check signing transaction""" - app.setup_expert_mode() + app.toggle_expert_mode() message = Transaction( source = 'tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu', @@ -52,7 +52,7 @@ def test_sign_transaction(app: TezosAppScreen, snapshot_dir: Path): def test_reject_transaction(app: TezosAppScreen, snapshot_dir: Path): """Check reject transaction""" - app.setup_expert_mode() + app.toggle_expert_mode() message = Transaction( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', @@ -75,7 +75,7 @@ def test_reject_transaction(app: TezosAppScreen, snapshot_dir: Path): def test_sign_simple_transaction(app: TezosAppScreen, snapshot_dir: Path): """Check sign not complex transaction""" - app.setup_expert_mode() + app.toggle_expert_mode() message = Transaction( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', @@ -123,7 +123,7 @@ def test_too_complex_transaction(app: TezosAppScreen, snapshot_dir: Path): def test_sign_stake_transaction(app: TezosAppScreen, snapshot_dir: Path): """Check sign stake""" - app.setup_expert_mode() + app.toggle_expert_mode() message = Transaction( source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W', @@ -149,7 +149,7 @@ def test_sign_stake_transaction(app: TezosAppScreen, snapshot_dir: Path): def test_sign_unstake_transaction(app: TezosAppScreen, snapshot_dir: Path): """Check sign unstake""" - app.setup_expert_mode() + app.toggle_expert_mode() message = Transaction( source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W', @@ -175,7 +175,7 @@ def test_sign_unstake_transaction(app: TezosAppScreen, snapshot_dir: Path): def test_sign_finalize_unstake_transaction(app: TezosAppScreen, snapshot_dir: Path): """Check sign finalize_unstake""" - app.setup_expert_mode() + app.toggle_expert_mode() message = Transaction( source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W', @@ -201,7 +201,7 @@ def test_sign_finalize_unstake_transaction(app: TezosAppScreen, snapshot_dir: Pa def test_sign_set_delegate_parameters_transaction(app: TezosAppScreen, snapshot_dir: Path): """Check sign set delegate parameters""" - app.setup_expert_mode() + app.toggle_expert_mode() message = Transaction( source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W', @@ -236,7 +236,7 @@ def test_sign_set_delegate_parameters_transaction(app: TezosAppScreen, snapshot_ def test_sign_with_long_hash(app: TezosAppScreen, snapshot_dir: Path): """Check signing transaction with a long destination hash""" - app.setup_expert_mode() + app.toggle_expert_mode() message = Transaction( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', @@ -263,7 +263,7 @@ def test_sign_with_long_hash(app: TezosAppScreen, snapshot_dir: Path): def test_ensure_always_clearsign(app: TezosAppScreen, snapshot_dir: Path): """Check clear signing never blindsign""" - app.setup_expert_mode() + app.toggle_expert_mode() message = Transaction( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', diff --git a/tests/integration/nano/test_sign/operations/test_sign_transfer_ticket.py b/tests/integration/nano/test_sign/operations/test_sign_transfer_ticket.py index 4c1d8a4a3..6ba362b2a 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_transfer_ticket.py +++ b/tests/integration/nano/test_sign/operations/test_sign_transfer_ticket.py @@ -25,7 +25,7 @@ def test_sign_transfer_ticket(app: TezosAppScreen, snapshot_dir: Path): """Check signing transfer ticket""" - app.setup_expert_mode() + app.toggle_expert_mode() message = TransferTicket( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', @@ -54,7 +54,7 @@ def test_sign_transfer_ticket(app: TezosAppScreen, snapshot_dir: Path): def test_nanosp_regression_potential_empty_screen(app: TezosAppScreen, snapshot_dir: Path): """Check signing operation that display potentially empty screens""" - app.setup_expert_mode() + app.toggle_expert_mode() message = TransferTicket( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', diff --git a/tests/integration/nano/test_sign/test_apdu_sign.py b/tests/integration/nano/test_sign/test_apdu_sign.py index d1d7f1f51..c7506ec0d 100644 --- a/tests/integration/nano/test_sign/test_apdu_sign.py +++ b/tests/integration/nano/test_sign/test_apdu_sign.py @@ -20,7 +20,7 @@ from conftest import requires_device from utils.account import Account -from utils.app import send_and_navigate, Screen, ScreenText, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import send_and_navigate, ScreenText, TezosAppScreen, DEFAULT_ACCOUNT from utils.message import Message, MichelineExpr, Transaction def test_sign_micheline_without_hash(app: TezosAppScreen, snapshot_dir: Path): @@ -41,7 +41,7 @@ def test_sign_micheline_without_hash(app: TezosAppScreen, snapshot_dir: Path): def test_sign_with_small_packet(app: TezosAppScreen, snapshot_dir: Path): """Check signing using small packet instead of full size packets""" - app.setup_expert_mode() + app.toggle_expert_mode() def check_sign_with_small_packet( account: Account, diff --git a/tests/integration/nano/test_sign/test_blindsign.py b/tests/integration/nano/test_sign/test_blindsign.py index 42767991e..343392110 100644 --- a/tests/integration/nano/test_sign/test_blindsign.py +++ b/tests/integration/nano/test_sign/test_blindsign.py @@ -18,9 +18,11 @@ from multiprocessing import Process, Queue from pathlib import Path -from typing import Callable +from typing import Callable, List, Union -from utils.app import Screen, ScreenText, TezosAppScreen, send_and_navigate, DEFAULT_ACCOUNT +from ragger.navigator import NavIns, NavInsID + +from utils.app import ScreenText, TezosAppScreen, DEFAULT_ACCOUNT from utils.backend import StatusCode from utils.message import ( Message, @@ -39,8 +41,8 @@ def _sign_too_long(app: TezosAppScreen, message: Message, navigate: Callable[[], None]): - app.setup_expert_mode() - app.setup_blindsign_on() + app.toggle_expert_mode() + app.toggle_blindsign() data = app.sign( DEFAULT_ACCOUNT, @@ -71,8 +73,8 @@ def _reject_too_long( navigate: Callable[[], None]): """Reject a too long message""" - app.setup_expert_mode() - app.setup_blindsign_on() + app.toggle_expert_mode() + app.toggle_blindsign() with status_code.expected(): app.sign( @@ -354,22 +356,23 @@ def navigate() -> None: if app.backend.firmware.device == "nanos": ### Simulate `navigate_review` up to `ACCEPT_RISK` because the nanos screen can look like it hasn't changed. - def assert_screen_i(i): - app.assert_screen(f"{str(i).zfill(5)}", snapshot_dir / "clear") - - app.backend.wait_for_text_not_on_screen(ScreenText.HOME) - for i in range(6): + instructions: List[Union[NavIns, NavInsID]] = [ # 'Review operation' - # 'Expression {{{...{{{' - # 'Expression {{{...{{{' - # 'The transaction cannot be trusted.' - # 'Parsing error ERR_TOO_DEEP' - # 'Learn More: bit.ly/ledger-tez' - assert_screen_i(i) - app.backend.right_click() - # 'Accept risk' screen - assert_screen_i(i+1) - app.backend.both_click() + NavInsID.RIGHT_CLICK, # 'Expression {{{...{{{' + NavInsID.RIGHT_CLICK, # 'Expression {{{...{{{' + NavInsID.RIGHT_CLICK, # 'The transaction cannot be trusted.' + NavInsID.RIGHT_CLICK, # 'Parsing error ERR_TOO_DEEP' + NavInsID.RIGHT_CLICK, # 'Learn More: bit.ly/ledger-tez' + NavInsID.RIGHT_CLICK, # 'Accept risk' + NavInsID.BOTH_CLICK, + ] + + app.unsafe_navigate( + instructions=instructions, + screen_change_before_first_instruction=True, + screen_change_after_last_instruction=False, + snap_path=snapshot_dir / "clear", + ) else: app.navigate_review(text=ScreenText.ACCEPT_RISK, snap_path=snapshot_dir / "clear") diff --git a/tests/integration/nano/test_sign/test_key.py b/tests/integration/nano/test_sign/test_key.py index 484fed181..1db218a6d 100644 --- a/tests/integration/nano/test_sign/test_key.py +++ b/tests/integration/nano/test_sign/test_key.py @@ -21,7 +21,7 @@ import pytest from utils.account import Account, SigType -from utils.app import Screen, TezosAppScreen +from utils.app import TezosAppScreen from utils.message import MichelineExpr, Transaction @pytest.mark.parametrize( @@ -66,7 +66,7 @@ def test_sign_micheline_basic(app: TezosAppScreen, account: Account, snapshot_di def test_sign_with_another_seed(app: TezosAppScreen, snapshot_dir: Path): """Check signing using another seed than [zebra*24]""" - app.setup_expert_mode() + app.toggle_expert_mode() account = Account("m/44'/1729'/0'/0'", SigType.ED25519, diff --git a/tests/integration/nano/test_sign/test_parsing_errors.py b/tests/integration/nano/test_sign/test_parsing_errors.py index 7af2ed5b3..6cddb4d15 100755 --- a/tests/integration/nano/test_sign/test_parsing_errors.py +++ b/tests/integration/nano/test_sign/test_parsing_errors.py @@ -56,7 +56,7 @@ def test_parsing_error(app: TezosAppScreen, raw_msg: str, snapshot_dir: Path): """Check parsing error handling""" - app.setup_expert_mode() + app.toggle_expert_mode() with StatusCode.PARSE_ERROR.expected(): app.reject_signing( @@ -77,7 +77,7 @@ def test_parsing_error(app: TezosAppScreen, raw_msg: str, snapshot_dir: Path): def test_parsing_hard_fail(app: TezosAppScreen, raw_msg: str, snapshot_dir: Path): """Check parsing error hard failing""" - app.setup_expert_mode() + app.toggle_expert_mode() with StatusCode.UNEXPECTED_SIGN_STATE.expected(): app.sign( diff --git a/tests/integration/nano/test_wrong_apdu.py b/tests/integration/nano/test_wrong_apdu.py index 472b73014..13e15c872 100644 --- a/tests/integration/nano/test_wrong_apdu.py +++ b/tests/integration/nano/test_wrong_apdu.py @@ -22,18 +22,20 @@ import pytest from utils.account import Account, SigType -from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen, DEFAULT_ACCOUNT from utils.backend import Cla, Index, Ins, StatusCode from utils.message import Transaction def test_regression_continue_after_reject(app: TezosAppScreen, snapshot_dir: Path): """Check the app still runs after rejects signing""" - app.setup_expert_mode() + app.toggle_expert_mode() with StatusCode.REJECT.expected(): app.reject_public_key(DEFAULT_ACCOUNT, snap_path=snapshot_dir / "reject_public_key") + app.backend.wait_for_home_screen() + message = Transaction( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', fee = 10000, diff --git a/tests/integration/nano/utils/app.py b/tests/integration/nano/utils/app.py index c42103c58..571f8902b 100644 --- a/tests/integration/nano/utils/app.py +++ b/tests/integration/nano/utils/app.py @@ -22,9 +22,8 @@ import time from typing import Callable, List, Optional, TypeVar, Union -import requests from ragger.backend import SpeculosBackend -from ragger.navigator import NavInsID, NanoNavigator +from ragger.navigator import NavIns, NavInsID, NanoNavigator from .message import Message from .account import Account, SigType @@ -103,21 +102,6 @@ def __enter__(self) -> "SpeculosTezosBackend": self._client.process = process return self -class Screen(str, Enum): - """Class representing common, known app screens.""" - - HOME = "home" - VERSION = "version" - SETTINGS = "settings" - SETTINGS_EXPERT_MODE_DISABLED = "settings_expert_mode_disabled" - SETTINGS_EXPERT_MODE_ENABLED = "settings_expert_mode_enabled" - SETTINGS_BLINDSIGN_ON = "settings_blindsign_on" - SETTINGS_BLINDSIGN_OFF = "settings_blindsign_off" - SETTINGS_BACK = "back" - QUIT = "quit" - - def __str__(self) -> str: - return self.value class ScreenText(str, Enum): """Class representing common, known app screen's text.""" @@ -145,10 +129,6 @@ class TezosAppScreen(): backend: SpeculosTezosBackend _root_dir: Path - snapshots_dir: Path - tmp_snapshots_dir: Path - snapshotted: List[str] - golden_run: bool navigator: NanoNavigator def __init__(self, @@ -156,15 +136,6 @@ def __init__(self, golden_run: bool): self.backend = backend self._root_dir = Path(__file__).resolve().parent.parent - self.snapshots_dir = self._root_dir / "snapshots" / backend.firmware.name - self.tmp_snapshots_dir = self._root_dir / "snapshots-tmp" / backend.firmware.name - if not self.snapshots_dir.is_dir() and golden_run: - self.snapshots_dir.mkdir(parents=True) - if not self.tmp_snapshots_dir.is_dir(): - self.tmp_snapshots_dir.mkdir(parents=True) - self.snapshotted = [] - - self.golden_run = golden_run self.navigator = NanoNavigator(backend, backend.firmware, golden_run) def __enter__(self) -> "TezosAppScreen": @@ -174,90 +145,6 @@ def __enter__(self) -> "TezosAppScreen": def __exit__(self, *args): self.backend.__exit__(*args) - def assert_screen(self, - screen: Union[str, Screen], - path: Optional[Union[str, Path]] = None) -> None: - """Check if the screen is the one expected.""" - golden_run = self.golden_run and screen not in self.snapshotted - if golden_run: - self.snapshotted = self.snapshotted + [screen] - input(f"Press ENTER to snapshot {screen}") - - snapshots_dir = self.snapshots_dir if path is None \ - else self.snapshots_dir / path - tmp_snapshots_dir = self.tmp_snapshots_dir if path is None \ - else self.tmp_snapshots_dir / path - - if not snapshots_dir.is_dir() and golden_run: - snapshots_dir.mkdir(parents=True) - if not tmp_snapshots_dir.is_dir(): - tmp_snapshots_dir.mkdir(parents=True) - - path = snapshots_dir / f'{screen}.png' - tmp_path = tmp_snapshots_dir / f'{screen}.png' - def check(): - print(f"- Expecting {screen} -") - assert self.backend.compare_screen_with_snapshot( - path, - tmp_snap_path=tmp_path, - golden_run=golden_run) - - with_retry(check) - self.backend._last_screenshot = BytesIO(self.backend._client.get_screenshot()) - - def setup_expert_mode(self) -> None: - """Enable expert-mode from home screen.""" - self.assert_screen(Screen.HOME) - self.backend.right_click() - self.assert_screen(Screen.VERSION) - self.backend.right_click() - self.assert_screen(Screen.SETTINGS) - self.backend.both_click() - self.assert_screen(Screen.SETTINGS_EXPERT_MODE_DISABLED) - self.backend.both_click() - self.assert_screen(Screen.SETTINGS_EXPERT_MODE_ENABLED) - self.backend.left_click() - self.assert_screen(Screen.SETTINGS_BACK) - self.backend.both_click() - self.assert_screen(Screen.HOME) - - def setup_blindsign_on(self) -> None: - """Enable blindsign from home screen.""" - self.assert_screen(Screen.HOME) - self.backend.right_click() - self.assert_screen(Screen.VERSION) - self.backend.right_click() - self.assert_screen(Screen.SETTINGS) - self.backend.both_click() - # expert_mode screen - self.backend.right_click() - self.assert_screen(Screen.SETTINGS_BLINDSIGN_OFF) - self.backend.both_click() - self.assert_screen(Screen.SETTINGS_BLINDSIGN_ON) - self.backend.right_click() - self.assert_screen(Screen.SETTINGS_BACK) - self.backend.both_click() - self.assert_screen(Screen.HOME) - - def _quit(self) -> None: - """Ensure quiting exit the app.""" - self.assert_screen(Screen.QUIT) - try: - self.backend.both_click() - assert False, "Must have lost connection with speculos" - except requests.exceptions.ConnectionError: - pass - - def quit(self) -> None: - """Quit the app from home screen.""" - self.assert_screen(Screen.HOME) - self.backend.right_click() - self.assert_screen(Screen.VERSION) - self.backend.right_click() - self.assert_screen(Screen.SETTINGS) - self.backend.right_click() - self._quit() - def navigate(self, snap_path: Optional[Path] = None, screen_change_before_first_instruction: bool = False, @@ -282,6 +169,99 @@ def navigate_until_text(self, **kwargs ) + def unsafe_navigate( + self, + instructions: List[Union[NavIns, NavInsID]], + snap_path: Optional[Path] = None, + timeout: float = 10.0, + screen_change_before_first_instruction: bool = False, + screen_change_after_last_instruction: bool = True, + snap_start_idx: int = 0) -> None: + """Navigate using instructions but do not wait for screens to + change. Only use this function if consecutive screens are the + same. + + Function based on `ragger.navigator.navigate_and_compare` + + """ + self.backend.pause_ticker() + self.navigator._run_instruction( + NavIns(NavInsID.WAIT, (0, )), + timeout, + wait_for_screen_change=screen_change_before_first_instruction, + path=self._root_dir, + test_case_name=snap_path, + snap_idx=snap_start_idx + ) + for idx, instruction in enumerate(instructions): + if idx + 1 != len(instructions) or screen_change_after_last_instruction: + self.navigator._run_instruction( + instruction, + timeout, + wait_for_screen_change=False, + path=self._root_dir, + test_case_name=snap_path, + snap_idx=snap_start_idx + idx + 1 + ) + else: + self.navigator._run_instruction( + instruction, + timeout, + wait_for_screen_change=False, + snap_idx=snap_start_idx + idx + 1 + ) + self.backend.resume_ticker() + + def navigate_to_settings(self, **kwargs) -> int: + """Navigate from Home screen to settings.""" + instructions: List[Union[NavIns, NavInsID]] = [ + # Home + NavInsID.RIGHT_CLICK, # Version + NavInsID.RIGHT_CLICK, # Settings + NavInsID.BOTH_CLICK, + ] + self.navigate(instructions=instructions, **kwargs) + snap_start_idx = kwargs['snap_start_idx'] if 'snap_start_idx' in kwargs else 0 + return snap_start_idx + len(instructions) + + def toggle_expert_mode(self, **kwargs) -> int: + """Enable expert-mode from home screen.""" + go_to_settings_kwargs = kwargs.copy() + go_to_settings_kwargs['screen_change_after_last_instruction'] = True + snap_idx = self.navigate_to_settings(**go_to_settings_kwargs) + + instructions: List[Union[NavIns, NavInsID]] = [ + # Expert Mode + NavInsID.BOTH_CLICK, + NavInsID.RIGHT_CLICK, # Blind Sign + NavInsID.RIGHT_CLICK, # Back + NavInsID.BOTH_CLICK, # Home + ] + kwargs['snap_start_idx'] = snap_idx + kwargs['screen_change_before_first_instruction'] = False + self.navigate(instructions=instructions, **kwargs) + + return snap_idx + len(instructions) + + def toggle_blindsign(self, **kwargs) -> int: + """Enable blindsign from home screen.""" + go_to_settings_kwargs = kwargs.copy() + go_to_settings_kwargs['screen_change_after_last_instruction'] = True + snap_idx = self.navigate_to_settings(**go_to_settings_kwargs) + + instructions: List[Union[NavIns, NavInsID]] = [ + # Expert Mode + NavInsID.RIGHT_CLICK, # Blind Sign + NavInsID.BOTH_CLICK, + NavInsID.RIGHT_CLICK, # Back + NavInsID.BOTH_CLICK, # Home + ] + kwargs['snap_start_idx'] = snap_idx + kwargs['screen_change_before_first_instruction'] = False + self.navigate(instructions=instructions, **kwargs) + + return snap_idx + len(instructions) + def navigate_forward(self, **kwargs) -> None: """Navigate forward until the text is found. Confirm at the end.""" self.navigate_until_text(