From 0abfc7b1f9a4aabf28d5e5e21fbe6f3ec98b65f2 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Mon, 10 Feb 2025 12:40:05 +0200 Subject: [PATCH] fix(core): correct Delizia loader completion detection This issue was found while debugging a flaky click test: `tests/click_tests/test_lock.py::test_hold_to_lock` Sample failures: https://github.com/trezor/trezor-firmware/actions/runs/13209659963/job/36880750418 https://github.com/trezor/trezor-firmware/actions/runs/13189762414/job/36820368643 https://github.com/trezor/trezor-firmware/actions/runs/13146713535/job/36686537519 https://github.com/trezor/trezor-firmware/actions/runs/13124809110/job/36619045092 https://github.com/trezor/trezor-firmware/actions/runs/13103415015/job/36554567296 https://github.com/trezor/trezor-firmware/actions/runs/13093382180/job/36532710349 [no changelog] --- core/embed/rust/src/ui/layout_bolt/component/loader.rs | 10 ++++++++-- .../rust/src/ui/layout_caesar/component/loader.rs | 10 ++++++++-- .../rust/src/ui/layout_delizia/component/loader.rs | 10 ++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/core/embed/rust/src/ui/layout_bolt/component/loader.rs b/core/embed/rust/src/ui/layout_bolt/component/loader.rs index 7789f95647..a440a18708 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/loader.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/loader.rs @@ -139,11 +139,17 @@ impl Loader { } pub fn is_completely_grown(&self, now: Instant) -> bool { - matches!(self.progress(now), Some(display::LOADER_MAX)) + match &self.state { + State::Growing(a) => a.finished(now), + _ => false, + } } pub fn is_completely_shrunk(&self, now: Instant) -> bool { - matches!(self.progress(now), Some(display::LOADER_MIN)) + match &self.state { + State::Shrinking(a) => a.finished(now), + _ => false, + } } } diff --git a/core/embed/rust/src/ui/layout_caesar/component/loader.rs b/core/embed/rust/src/ui/layout_caesar/component/loader.rs index b62822f747..05ddbead5b 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/loader.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/loader.rs @@ -154,11 +154,17 @@ impl Loader { } pub fn is_completely_grown(&self, now: Instant) -> bool { - matches!(self.progress(now), Some(display::LOADER_MAX)) + match &self.state { + State::Growing(a) => a.finished(now), + _ => false, + } } pub fn is_completely_shrunk(&self, now: Instant) -> bool { - matches!(self.progress(now), Some(display::LOADER_MIN)) + match &self.state { + State::Shrinking(a) => a.finished(now), + _ => false, + } } pub fn render_loader<'s>( diff --git a/core/embed/rust/src/ui/layout_delizia/component/loader.rs b/core/embed/rust/src/ui/layout_delizia/component/loader.rs index 158a0bc83e..8795822216 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/loader.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/loader.rs @@ -143,11 +143,17 @@ impl Loader { } pub fn is_completely_grown(&self, now: Instant) -> bool { - matches!(self.progress_raw(now), Some(display::LOADER_MAX)) + match &self.state { + State::Growing(a) => a.finished(now), + _ => false, + } } pub fn is_completely_shrunk(&self, now: Instant) -> bool { - matches!(self.progress_raw(now), Some(display::LOADER_MIN)) + match &self.state { + State::Shrinking(a) => a.finished(now), + _ => false, + } } }