From fd05dfc2964aeb153bf3504d5f1ee7a41998a498 Mon Sep 17 00:00:00 2001 From: Xavier Chapron Date: Thu, 4 Apr 2024 14:30:44 +0200 Subject: [PATCH] navigator.py: Add use case navigation function --- src/ragger/navigator/navigator.py | 105 ++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/src/ragger/navigator/navigator.py b/src/ragger/navigator/navigator.py index 1f452b20..da93a2f6 100644 --- a/src/ragger/navigator/navigator.py +++ b/src/ragger/navigator/navigator.py @@ -573,3 +573,108 @@ def navigate_until_text(self, None, None, timeout, screen_change_before_first_instruction, screen_change_after_last_instruction) + + def review_approve(self, + path: Optional[Path] = None, + test_case_name: Optional[Path] = None, + approve_screen_text: Optional[str] = None): + if self._firmware.device.startswith("nano"): + navigate_instruction = NavInsID.RIGHT_CLICK + validation_instructions = [NavInsID.BOTH_CLICK] + if not approve_screen_text: + approve_screen_text = "Approve" + + elif self._firmware.device.startswith("stax"): + navigate_instruction = NavInsID.USE_CASE_REVIEW_TAP + validation_instructions = [NavInsID.USE_CASE_REVIEW_CONFIRM, + NavInsID.USE_CASE_STATUS_DISMISS] + if not approve_screen_text: + approve_screen_text = "Hold to sign" + + else: + raise NotImplementedError("Device not supported") + + self.navigate_until_text_and_compare(navigate_instruction, + validation_instructions, + approve_screen_text, + path, + test_case_name) + + def review_reject(self, + path: Optional[Path] = None, + test_case_name: Optional[Path] = None, + reject_screen_text: Optional[str] = None): + if self._firmware.device.startswith("nano"): + navigate_instruction = NavInsID.RIGHT_CLICK + validation_instructions = [NavInsID.BOTH_CLICK] + + if not reject_screen_text: + reject_screen_text = "Reject" + + elif self._firmware.device.startswith("stax"): + navigate_instruction = NavInsID.USE_CASE_REVIEW_TAP + validation_instructions = [NavInsID.USE_CASE_REVIEW_REJECT, + NavInsID.USE_CASE_CHOICE_CONFIRM, + NavInsID.USE_CASE_STATUS_DISMISS] + if not reject_screen_text: + reject_screen_text = "Hold to sign" + else: + raise NotImplementedError("Device not supported") + + self.navigate_until_text_and_compare(navigate_instruction, + validation_instructions, + reject_screen_text, + path, + test_case_name) + + def address_review_approve(self, + path: Optional[Path] = None, + test_case_name: Optional[Path] = None, + approve_screen_text: Optional[str] = None): + if self._firmware.device.startswith("nano"): + navigate_instruction = NavInsID.RIGHT_CLICK + validation_instructions = [NavInsID.BOTH_CLICK] + if not approve_screen_text: + approve_screen_text = "Approve" + + elif self._firmware.device.startswith("stax"): + navigate_instruction = NavInsID.USE_CASE_REVIEW_TAP + validation_instructions = [NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CONFIRM, + NavInsID.USE_CASE_STATUS_DISMISS] + if not approve_screen_text: + approve_screen_text = "Confirm" + + else: + raise NotImplementedError("Device not supported") + + self.navigate_until_text_and_compare(navigate_instruction, + validation_instructions, + approve_screen_text, + path, + test_case_name) + + def address_review_reject(self, + path: Optional[Path] = None, + test_case_name: Optional[Path] = None, + reject_screen_text: Optional[str] = None): + if self._firmware.device.startswith("nano"): + navigate_instruction = NavInsID.RIGHT_CLICK + validation_instructions = [NavInsID.BOTH_CLICK] + + if not reject_screen_text: + reject_screen_text = "Reject" + + elif self._firmware.device.startswith("stax"): + navigate_instruction = NavInsID.USE_CASE_REVIEW_TAP + validation_instructions = [NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CANCEL, + NavInsID.USE_CASE_STATUS_DISMISS] + if not reject_screen_text: + reject_screen_text = "Confirm" + else: + raise NotImplementedError("Device not supported") + + self.navigate_until_text_and_compare(navigate_instruction, + validation_instructions, + reject_screen_text, + path, + test_case_name)