Search in sources :

Example 1 with NativeContactDetails

use of com.vodafone360.people.tests.TestModule.NativeContactDetails in project 360-Engine-for-Android by 360.

the class FetchNativeContactsTest method checkContacts.

private void checkContacts(List<NativeContactDetails> nativeContactList) {
    for (int i = 0; i < nativeContactList.size(); i++) {
        NativeContactDetails ncd = nativeContactList.get(i);
        ContactIdInfo info = ContactsTable.fetchContactIdFromNative(ncd.mId, mDb.getReadableDatabase());
        Contact contact = new Contact();
        ServiceStatus status = mDb.fetchContact(info.localId, contact);
        assertEquals(ServiceStatus.SUCCESS, status);
        LogUtils.logI("Checking contact local ID " + info.localId + ", native ID " + ncd.mId);
        boolean nameDone = false;
        boolean nicknameDone = false;
        boolean noteDone = false;
        int phonesDone = 0;
        int emailsDone = 0;
        int addressesDone = 0;
        int orgsDone = 0;
        int titlesDone = 0;
        for (ContactDetail detail : contact.details) {
            assertEquals(ncd.mId, detail.nativeContactId);
            detail.syncNativeContactId = fetchSyncNativeId(detail.localDetailID);
            assertEquals("No sync marker, ID = " + detail.nativeDetailId + ", key = " + detail.key, Integer.valueOf(-1), detail.syncNativeContactId);
            switch(detail.key) {
                case VCARD_NAME:
                    nameDone = true;
                    assertEquals(ncd.mName.toString(), detail.nativeVal1);
                    break;
                case VCARD_NICKNAME:
                    nicknameDone = true;
                    assertEquals(ncd.mName.toString(), detail.nativeVal1);
                    break;
                case VCARD_NOTE:
                    noteDone = true;
                    assertEquals(ncd.mNote, detail.nativeVal1);
                    break;
                case VCARD_PHONE:
                    phonesDone++;
                    for (NativeDetail nd : ncd.mPhoneList) {
                        if (nd.mId.equals(detail.localDetailID)) {
                            assertEquals(nd.mValue1, detail.nativeVal1);
                            assertEquals(nd.mValue2, detail.nativeVal2);
                            assertEquals(nd.mValue3, detail.nativeVal3);
                            break;
                        }
                    }
                    break;
                case VCARD_EMAIL:
                    emailsDone++;
                    for (NativeDetail nd : ncd.mEmailList) {
                        if (nd.mId.equals(detail.localDetailID)) {
                            assertEquals(nd.mValue1, detail.nativeVal1);
                            assertEquals(nd.mValue2, detail.nativeVal2);
                            assertEquals(nd.mValue3, detail.nativeVal3);
                            break;
                        }
                    }
                    break;
                case VCARD_ADDRESS:
                    addressesDone++;
                    for (NativeDetail nd : ncd.mAddressList) {
                        if (nd.mId.equals(detail.localDetailID)) {
                            assertEquals(nd.mValue1, detail.nativeVal1);
                            assertEquals(nd.mValue2, detail.nativeVal2);
                            assertEquals(nd.mValue3, detail.nativeVal3);
                            break;
                        }
                    }
                    break;
                case VCARD_ORG:
                    orgsDone++;
                    for (NativeDetail nd : ncd.mOrgList) {
                        if (nd.mId.equals(detail.localDetailID)) {
                            assertEquals(nd.mValue1, detail.nativeVal1);
                            assertEquals(nd.mValue2, detail.nativeVal2);
                            assertEquals(nd.mValue3, detail.nativeVal3);
                            break;
                        }
                    }
                    break;
                case VCARD_TITLE:
                    titlesDone++;
                    for (NativeDetail nd : ncd.mTitleList) {
                        if (nd.mId.equals(detail.localDetailID)) {
                            assertEquals(nd.mValue1, detail.nativeVal1);
                            assertEquals(nd.mValue2, detail.nativeVal2);
                            assertEquals(nd.mValue3, detail.nativeVal3);
                            break;
                        }
                    }
                    break;
                default:
                    fail("Unexpected detail: " + detail.key);
            }
        }
        String nameString = ncd.mName.toString();
        if (nameString.length() > 0) {
            assertTrue("Name was not done", nameDone);
            assertTrue("Nickname was not done", nicknameDone);
        }
        if (ncd.mNote != null && ncd.mNote.length() > 0) {
            assertTrue("Note was not done", noteDone);
        }
        assertEquals(ncd.mPhoneList.size(), phonesDone);
        assertEquals(ncd.mEmailList.size(), emailsDone);
        assertEquals(ncd.mAddressList.size(), addressesDone);
        assertEquals(ncd.mOrgList.size(), orgsDone);
        assertEquals(ncd.mTitleList.size(), titlesDone);
    }
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) NativeContactDetails(com.vodafone360.people.tests.TestModule.NativeContactDetails) ContactIdInfo(com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo) ServiceStatus(com.vodafone360.people.service.ServiceStatus) NativeDetail(com.vodafone360.people.tests.TestModule.NativeDetail) Contact(com.vodafone360.people.datatypes.Contact)

Example 2 with NativeContactDetails

use of com.vodafone360.people.tests.TestModule.NativeContactDetails in project 360-Engine-for-Android by 360.

the class FetchNativeContactsTest method testRunBulkTest.

@LargeTest
@Suppress
public // Breaks tests.
void testRunBulkTest() {
    final String fnName = "testRunBulkTest";
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + " *****");
    mTestStep = 1;
    startSubTest(fnName, "Checking people database is empty");
    Cursor peopleCursor = mDb.openContactSummaryCursor(null, null);
    assertEquals(0, peopleCursor.getCount());
    assertTrue(Settings.ENABLE_UPDATE_NATIVE_CONTACTS);
    startSubTest(fnName, "Checking native database is empty");
    Cursor nativeCursor = mCr.query(People.CONTENT_URI, new String[] { People._ID, People.NAME, People.NOTES }, null, null, null);
    assertEquals(0, nativeCursor.getCount());
    startSubTest(fnName, "Add " + BULK_TEST_NO_CONTACTS + " dummy native contacts");
    List<NativeContactDetails> nativeContactList = new ArrayList<NativeContactDetails>();
    for (int i = 0; i < BULK_TEST_NO_CONTACTS; i++) {
        NativeContactDetails ncd = new NativeContactDetails();
        ncd = mTestModule.addNativeContact(mCr, generateNameType(i), (i & 15) == 5, (i & 3), (i & 3), (i & 3), (i & 3));
        assertTrue(ncd != null);
        nativeContactList.add(ncd);
    }
    startSubTest(fnName, "Running processor");
    runProcessor();
    startSubTest(fnName, "Checking people contact list");
    peopleCursor.requery();
    assertEquals(BULK_TEST_NO_CONTACTS, peopleCursor.getCount());
    checkContacts(nativeContactList);
    nativeCursor.close();
    peopleCursor.close();
    Log.i(LOG_TAG, "*************************************************************************");
    Log.i(LOG_TAG, fnName + " has completed successfully");
    Log.i(LOG_TAG, "*************************************************************************");
    Log.i(LOG_TAG, "");
}
Also used : NativeContactDetails(com.vodafone360.people.tests.TestModule.NativeContactDetails) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Suppress(android.test.suitebuilder.annotation.Suppress) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

NativeContactDetails (com.vodafone360.people.tests.TestModule.NativeContactDetails)2 Cursor (android.database.Cursor)1 LargeTest (android.test.suitebuilder.annotation.LargeTest)1 Suppress (android.test.suitebuilder.annotation.Suppress)1 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)1 Contact (com.vodafone360.people.datatypes.Contact)1 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)1 ServiceStatus (com.vodafone360.people.service.ServiceStatus)1 NativeDetail (com.vodafone360.people.tests.TestModule.NativeDetail)1 ArrayList (java.util.ArrayList)1