diff --git a/rom/tests/rust/AndroidEditorSyncTest.rs b/rom/tests/rust/AndroidEditorSyncTest.rs index 703cb0332..b6cff21b5 100644 --- a/rom/tests/rust/AndroidEditorSyncTest.rs +++ b/rom/tests/rust/AndroidEditorSyncTest.rs @@ -17,6 +17,8 @@ impl Cx { struct Background(Area); impl Background {fn area(&self)->Area {self.0} fn redraw(&mut self,_cx:&mut Cx){}} struct History; +// The real `set_text` ends with `check_text_is_empty(cx, Animate::Yes)`. +#[allow(dead_code)] #[derive(Clone, Copy)] enum Animate { Yes, No } impl History {fn clear(&mut self){} fn force_new_edit_group(&mut self){}} fn floor_grapheme_boundary(text:&str,mut index:usize)->usize {index=index.min(text.len());while !text.is_char_boundary(index) {index-=1;}index} struct TextInput { @@ -26,7 +28,7 @@ struct TextInput { } impl TextInput { fn filter_input(&self,text:&str,_programmatic:bool)->String {text.into()} - fn check_text_is_empty(&mut self,_cx:&mut Cx){} + fn check_text_is_empty(&mut self,_cx:&mut Cx,_animate:Animate){} /* REAL_EDITOR_METHODS */ } fn main() { diff --git a/rom/tests/rust/AndroidImeVisibilityTest.rs b/rom/tests/rust/AndroidImeVisibilityTest.rs index 4045fdb95..07c4c9c21 100644 --- a/rom/tests/rust/AndroidImeVisibilityTest.rs +++ b/rom/tests/rust/AndroidImeVisibilityTest.rs @@ -1,7 +1,7 @@ use std::{cell::RefCell,collections::VecDeque}; enum CxOsOp {ShowTextIME((),(),i32)} struct Keyboard {text_ime_dismissed:bool} -struct Os {last_ime_config:Option,ime_editor_session:u64} +struct Os {last_ime_config:Option,ime_editor_session:u64,pending_ime_hide:bool} struct Cx {keyboard:Keyboard,os:Os,ops:VecDeque,focused_session:u64,publishes:usize} mod android_jni { use super::*; @@ -20,17 +20,19 @@ impl Cx { } } fn main() { - let mut cx=Cx{keyboard:Keyboard{text_ime_dismissed:false},os:Os{last_ime_config:Some(1),ime_editor_session:1},ops:VecDeque::new(),focused_session:1,publishes:0}; + let mut cx=Cx{keyboard:Keyboard{text_ime_dismissed:false},os:Os{last_ime_config:Some(1),ime_editor_session:1,pending_ime_hide:false},ops:VecDeque::new(),focused_session:1,publishes:0}; // A draw requested Show before Gboard delivered its final hidden inset. // DidHide retires the cached configuration and records user dismissal; // the already queued request must be revalidated when dispatched. cx.ops.push_back(CxOsOp::ShowTextIME((),(),1)); cx.keyboard.text_ime_dismissed=true;cx.os.last_ime_config=None; cx.dispatch();android_jni::SHOWS.with(|v|assert!(v.borrow().is_empty())); - // A deliberate new tap resets dismissal and may reopen the same editor. - cx.keyboard.text_ime_dismissed=false; + // A deliberate new tap resets dismissal and may reopen the same editor, + // and an editor asking for the keyboard keeps it up through a pending hide. + cx.keyboard.text_ime_dismissed=false;cx.os.pending_ime_hide=true; cx.ops.push_back(CxOsOp::ShowTextIME((),(),1));cx.dispatch(); android_jni::SHOWS.with(|v|assert_eq!(*v.borrow(),vec![true])); + assert!(!cx.os.pending_ime_hide,"a show cancels the pending hide"); cx.ops.push_back(CxOsOp::ShowTextIME((),(),1));cx.dispatch(); android_jni::SHOWS.with(|v|assert_eq!(*v.borrow(),vec![true])); assert_eq!(cx.publishes,0,"the same editor's repeated shows publish nothing");