mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add unit test for setting selection with selection direction
This commit is contained in:
parent
8e5d5a45ef
commit
6c7e812966
1 changed files with 23 additions and 0 deletions
|
@ -458,3 +458,26 @@ fn test_textinput_cursor_position_correct_after_clearing_selection() {
|
||||||
assert_eq!(textinput.edit_point.index, 0);
|
assert_eq!(textinput.edit_point.index, 0);
|
||||||
assert_eq!(textinput.edit_point.line, 0);
|
assert_eq!(textinput.edit_point.line, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_textinput_set_selection_with_direction() {
|
||||||
|
let mut textinput = text_input(Lines::Single, "abcdef");
|
||||||
|
textinput.selection_direction = SelectionDirection::Forward;
|
||||||
|
textinput.set_selection_range(2, 6);
|
||||||
|
assert_eq!(textinput.edit_point.line, 0);
|
||||||
|
assert_eq!(textinput.edit_point.index, 6);
|
||||||
|
|
||||||
|
assert!(textinput.selection_begin.is_some());
|
||||||
|
assert_eq!(textinput.selection_begin.unwrap().line, 0);
|
||||||
|
assert_eq!(textinput.selection_begin.unwrap().index, 2);
|
||||||
|
|
||||||
|
textinput.selection_direction = SelectionDirection::Backward;
|
||||||
|
textinput.set_selection_range(2, 6);
|
||||||
|
assert_eq!(textinput.edit_point.line, 0);
|
||||||
|
assert_eq!(textinput.edit_point.index, 2);
|
||||||
|
|
||||||
|
assert!(textinput.selection_begin.is_some());
|
||||||
|
assert_eq!(textinput.selection_begin.unwrap().line, 0);
|
||||||
|
assert_eq!(textinput.selection_begin.unwrap().index, 6);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue