Auto merge of #5547 - aweinstock314:x11-clipboard, r=jdm

Manual re-opening of #5479 (since it seems that GitHub disables re-opening with the same number after a rebase).

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5547)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-04-21 14:41:32 -05:00
commit 9974ebb2f9
12 changed files with 104 additions and 23 deletions

View file

@ -12,7 +12,7 @@ use std::borrow::ToOwned;
#[test]
fn test_textinput_delete_char() {
let mut textinput = TextInput::new(Lines::Single, "abcdefg".to_owned());
let mut textinput = TextInput::new(Lines::Single, "abcdefg".to_owned(), None);
textinput.adjust_horizontal(2, Selection::NotSelected);
textinput.delete_char(DeleteDir::Backward);
assert_eq!(textinput.get_content(), "acdefg");
@ -27,7 +27,7 @@ fn test_textinput_delete_char() {
#[test]
fn test_textinput_insert_char() {
let mut textinput = TextInput::new(Lines::Single, "abcdefg".to_owned());
let mut textinput = TextInput::new(Lines::Single, "abcdefg".to_owned(), None);
textinput.adjust_horizontal(2, Selection::NotSelected);
textinput.insert_char('a');
assert_eq!(textinput.get_content(), "abacdefg");
@ -39,7 +39,7 @@ fn test_textinput_insert_char() {
#[test]
fn test_textinput_get_sorted_selection() {
let mut textinput = TextInput::new(Lines::Single, "abcdefg".to_owned());
let mut textinput = TextInput::new(Lines::Single, "abcdefg".to_owned(), None);
textinput.adjust_horizontal(2, Selection::NotSelected);
textinput.adjust_horizontal(2, Selection::Selected);
let (begin, end) = textinput.get_sorted_selection();
@ -56,7 +56,7 @@ fn test_textinput_get_sorted_selection() {
#[test]
fn test_textinput_replace_selection() {
let mut textinput = TextInput::new(Lines::Single, "abcdefg".to_owned());
let mut textinput = TextInput::new(Lines::Single, "abcdefg".to_owned(), None);
textinput.adjust_horizontal(2, Selection::NotSelected);
textinput.adjust_horizontal(2, Selection::Selected);
@ -66,7 +66,7 @@ fn test_textinput_replace_selection() {
#[test]
fn test_textinput_current_line_length() {
let mut textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned());
let mut textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned(), None);
assert_eq!(textinput.current_line_length(), 3);
textinput.adjust_vertical(1, Selection::NotSelected);
@ -78,7 +78,7 @@ fn test_textinput_current_line_length() {
#[test]
fn test_textinput_adjust_vertical() {
let mut textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned());
let mut textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned(), None);
textinput.adjust_horizontal(3, Selection::NotSelected);
textinput.adjust_vertical(1, Selection::NotSelected);
assert_eq!(textinput.edit_point.line, 1);
@ -95,7 +95,7 @@ fn test_textinput_adjust_vertical() {
#[test]
fn test_textinput_adjust_horizontal() {
let mut textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned());
let mut textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned(), None);
textinput.adjust_horizontal(4, Selection::NotSelected);
assert_eq!(textinput.edit_point.line, 1);
assert_eq!(textinput.edit_point.index, 0);
@ -115,12 +115,12 @@ fn test_textinput_adjust_horizontal() {
#[test]
fn test_textinput_handle_return() {
let mut single_line_textinput = TextInput::new(Lines::Single, "abcdef".to_owned());
let mut single_line_textinput = TextInput::new(Lines::Single, "abcdef".to_owned(), None);
single_line_textinput.adjust_horizontal(3, Selection::NotSelected);
single_line_textinput.handle_return();
assert_eq!(single_line_textinput.get_content(), "abcdef");
let mut multi_line_textinput = TextInput::new(Lines::Multiple, "abcdef".to_owned());
let mut multi_line_textinput = TextInput::new(Lines::Multiple, "abcdef".to_owned(), None);
multi_line_textinput.adjust_horizontal(3, Selection::NotSelected);
multi_line_textinput.handle_return();
assert_eq!(multi_line_textinput.get_content(), "abc\ndef");
@ -128,7 +128,7 @@ fn test_textinput_handle_return() {
#[test]
fn test_textinput_select_all() {
let mut textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned());
let mut textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned(), None);
assert_eq!(textinput.edit_point.line, 0);
assert_eq!(textinput.edit_point.index, 0);
@ -139,16 +139,16 @@ fn test_textinput_select_all() {
#[test]
fn test_textinput_get_content() {
let single_line_textinput = TextInput::new(Lines::Single, "abcdefg".to_owned());
let single_line_textinput = TextInput::new(Lines::Single, "abcdefg".to_owned(), None);
assert_eq!(single_line_textinput.get_content(), "abcdefg");
let multi_line_textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned());
let multi_line_textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned(), None);
assert_eq!(multi_line_textinput.get_content(), "abc\nde\nf");
}
#[test]
fn test_textinput_set_content() {
let mut textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned());
let mut textinput = TextInput::new(Lines::Multiple, "abc\nde\nf".to_owned(), None);
assert_eq!(textinput.get_content(), "abc\nde\nf");
textinput.set_content("abc\nf".to_owned());