aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/script/textinput.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2015-07-30 19:50:06 +0200
committerSimon Sapin <simon.sapin@exyr.org>2015-08-28 11:57:40 +0200
commit95a252a6501840d95da82e226034e9fbb798ad3e (patch)
tree3bc05f772bcc03e5bdd448414ed552df21b010a7 /tests/unit/script/textinput.rs
parent6431e8da43817e8a6b1e4757afbcf45c1a629707 (diff)
downloadservo-95a252a6501840d95da82e226034e9fbb798ad3e.tar.gz
servo-95a252a6501840d95da82e226034e9fbb798ad3e.zip
Refactor script::textinput to count UTF-8 bytes rather than code points.
Diffstat (limited to 'tests/unit/script/textinput.rs')
-rw-r--r--tests/unit/script/textinput.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/unit/script/textinput.rs b/tests/unit/script/textinput.rs
index aea84946427..313ab62fe0a 100644
--- a/tests/unit/script/textinput.rs
+++ b/tests/unit/script/textinput.rs
@@ -15,22 +15,29 @@ use msg::constellation_msg::SUPER;
use msg::constellation_msg::CONTROL;
use script::clipboard_provider::DummyClipboardContext;
-use script::textinput::{TextInput, Selection, Lines, DeleteDir};
+use script::textinput::{TextInput, Selection, Lines, Direction};
use std::borrow::ToOwned;
#[test]
fn test_textinput_delete_char() {
let mut textinput = TextInput::new(Lines::Single, "abcdefg".to_owned(), DummyClipboardContext::new(""));
textinput.adjust_horizontal(2, Selection::NotSelected);
- textinput.delete_char(DeleteDir::Backward);
+ textinput.delete_char(Direction::Backward);
assert_eq!(textinput.get_content(), "acdefg");
- textinput.delete_char(DeleteDir::Forward);
+ textinput.delete_char(Direction::Forward);
assert_eq!(textinput.get_content(), "adefg");
textinput.adjust_horizontal(2, Selection::Selected);
- textinput.delete_char(DeleteDir::Forward);
+ textinput.delete_char(Direction::Forward);
assert_eq!(textinput.get_content(), "afg");
+
+ let mut textinput = TextInput::new(Lines::Single, "a🌠b".to_owned(), DummyClipboardContext::new(""));
+ // Same as "Right" key
+ textinput.adjust_horizontal_by_one(Direction::Forward, Selection::NotSelected);
+ textinput.delete_char(Direction::Forward);
+ // Not splitting surrogate pairs.
+ assert_eq!(textinput.get_content(), "ab");
}
#[test]
@@ -43,6 +50,14 @@ fn test_textinput_insert_char() {
textinput.adjust_horizontal(2, Selection::Selected);
textinput.insert_char('b');
assert_eq!(textinput.get_content(), "ababefg");
+
+ let mut textinput = TextInput::new(Lines::Single, "a🌠c".to_owned(), DummyClipboardContext::new(""));
+ // Same as "Right" key
+ textinput.adjust_horizontal_by_one(Direction::Forward, Selection::NotSelected);
+ textinput.adjust_horizontal_by_one(Direction::Forward, Selection::NotSelected);
+ textinput.insert_char('b');
+ // Not splitting surrogate pairs.
+ assert_eq!(textinput.get_content(), "a🌠bc");
}
#[test]