summaryrefslogtreecommitdiffstats
path: root/chips/tests
diff options
context:
space:
mode:
authorScott Kennedy <skennedy@google.com>2013-03-06 22:23:59 -0800
committerScott Kennedy <skennedy@google.com>2013-03-06 23:14:59 -0800
commit563bbd3883a226dd1529170a6df937c8f9c8bd43 (patch)
treee0b627a86c4f8d91b96f6dd3a889cc3580ff1d6e /chips/tests
parentb48368b1a1b15fd52c66ff9432429c744c411932 (diff)
downloadandroid_frameworks_ex-563bbd3883a226dd1529170a6df937c8f9c8bd43.tar.gz
android_frameworks_ex-563bbd3883a226dd1529170a6df937c8f9c8bd43.tar.bz2
android_frameworks_ex-563bbd3883a226dd1529170a6df937c8f9c8bd43.zip
Add a test case for b/8321211
Emails like: "Ex Ample" <example@example.com> were displaying improperly. Change-Id: Idd43814352e0c4455733adc13b89eb6fc1aca1bb
Diffstat (limited to 'chips/tests')
-rw-r--r--chips/tests/src/com/android/ex/chips/ChipsTest.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/chips/tests/src/com/android/ex/chips/ChipsTest.java b/chips/tests/src/com/android/ex/chips/ChipsTest.java
index 3d020a3..be74627 100644
--- a/chips/tests/src/com/android/ex/chips/ChipsTest.java
+++ b/chips/tests/src/com/android/ex/chips/ChipsTest.java
@@ -929,4 +929,62 @@ public class ChipsTest extends AndroidTestCase {
mMockRecips[i] = new VisibleRecipientChip(null, mMockEntries[i]);
}
}
+
+ /**
+ * <p>
+ * Ensure the original text is always accurate, regardless of the type of email. The original
+ * text is used to determine where to display the chip span. If this test fails, it means some
+ * text that should be turned into one whole chip may behave unexpectedly.
+ * </p>
+ * <p>
+ * For example, a bug was seen where
+ *
+ * <pre>
+ * "Android User" <android@example.com>
+ * </pre>
+ *
+ * was converted to
+ *
+ * <pre>
+ * Android User [android@example.com]
+ * </pre>
+ *
+ * where text inside [] is a chip.
+ * </p>
+ */
+ public void testCreateReplacementChipOriginalText() {
+ // Name in quotes + email address
+ testCreateReplacementChipOriginalText("\"Android User\" <android@example.com>,");
+ // Name in quotes + email address without brackets
+ testCreateReplacementChipOriginalText("\"Android User\" android@example.com,");
+ // Name in quotes
+ testCreateReplacementChipOriginalText("\"Android User\",");
+ // Name without quotes + email address
+ testCreateReplacementChipOriginalText("Android User <android@example.com>,");
+ // Name without quotes
+ testCreateReplacementChipOriginalText("Android User,");
+ // Email address
+ testCreateReplacementChipOriginalText("<android@example.com>,");
+ // Email address without brackets
+ testCreateReplacementChipOriginalText("android@example.com,");
+ }
+
+ private void testCreateReplacementChipOriginalText(final String email) {
+ // No trailing space
+ attemptCreateReplacementChipOriginalText(email.trim());
+ // Trailing space
+ attemptCreateReplacementChipOriginalText(email.trim() + " ");
+ }
+
+ private void attemptCreateReplacementChipOriginalText(final String email) {
+ final RecipientEditTextView view = new RecipientEditTextView(getContext(), null);
+
+ view.setText(email);
+ view.mPendingChips.add(email);
+
+ view.createReplacementChip(0, email.length(), view.getText(), true);
+ // The "original text" should be the email without the comma or space(s)
+ assertEquals(email.replaceAll(",\\s*$", ""),
+ view.mTemporaryRecipients.get(0).getOriginalText().toString().trim());
+ }
}