From 342e8e82b107f561c16ba4e80ac2b708bf2c2811 Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Wed, 25 May 2022 10:29:21 +1000 Subject: [PATCH] implement shellchat test modals remove modals feature ux_tests --- services/modals/Cargo.toml | 3 +-- services/modals/src/lib.rs | 1 + services/modals/src/main.rs | 6 ------ services/modals/src/tests.rs | 7 ++++--- services/shellchat/src/cmds/test.rs | 4 ++++ 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/services/modals/Cargo.toml b/services/modals/Cargo.toml index 084e728fd..953a3b18f 100644 --- a/services/modals/Cargo.toml +++ b/services/modals/Cargo.toml @@ -32,6 +32,5 @@ fast_image_resize = "0.9.2" utralib = { path = "../../utralib"} [features] -ux_tests = [] tts = [] -default = ["ux_tests"] +default = [] diff --git a/services/modals/src/lib.rs b/services/modals/src/lib.rs index 1da1ad614..bfc1165f3 100644 --- a/services/modals/src/lib.rs +++ b/services/modals/src/lib.rs @@ -2,6 +2,7 @@ pub mod api; use api::*; +pub mod tests; use bit_field::BitField; use core::cell::Cell; diff --git a/services/modals/src/main.rs b/services/modals/src/main.rs index 3f93abf3a..b92d207ba 100644 --- a/services/modals/src/main.rs +++ b/services/modals/src/main.rs @@ -27,7 +27,6 @@ /// a `TextResponseValid` message which pumps the work queue. mod api; use api::*; -mod tests; use gam::Bitmap; use xous::{msg_blocking_scalar_unpack, msg_scalar_unpack, send_message, Message}; @@ -126,11 +125,6 @@ fn xmain() -> ! { let mut list_hash = HashMap::::new(); let mut list_selected = 0u32; - if cfg!(feature = "ux_tests") { - tt.sleep_ms(1000).unwrap(); - tests::spawn_test(); - } - let mut token_lock: Option<[u32; 4]> = None; let trng = trng::Trng::new(&xns).unwrap(); // this is a random number that serves as a "default" that cannot be guessed diff --git a/services/modals/src/tests.rs b/services/modals/src/tests.rs index 49093eeb8..cf47bfac0 100644 --- a/services/modals/src/tests.rs +++ b/services/modals/src/tests.rs @@ -3,6 +3,7 @@ use gam::*; use std::thread; use xous_names::XousNames; use image::io::{Reader}; +use super::*; const RADIO_TEST: [&'static str; 4] = ["zebra", "cow", "horse", "cat"]; @@ -15,12 +16,12 @@ const CHECKBOX_TEST: [&'static str; 5] = ["happy", "😃", "安", "peaceful", ". /// /// Each thread will create a series of Modal primitives, including progess bars, notifications, /// check boxes and radio boxes. -pub(crate) fn spawn_test() { +pub fn spawn_test() { // spawn two threads that compete for modal resources, to test the interlocking mechanisms thread::spawn({ move || { let xns = XousNames::new().unwrap(); - let modals = modals::Modals::new(&xns).unwrap(); + let modals = Modals::new(&xns).unwrap(); let tt = ticktimer_server::Ticktimer::new().unwrap(); // 0. multi-modal test @@ -84,7 +85,7 @@ pub(crate) fn spawn_test() { thread::spawn({ move || { let xns = XousNames::new().unwrap(); - let modals = modals::Modals::new(&xns).unwrap(); + let modals = Modals::new(&xns).unwrap(); // 1. test radio box for item in RADIO_TEST { diff --git a/services/shellchat/src/cmds/test.rs b/services/shellchat/src/cmds/test.rs index 2abad0a3c..b5db75bf6 100644 --- a/services/shellchat/src/cmds/test.rs +++ b/services/shellchat/src/cmds/test.rs @@ -10,6 +10,7 @@ use core::fmt::Write; use core::sync::atomic::{AtomicBool, Ordering, AtomicU32}; use std::sync::Arc; use num_traits::*; +use modals; use std::time::Instant; @@ -608,6 +609,9 @@ impl<'a> ShellCmdApi<'a> for Test { write!(ret, "Ship mode request denied").unwrap(); } } + "modals" => { + modals::tests::spawn_test(); + } _ => { () // do nothing }