diff options
author | Ms2ger <Ms2ger@gmail.com> | 2015-11-03 14:16:55 +0100 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2015-11-04 12:09:11 +0100 |
commit | 6b75078503f25a61084a3e9cae1b7d57de21772f (patch) | |
tree | ddfc15e73be407657f687f55d9c8b7bce5b9596c /tests/unit/script/textinput.rs | |
parent | e6aa976462fad0aafb2d59d0a590b69a8c8b5ba9 (diff) | |
download | servo-6b75078503f25a61084a3e9cae1b7d57de21772f.tar.gz servo-6b75078503f25a61084a3e9cae1b7d57de21772f.zip |
Make DOMString a newtype around String, rather than a typedef.
This should make it somewhat easier to experiment with alternative
representations in the future. To reduce churn, this commit leaves the String
field public, though.
Also, this will allow us to use the default String type to represent the IDL
USVString type, which explicitly forbids unpaired surrogates, ans as such is
a better match to the Rust String type.
Diffstat (limited to 'tests/unit/script/textinput.rs')
-rw-r--r-- | tests/unit/script/textinput.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/unit/script/textinput.rs b/tests/unit/script/textinput.rs index c252d8c8f74..da7555f7775 100644 --- a/tests/unit/script/textinput.rs +++ b/tests/unit/script/textinput.rs @@ -15,9 +15,10 @@ use msg::constellation_msg::{Key, KeyModifiers}; use script::clipboard_provider::DummyClipboardContext; use script::textinput::{TextInput, Selection, Lines, Direction}; use std::borrow::ToOwned; +use util::str::DOMString; fn text_input(lines: Lines, s: &str) -> TextInput<DummyClipboardContext> { - TextInput::new(lines, s.to_owned(), DummyClipboardContext::new("")) + TextInput::new(lines, DOMString(s.to_owned()), DummyClipboardContext::new("")) } #[test] @@ -85,7 +86,7 @@ fn test_textinput_replace_selection() { textinput.adjust_horizontal(2, Selection::NotSelected); textinput.adjust_horizontal(2, Selection::Selected); - textinput.replace_selection("xyz".to_owned()); + textinput.replace_selection(DOMString("xyz".to_owned())); assert_eq!(textinput.get_content(), "abxyzefg"); } @@ -176,7 +177,7 @@ fn test_textinput_set_content() { let mut textinput = text_input(Lines::Multiple, "abc\nde\nf"); assert_eq!(textinput.get_content(), "abc\nde\nf"); - textinput.set_content("abc\nf".to_owned()); + textinput.set_content(DOMString("abc\nf".to_owned())); assert_eq!(textinput.get_content(), "abc\nf"); assert_eq!(textinput.edit_point.line, 0); @@ -184,7 +185,7 @@ fn test_textinput_set_content() { textinput.adjust_horizontal(3, Selection::Selected); assert_eq!(textinput.edit_point.line, 0); assert_eq!(textinput.edit_point.index, 3); - textinput.set_content("de".to_owned()); + textinput.set_content(DOMString("de".to_owned())); assert_eq!(textinput.get_content(), "de"); assert_eq!(textinput.edit_point.line, 0); assert_eq!(textinput.edit_point.index, 2); @@ -197,7 +198,9 @@ fn test_clipboard_paste() { #[cfg(not(target_os = "macos"))] const MODIFIERS: KeyModifiers = CONTROL; - let mut textinput = TextInput::new(Lines::Single, "defg".to_owned(), DummyClipboardContext::new("abc")); + let mut textinput = TextInput::new(Lines::Single, + DOMString("defg".to_owned()), + DummyClipboardContext::new("abc")); assert_eq!(textinput.get_content(), "defg"); assert_eq!(textinput.edit_point.index, 0); textinput.handle_keydown_aux(Key::V, MODIFIERS); |