1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Test(egui_kittest): cover cursor as well

This commit is contained in:
umajho
2026-04-11 21:36:01 +08:00
parent 47f869a402
commit 60fbeddfcf
3 changed files with 19 additions and 8 deletions

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:93ce77fe1f570281d50eed4c8681f1fbb382bd5fc5de63e2d683e0c570c929ff
size 9065

View File

@@ -237,16 +237,24 @@ fn test_ime_composition_visuals() {
for _ in 0.."Hello. ".len() {
harness.key_press(egui::Key::ArrowRight);
}
let text = "Have you ever seen an IME composing English text? You now see it. ";
let text_index_1 = "Have you ever ".chars().count();
let text_index_2 = "Have you ever seen an IME composing English text? "
.chars()
.count();
harness.event(egui::Event::Ime(egui::ImeEvent::Preedit {
text: "Have you ever seen an IME composing English text? You now see it. ".to_owned(),
active_range_chars: Some(
"Have you ever ".chars().count()
.."Have you ever seen an IME composing English text? "
.chars()
.count(),
),
text: text.to_owned(),
active_range_chars: Some(text_index_1..text_index_2),
}));
harness.run();
harness.snapshot("test_ime_composition_visuals_segment");
harness.snapshot("test_ime_composition_visuals");
harness.event(egui::Event::Ime(egui::ImeEvent::Preedit {
text: text.to_owned(),
active_range_chars: Some(text_index_2..text_index_2),
}));
harness.run();
harness.snapshot("test_ime_composition_visuals_cursor");
}