From ed797e6a82b7457e927b09505d8bc945a385c302 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 29 Apr 2025 03:03:54 +0800 Subject: [PATCH] scrolling tests --- services/bao-console/src/main.rs | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/services/bao-console/src/main.rs b/services/bao-console/src/main.rs index ec8034a13..593480592 100644 --- a/services/bao-console/src/main.rs +++ b/services/bao-console/src/main.rs @@ -12,6 +12,59 @@ fn main() { let tt = ticktimer::Ticktimer::new().unwrap(); shell::start_shell(); + #[cfg(feature = "test-scrollbars")] + { + let mut sl_binding = ux_api::widgets::ScrollableList::default(); + let mut sl = &mut sl_binding; + + log::info!("setup list"); + for col in 0..2 { + for row in 0..12 { + sl = sl.add_item(col, &format!("c{}r{}", row, col)); + } + } + sl.select_index = (1, 3); + log::info!("initial draw"); + sl.draw(0); + tt.sleep_ms(500).ok(); + use ux_api::widgets::Direction; + + log::info!("scroll down test"); + for _ in 0..14 { + sl.move_scroll_offset(Direction::Down); + sl.draw(0); + tt.sleep_ms(500).ok(); + } + log::info!("scroll right then up"); + sl.move_scroll_offset(Direction::Right); + for _ in 0..10 { + sl.move_scroll_offset(Direction::Up); + sl.draw(0); + tt.sleep_ms(500).ok(); + } + + sl.set_scroll_offset(0, 0); + sl.set_selected(0, 0); + for _ in 0..14 { + sl.move_selection(Direction::Down); + sl.draw(0); + tt.sleep_ms(500).ok(); + } + for _ in 0..8 { + sl.move_selection(Direction::Up); + sl.draw(0); + tt.sleep_ms(500).ok(); + } + for _ in 0..4 { + sl.move_selection(Direction::Right); + sl.draw(0); + tt.sleep_ms(500).ok(); + } + sl.move_selection(Direction::Left); + sl.draw(0); + tt.sleep_ms(500).ok(); + } + #[cfg(feature = "modal-testing")] { log::set_max_level(log::LevelFilter::Debug);