diff options
author | Alberto Corona <ac@albertocorona.com> | 2016-03-15 09:03:05 -0500 |
---|---|---|
committer | Adrian Utrilla <adrianutrilla@gmail.com> | 2016-04-17 17:27:26 +0200 |
commit | 5e863f2eb8c261ed05c46310b8f8a125b8ed9f04 (patch) | |
tree | 9da74c7c6e9fd27720668bd96cdbccffa94c5e9d /tests/unit/script/textinput.rs | |
parent | db4481b4509db4be83e0f77a66884feccd1878e0 (diff) | |
download | servo-5e863f2eb8c261ed05c46310b8f8a125b8ed9f04.tar.gz servo-5e863f2eb8c261ed05c46310b8f8a125b8ed9f04.zip |
Implement HTMLTextArea.setSelectionRange
Diffstat (limited to 'tests/unit/script/textinput.rs')
-rw-r--r-- | tests/unit/script/textinput.rs | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/tests/unit/script/textinput.rs b/tests/unit/script/textinput.rs index 318612e64af..52c5808c30a 100644 --- a/tests/unit/script/textinput.rs +++ b/tests/unit/script/textinput.rs @@ -13,17 +13,17 @@ use msg::constellation_msg::CONTROL; use msg::constellation_msg::SUPER; use msg::constellation_msg::{Key, KeyModifiers}; use script::clipboard_provider::DummyClipboardContext; -use script::textinput::{TextInput, TextPoint, Selection, Lines, Direction}; +use script::textinput::{TextInput, TextPoint, Selection, Lines, Direction, SelectionDirection}; use util::str::DOMString; fn text_input(lines: Lines, s: &str) -> TextInput<DummyClipboardContext> { - TextInput::new(lines, DOMString::from(s), DummyClipboardContext::new(""), None) + TextInput::new(lines, DOMString::from(s), DummyClipboardContext::new(""), None, SelectionDirection::None) } #[test] fn test_set_content_ignores_max_length() { let mut textinput = TextInput::new( - Lines::Single, DOMString::from(""), DummyClipboardContext::new(""), Some(1) + Lines::Single, DOMString::from(""), DummyClipboardContext::new(""), Some(1), SelectionDirection::None ); textinput.set_content(DOMString::from("mozilla rocks")); @@ -36,7 +36,8 @@ fn test_textinput_when_inserting_multiple_lines_over_a_selection_respects_max_le Lines::Multiple, DOMString::from("hello\nworld"), DummyClipboardContext::new(""), - Some(17) + Some(17), + SelectionDirection::None, ); textinput.edit_point = TextPoint { line: 0, index: 1 }; @@ -59,7 +60,8 @@ fn test_textinput_when_inserting_multiple_lines_still_respects_max_length() { Lines::Multiple, DOMString::from("hello\nworld"), DummyClipboardContext::new(""), - Some(17) + Some(17), + SelectionDirection::None ); textinput.edit_point = TextPoint { line: 1, index: 0 }; @@ -75,7 +77,8 @@ fn test_textinput_when_content_is_already_longer_than_max_length_and_theres_no_s Lines::Single, DOMString::from("abc"), DummyClipboardContext::new(""), - Some(1) + Some(1), + SelectionDirection::None, ); textinput.insert_char('a'); @@ -89,7 +92,8 @@ fn test_multi_line_textinput_with_maxlength_doesnt_allow_appending_characters_wh Lines::Multiple, DOMString::from("abc\nd"), DummyClipboardContext::new(""), - Some(5) + Some(5), + SelectionDirection::None, ); textinput.insert_char('a'); @@ -103,7 +107,8 @@ fn test_single_line_textinput_with_max_length_doesnt_allow_appending_characters_ Lines::Single, DOMString::from("abcde"), DummyClipboardContext::new(""), - Some(5) + Some(5), + SelectionDirection::None, ); textinput.edit_point = TextPoint { line: 0, index: 1 }; @@ -123,7 +128,8 @@ fn test_single_line_textinput_with_max_length_multibyte() { Lines::Single, DOMString::from(""), DummyClipboardContext::new(""), - Some(2) + Some(2), + SelectionDirection::None, ); textinput.insert_char('á'); @@ -140,7 +146,8 @@ fn test_single_line_textinput_with_max_length_multi_code_unit() { Lines::Single, DOMString::from(""), DummyClipboardContext::new(""), - Some(3) + Some(3), + SelectionDirection::None, ); textinput.insert_char('\u{10437}'); @@ -159,7 +166,8 @@ fn test_single_line_textinput_with_max_length_inside_char() { Lines::Single, DOMString::from("\u{10437}"), DummyClipboardContext::new(""), - Some(1) + Some(1), + SelectionDirection::None, ); textinput.insert_char('x'); @@ -172,7 +180,8 @@ fn test_single_line_textinput_with_max_length_doesnt_allow_appending_characters_ Lines::Single, DOMString::from("a"), DummyClipboardContext::new(""), - Some(1) + Some(1), + SelectionDirection::None, ); textinput.insert_char('b'); @@ -388,7 +397,8 @@ fn test_clipboard_paste() { let mut textinput = TextInput::new(Lines::Single, DOMString::from("defg"), DummyClipboardContext::new("abc"), - None); + None, + SelectionDirection::None); assert_eq!(textinput.get_content(), "defg"); assert_eq!(textinput.edit_point.index, 0); textinput.handle_keydown_aux(Key::V, MODIFIERS); |