merge from open-source master
Change-Id: Idf8d5661d7b261b74ac0b1271af98795ac5faff9
This commit is contained in:
@@ -84,8 +84,10 @@ public class Rfc822Tokenizer implements MultiAutoCompleteTextView.Tokenizer {
|
||||
if (c == '"') {
|
||||
i++;
|
||||
break;
|
||||
} else if (c == '\\' && i + 1 < cursor) {
|
||||
name.append(text.charAt(i + 1));
|
||||
} else if (c == '\\') {
|
||||
if (i + 1 < cursor) {
|
||||
name.append(text.charAt(i + 1));
|
||||
}
|
||||
i += 2;
|
||||
} else {
|
||||
name.append(c);
|
||||
@@ -110,8 +112,10 @@ public class Rfc822Tokenizer implements MultiAutoCompleteTextView.Tokenizer {
|
||||
comment.append(c);
|
||||
level++;
|
||||
i++;
|
||||
} else if (c == '\\' && i + 1 < cursor) {
|
||||
comment.append(text.charAt(i + 1));
|
||||
} else if (c == '\\') {
|
||||
if (i + 1 < cursor) {
|
||||
comment.append(text.charAt(i + 1));
|
||||
}
|
||||
i += 2;
|
||||
} else {
|
||||
comment.append(c);
|
||||
|
||||
@@ -26,6 +26,8 @@ import android.text.SpannedString;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.text.util.Rfc822Token;
|
||||
import android.text.util.Rfc822Tokenizer;
|
||||
import android.test.MoreAsserts;
|
||||
|
||||
import com.android.common.Rfc822Validator;
|
||||
@@ -269,6 +271,24 @@ public class TextUtilsTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testRfc822TokenizerFullAddress() {
|
||||
Rfc822Token[] tokens = Rfc822Tokenizer.tokenize("Foo Bar (something) <foo@google.com>");
|
||||
assertNotNull(tokens);
|
||||
assertEquals(1, tokens.length);
|
||||
assertEquals("foo@google.com", tokens[0].getAddress());
|
||||
assertEquals("Foo Bar", tokens[0].getName());
|
||||
assertEquals("something",tokens[0].getComment());
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testRfc822TokenizeItemWithError() {
|
||||
Rfc822Token[] tokens = Rfc822Tokenizer.tokenize("\"Foo Bar\\");
|
||||
assertNotNull(tokens);
|
||||
assertEquals(1, tokens.length);
|
||||
assertEquals("Foo Bar", tokens[0].getAddress());
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
public void testEllipsize() {
|
||||
CharSequence s1 = "The quick brown fox jumps over \u00FEhe lazy dog.";
|
||||
|
||||
Reference in New Issue
Block a user