diff options
author | Paul Soulos <psoulos@google.com> | 2014-07-07 11:46:49 -0700 |
---|---|---|
committer | Paul Soulos <psoulos@google.com> | 2014-07-07 11:46:49 -0700 |
commit | 35408bef2b7a180dfa5860e87d4d62209d9d1e09 (patch) | |
tree | 31e4df4a33791b6a82cd7d317337c6f480fd208e /tests | |
parent | 4ab0cc8065d7080d8ea899814b0efd98908cb1b3 (diff) | |
download | android_packages_apps_ContactsCommon-35408bef2b7a180dfa5860e87d4d62209d9d1e09.tar.gz android_packages_apps_ContactsCommon-35408bef2b7a180dfa5860e87d4d62209d9d1e09.tar.bz2 android_packages_apps_ContactsCommon-35408bef2b7a180dfa5860e87d4d62209d9d1e09.zip |
Moves getCustomIMIntent to Util class
Change-Id: I7b8f818becb5e0e1d855db742de053d9a23a09a2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/contacts/common/ContactsUtilsTests.java | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/tests/src/com/android/contacts/common/ContactsUtilsTests.java b/tests/src/com/android/contacts/common/ContactsUtilsTests.java index c0df3dd4..eeaf1211 100644 --- a/tests/src/com/android/contacts/common/ContactsUtilsTests.java +++ b/tests/src/com/android/contacts/common/ContactsUtilsTests.java @@ -14,15 +14,18 @@ * limitations under the License. */ -package src.com.android.contacts.common; +package com.android.contacts.common; +import android.content.ContentValues; import android.content.Intent; -import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.net.Uri; +import android.provider.ContactsContract.CommonDataKinds.Im; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import com.android.contacts.common.ContactsUtils; -import com.android.contacts.common.MoreContactUtils; +import com.android.contacts.common.model.dataitem.DataItem; +import com.android.contacts.common.model.dataitem.ImDataItem; /** * Tests for {@link ContactsUtils}. @@ -66,4 +69,29 @@ public class ContactsUtilsTests extends AndroidTestCase { assertFalse("22", ContactsUtils.areIntentActionEqual(new Intent(), new Intent("b"))); assertFalse("23", ContactsUtils.areIntentActionEqual(new Intent("a"), new Intent("b"))); } + + public void testImIntentCustom() throws Exception { + final String testAddress = "user@example.org"; + final String testProtocol = "prot%col"; + + + // Custom IM types have encoded authority. We send the imto Intent here, because + // legacy third party apps might not accept xmpp yet + final ContentValues values = new ContentValues(); + values.put(Im.MIMETYPE, Im.CONTENT_ITEM_TYPE); + values.put(Im.TYPE, Im.TYPE_HOME); + values.put(Im.PROTOCOL, Im.PROTOCOL_CUSTOM); + values.put(Im.CUSTOM_PROTOCOL, testProtocol); + values.put(Im.DATA, testAddress); + ImDataItem im = (ImDataItem) DataItem.createFrom(values); + + final Intent imIntent = + ContactsUtils.getCustomIMIntent(im, Im.PROTOCOL_CUSTOM); + assertEquals(Intent.ACTION_SENDTO, imIntent.getAction()); + + final Uri data = imIntent.getData(); + assertEquals("imto", data.getScheme()); + assertEquals(testProtocol, data.getAuthority()); + assertEquals(testAddress, data.getPathSegments().get(0)); + } } |