Improvements for tests
This commit is contained in:
parent
1503589355
commit
ac31fa8284
2 changed files with 53 additions and 19 deletions
|
|
@ -1 +1 @@
|
||||||
RUST_LOG="cosmic_text=debug,editor_test=debug" cargo run --release --package editor-test -- "$@"
|
RUST_LOG="cosmic_text=debug,editor_test=debug" cargo run --release --package editor-test --features mono -- "$@"
|
||||||
|
|
|
||||||
|
|
@ -135,15 +135,61 @@ fn main() {
|
||||||
default_text.to_string()
|
default_text.to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
for c in text.chars() {
|
//TODO: support bidi
|
||||||
match c {
|
for line in text.lines() {
|
||||||
'\r' => (),
|
for c in line.chars() {
|
||||||
'\n' => buffer.action(TextAction::Enter),
|
if c.is_control() {
|
||||||
_ => {
|
log::warn!("Ignoring control character {:?}", c);
|
||||||
buffer.action(TextAction::Insert(c));
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log::debug!("Insert {:?}", c);
|
||||||
|
|
||||||
|
//TODO: ligatures break this, make cursor reference text lines not layout lines!
|
||||||
|
// Test backspace of character
|
||||||
|
{
|
||||||
|
let cursor = buffer.cursor();
|
||||||
|
buffer.action(TextAction::Insert(c));
|
||||||
|
buffer.action(TextAction::Backspace);
|
||||||
|
assert_eq!(cursor, buffer.cursor());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test delete of character (DOES NOT SUPPORT RTL)
|
||||||
|
{
|
||||||
|
let cursor = buffer.cursor();
|
||||||
|
buffer.action(TextAction::Insert(c));
|
||||||
|
buffer.action(TextAction::Left);
|
||||||
|
buffer.action(TextAction::Delete);
|
||||||
|
assert_eq!(cursor, buffer.cursor());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, normal insert of character
|
||||||
|
buffer.action(TextAction::Insert(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log::debug!("Line '{}': {:?}", line, line);
|
||||||
|
|
||||||
|
// Test backspace of newline
|
||||||
|
{
|
||||||
|
let cursor = buffer.cursor();
|
||||||
|
buffer.action(TextAction::Enter);
|
||||||
|
buffer.action(TextAction::Backspace);
|
||||||
|
assert_eq!(cursor, buffer.cursor());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test delete of newline
|
||||||
|
{
|
||||||
|
let cursor = buffer.cursor();
|
||||||
|
buffer.action(TextAction::Enter);
|
||||||
|
buffer.action(TextAction::Up);
|
||||||
|
buffer.action(TextAction::End);
|
||||||
|
buffer.action(TextAction::Delete);
|
||||||
|
assert_eq!(cursor, buffer.cursor());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, normal enter
|
||||||
|
buffer.action(TextAction::Enter);
|
||||||
|
|
||||||
redraw(&mut window, &mut buffer);
|
redraw(&mut window, &mut buffer);
|
||||||
|
|
||||||
for event in window.events() {
|
for event in window.events() {
|
||||||
|
|
@ -168,16 +214,4 @@ fn main() {
|
||||||
} else {
|
} else {
|
||||||
log::error!("{} lines did not match!", wrong);
|
log::error!("{} lines did not match!", wrong);
|
||||||
}
|
}
|
||||||
|
|
||||||
redraw(&mut window, &mut buffer);
|
|
||||||
|
|
||||||
loop {
|
|
||||||
for event in window.events() {
|
|
||||||
match event.to_option() {
|
|
||||||
EventOption::Quit(_) => process::exit(0),
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
thread::sleep(Duration::from_millis(1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue