mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add a feature for testing the UI on mtxchat
when `test-chat-ui` is selected as a feature and mtxchat is selected as an app to build, this will override the mainloop of the `mtxchat` app and create a test dialog & present it, laying a framework for controlled debugging of the layout engine.
This commit is contained in:
parent
c2becc089b
commit
60db6053bc
3 changed files with 40 additions and 0 deletions
|
|
@ -41,3 +41,4 @@ url = "2.2.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
test-chat-ui = []
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
#![cfg_attr(target_os = "none", no_main)]
|
#![cfg_attr(target_os = "none", no_main)]
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
|
#[cfg(feature="test-chat-ui")]
|
||||||
|
mod tests;
|
||||||
|
|
||||||
use api::*;
|
use api::*;
|
||||||
use chat::{Chat, Event, POST_TEXT_MAX};
|
use chat::{Chat, Event, POST_TEXT_MAX};
|
||||||
use gam::{MenuItem, MenuPayload};
|
use gam::{MenuItem, MenuPayload};
|
||||||
|
|
@ -97,6 +100,8 @@ fn wrapped_main() -> ! {
|
||||||
let mut mtxchat = MtxChat::new(&chat);
|
let mut mtxchat = MtxChat::new(&chat);
|
||||||
let mut first_focus = true;
|
let mut first_focus = true;
|
||||||
let mut user_post: Option<String> = None;
|
let mut user_post: Option<String> = None;
|
||||||
|
#[cfg(feature="test-chat-ui")]
|
||||||
|
tests::test_ui(&chat);
|
||||||
loop {
|
loop {
|
||||||
let msg = xous::receive_message(sid).unwrap();
|
let msg = xous::receive_message(sid).unwrap();
|
||||||
log::debug!("got message {:?}", msg);
|
log::debug!("got message {:?}", msg);
|
||||||
|
|
|
||||||
34
apps/mtxchat/src/tests.rs
Normal file
34
apps/mtxchat/src/tests.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
use chat::Chat;
|
||||||
|
|
||||||
|
pub fn test_ui(chat: &Chat) {
|
||||||
|
let tt = ticktimer_server::Ticktimer::new().unwrap();
|
||||||
|
let pddb = pddb::Pddb::new();
|
||||||
|
// nuke any existing test dictionary, if it exists
|
||||||
|
pddb.delete_dict("tests.ui", None).ok();
|
||||||
|
pddb.sync().ok();
|
||||||
|
|
||||||
|
// re-create the test room from scratch every time
|
||||||
|
chat.dialogue_set("tests.ui", Some("test_room")).expect("couldn't set dialog");
|
||||||
|
|
||||||
|
// generate a list of test posts that are repeatable each time
|
||||||
|
chat.post_add("alice", 1_700_000_000, "hello world!", None).ok();
|
||||||
|
chat.post_add("bob", 1_700_000_002, "hi alice!", None).ok();
|
||||||
|
|
||||||
|
tt.sleep_ms(2000).ok();
|
||||||
|
log::info!("triggering save");
|
||||||
|
xous::send_message(
|
||||||
|
chat.cid(),
|
||||||
|
xous::Message::new_scalar(chat::ChatOp::DialogueSave as usize, 0, 0, 0, 0),
|
||||||
|
)
|
||||||
|
.expect("failed to send new inbound msgs");
|
||||||
|
|
||||||
|
log::info!("sleep");
|
||||||
|
tt.sleep_ms(5000).ok();
|
||||||
|
log::info!("redraw");
|
||||||
|
chat.redraw();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
tt.sleep_ms(5000).ok();
|
||||||
|
log::info!("test done, displaying result");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue