diff options
author | Gary Mai <garymai@google.com> | 2016-10-10 15:41:48 -0700 |
---|---|---|
committer | Gary Mai <garymai@google.com> | 2016-10-11 14:18:24 -0700 |
commit | 7a6daea69ea47c31a1b838a423e7cdaceafae753 (patch) | |
tree | a0785eb2c06d7bc4814627b0efa3bdc8d87fac79 /tests | |
parent | 3d0d03ee618e2ae1046c5b4781320015e39daaf0 (diff) | |
download | Contacts-7a6daea69ea47c31a1b838a423e7cdaceafae753.tar.gz |
Reintroduce pseudo mimetype for name
In order to have a separate edit DataKind for phonetic name
we need a pseudo mimetype for just the name as well. The pseudo
DataKinds are used to render the actual text fields while the
StructuredName mimetype DataKind is used for checking if any
thing was changed.
Test:
Unit tests
Save a new contact while entering only the phonetic name
Bug: 32023197
Bug: 21758689
Change-Id: I151b37b7be091705974e3f36770e4bb0e150a64d
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java b/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java index 684a379ec..96e776ff8 100644 --- a/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java +++ b/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java @@ -31,12 +31,14 @@ import android.provider.ContactsContract.CommonDataKinds.Website; import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.Suppress; -import android.util.Log; import com.android.contacts.common.model.dataitem.DataKind; import com.android.contacts.common.tests.R; + import com.google.common.base.Objects; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -47,6 +49,12 @@ import java.util.List; */ @SmallTest public class ExternalAccountTypeTest extends InstrumentationTestCase { + private static ArrayList<String> mDefaultMimetypes = new ArrayList<>(Arrays.asList( + StructuredName.CONTENT_ITEM_TYPE, + DataKind.PSEUDO_MIME_TYPE_NAME, + DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME, + Photo.CONTENT_ITEM_TYPE + )); @Suppress public void testResolveExternalResId() { @@ -92,6 +100,7 @@ public class ExternalAccountTypeTest extends InstrumentationTestCase { // Let's just check if the DataKinds are registered. assertNotNull(type.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE)); + assertNotNull(type.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_NAME)); assertNotNull(type.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME)); assertNotNull(type.getKindForMimetype(Email.CONTENT_ITEM_TYPE)); assertNotNull(type.getKindForMimetype(StructuredPostal.CONTENT_ITEM_TYPE)); @@ -159,13 +168,13 @@ public class ExternalAccountTypeTest extends InstrumentationTestCase { // Shouldn't have a "null" mimetype. assertTrue(type.getKindForMimetype(null) == null); - // 3 kinds are defined in XML and 3 are added by default. - assertEquals(3 + 3, type.getSortedDataKinds().size()); + // 3 kinds are defined in XML and the rest are added by default. + assertEquals(3 + mDefaultMimetypes.size(), type.getSortedDataKinds().size()); // Check for the default kinds. - assertNotNull(type.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE)); - assertNotNull(type.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME)); - assertNotNull(type.getKindForMimetype(Photo.CONTENT_ITEM_TYPE)); + for (String mimetype : mDefaultMimetypes) { + assertNotNull(type.getKindForMimetype(mimetype)); + } // Check for type specific kinds. DataKind kind = type.getKindForMimetype("vnd.android.cursor.item/a.b.c"); |