Fix a failing test
Change-Id: Iaa45618d69ea12aa6714bcae36c8f12a253d5df2
diff --git a/src/com/android/ex/chips/RecipientEntry.java b/src/com/android/ex/chips/RecipientEntry.java
index 1a79f32..14b11e1 100644
--- a/src/com/android/ex/chips/RecipientEntry.java
+++ b/src/com/android/ex/chips/RecipientEntry.java
@@ -19,6 +19,8 @@
import android.net.Uri;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.DisplayNameSources;
+import android.text.util.Rfc822Token;
+import android.text.util.Rfc822Tokenizer;
/**
* Represents one entry inside recipient auto-complete list.
@@ -106,8 +108,11 @@
* This address has not been resolved to a contact and therefore does not
* have a contact id or photo.
*/
- public static RecipientEntry constructFakeEntry(String address, boolean isValid) {
- return new RecipientEntry(ENTRY_TYPE_PERSON, address, address,
+ public static RecipientEntry constructFakeEntry(final String address, final boolean isValid) {
+ final Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(address);
+ final String tokenizedAddress = tokens[0].getAddress();
+
+ return new RecipientEntry(ENTRY_TYPE_PERSON, tokenizedAddress, tokenizedAddress,
INVALID_DESTINATION_TYPE, null,
INVALID_CONTACT, INVALID_CONTACT, null, true, isValid);
}
diff --git a/tests/src/com/android/ex/chips/ChipsTest.java b/tests/src/com/android/ex/chips/ChipsTest.java
index 480335a..534b34f 100644
--- a/tests/src/com/android/ex/chips/ChipsTest.java
+++ b/tests/src/com/android/ex/chips/ChipsTest.java
@@ -142,7 +142,6 @@
"\"User Name, Jr\" <user@username.com>, ", testAddress);
assertEquals("Expected a displayable name", "User Name, Jr", testDisplay);
-
RecipientEntry alreadyFormatted =
RecipientEntry.constructFakeEntry("user@username.com, ", true);
testAddress = view.createAddressText(alreadyFormatted);