Skip to content

Commit

Permalink
Merge pull request #150 from LedgerHQ/xch/navigation-regex
Browse files Browse the repository at this point in the history
backend: Allow navigation screen content comparison with regex
  • Loading branch information
xchapron-ledger authored Sep 27, 2023
2 parents d85e016 + 89f4cfe commit c675469
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.11.5] - 2023-09-27

### Changed:
- backend/speculos - navigator: Allow navigation screen content comparison with regex.

## [1.11.4] - 2023-07-31

### Changed:
Expand Down
7 changes: 5 additions & 2 deletions src/ragger/backend/speculos.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from PIL import Image
from typing import Optional, Generator
from time import time, sleep
from json import dumps
from re import match

from speculos.client import SpeculosClient, screenshot_equal, ApduResponse, ApduException
from speculos.mcu.seproxyhal import TICKER_DELAY
Expand Down Expand Up @@ -214,7 +214,10 @@ def get_current_screen_content(self) -> dict:
return self._retrieve_client_screen_content()

def compare_screen_with_text(self, text: str) -> bool:
return text in dumps(self._retrieve_client_screen_content())
for event in self._retrieve_client_screen_content()["events"]:
if match(text, event.get("text", "")):
return True
return False

def wait_for_screen_change(self, timeout: float = 10.0) -> None:
screenshot = BytesIO(self._client.get_screenshot())
Expand Down

0 comments on commit c675469

Please sign in to comment.