This repository has been archived on 2026-10-10. You can view files and clone it, but cannot push or open issues or pull requests.
molotov/crates/molotov-core/tests/ime_preedit_test.rs

22 lines
758 B
Rust

// SPDX-License-Identifier: GPL-3.0-or-later
use molotov_core::input::ime::{ImeManager, Rect};
#[test]
fn test_ime_preedit_composition_flow() {
let mut ime = ImeManager::new();
ime.start_text_input(Rect { x: 100, y: 200, width: 20, height: 24 });
assert!(ime.is_active());
// User types in Japanese IME: preedit string "とうきょう"
ime.update_preedit("とうきょう", 4);
assert_eq!(ime.preedit_text(), "とうきょう");
assert_eq!(ime.cursor_pos(), 4);
// User selects candidate: commit "東京"
let committed = ime.commit_text("東京");
assert_eq!(committed, "東京");
assert_eq!(ime.preedit_text(), "", "Preedit must clear on commit");
ime.stop_text_input();
assert!(!ime.is_active());
}