Search in sources :

Example 16 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class LoginEngineTest method testFetchUserNameState.

@MediumTest
// Breaks tests.
@Suppress
public void testFetchUserNameState() {
    mState = LoginTestState.USER_NAME_STATE;
    String userName = null;
    try {
        synchronized (mEngineTester) {
            mEng.addUiGetUsernameStateRequest(userName);
            ServiceStatus status = mEngineTester.waitForEvent();
            assertEquals(ServiceStatus.ERROR_COMMS, status);
        }
    } catch (Exception e) {
        displayException(e);
        fail("testFetchUserNameState test 1 failed with exception");
    }
    userName = "bwibble";
    try {
        synchronized (mEngineTester) {
            mEng.addUiGetUsernameStateRequest(userName);
            ServiceStatus status = mEngineTester.waitForEvent();
            assertEquals(ServiceStatus.SUCCESS, status);
        }
    } catch (Exception e) {
        displayException(e);
        fail("testFetchUserNameState test 2 failed with exception");
    }
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 17 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class FetchNativeContacts method onTimeoutEvent.

@Override
public void onTimeoutEvent() {
    LogUtils.logD("FetchNativeContacts.onTimeoutEvent()");
    // call the tick method of the NativeImporter
    final boolean isDone = mNativeImporter.tick();
    // get the index of the last processed id
    final int position = mNativeImporter.getPosition();
    // get the total count of ids to process
    final int total = mNativeImporter.getCount();
    // get the percentage out of position and total count
    final int percentage = (total != 0) ? ((position * 100) / total) : 100;
    LogUtils.logD("FetchNativeContacts.onTimeoutEvent() - pos=" + position + ", total=" + total + ", percentage=" + percentage);
    // check the NativeImporter progress
    if (!isDone) {
        // report the current progress
        // pass an empty name as currently the last processed contact name by the NativeImporter can't be known
        setProgress("", percentage, position, total);
        // yield some time to the other engines and request to be called back immediately
        setTimeout(0);
    } else {
        final ServiceStatus status = mNativeImporter.getResult() == NativeImporter.RESULT_OK ? ServiceStatus.SUCCESS : ServiceStatus.ERROR_UNKNOWN;
        LogUtils.logD("FetchNativeContacts.onTimeoutEvent() - complete(" + status + ")");
        setProgress("", percentage, position, total);
        complete(status);
    }
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 18 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class FetchCallLogEvents method updateDatabase.

private ServiceStatus updateDatabase() {
    ServiceStatus status = mDb.addTimelineEvents(mSyncItemList, true);
    updateTimeStamps();
    saveTimestamp();
    mSyncItemList.clear();
    return status;
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 19 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class UploadServerContactsTest method runProcessor.

private void runProcessor(int count, State state) {
    mInitialCount = count;
    nextState(state);
    mEng.mProcessorCompleteFlag = false;
    mProcessor.start();
    ServiceStatus status = mEng.waitForProcessorComplete(MAX_PROCESSOR_TIME);
    assertEquals(ServiceStatus.SUCCESS, status);
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 20 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class UploadServerContactsTest method testRunWithAddDeleteContactDetailChange.

@Suppress
public // Breaks tests
void testRunWithAddDeleteContactDetailChange() {
    final String fnName = "testRunWithAddDeleteContactDetailChange";
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + " *****");
    mTestStep = 1;
    startSubTest(fnName, "Checking change list is empty");
    long noOfChanges = ContactChangeLogTable.fetchNoOfContactDetailChanges(null, mDb.getReadableDatabase());
    assertEquals(0, noOfChanges);
    noOfChanges = ContactDetailsTable.syncNativeFetchNoOfChanges(mDb.getReadableDatabase());
    assertEquals(0, noOfChanges);
    startSubTest(fnName, "Adding test contact to database");
    Contact contact = mTestModule.createDummyContactData();
    contact.contactID = TestModule.generateRandomLong();
    contact.userID = generateTestUserID(contact.contactID);
    List<Contact> contactList = new ArrayList<Contact>();
    contactList.add(contact);
    ServiceStatus status = mDb.syncAddContactList(contactList, false, false);
    assertEquals(ServiceStatus.SUCCESS, status);
    startSubTest(fnName, "Adding new detail to contact");
    ContactDetail newDetail = new ContactDetail();
    newDetail.value = NEW_DETAIL_VALUE;
    newDetail.key = NEW_DETAIL_KEY;
    newDetail.keyType = NEW_DETAIL_TYPE;
    newDetail.localContactID = contact.localContactID;
    status = mDb.addContactDetail(newDetail);
    assertEquals(ServiceStatus.SUCCESS, status);
    startSubTest(fnName, "Deleting contact detail without unique ID");
    status = mDb.deleteContactDetail(contact.details.get(0).localDetailID);
    assertEquals(ServiceStatus.SUCCESS, status);
    startSubTest(fnName, "Deleting contact detail with unique ID");
    status = mDb.deleteContactDetail(newDetail.localDetailID);
    assertEquals(ServiceStatus.SUCCESS, status);
    startSubTest(fnName, "Running processor");
    runProcessor(1, State.DELETE_CONTACT_DETAIL_LIST);
    assertEquals(State.IDLE, mState);
    noOfChanges = ContactChangeLogTable.fetchNoOfContactDetailChanges(null, mDb.getReadableDatabase());
    assertEquals(0, noOfChanges);
    noOfChanges = ContactDetailsTable.syncNativeFetchNoOfChanges(mDb.getReadableDatabase());
    assertEquals(0, noOfChanges);
    startSubTest(fnName, "Running processor with no contact changes");
    runProcessor(0, State.IDLE);
    Log.i(LOG_TAG, "*************************************************************************");
    Log.i(LOG_TAG, fnName + " has completed successfully");
    Log.i(LOG_TAG, "*************************************************************************");
    Log.i(LOG_TAG, "");
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) Contact(com.vodafone360.people.datatypes.Contact) Suppress(android.test.suitebuilder.annotation.Suppress)

Aggregations

ServiceStatus (com.vodafone360.people.service.ServiceStatus)190 Contact (com.vodafone360.people.datatypes.Contact)71 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)63 MediumTest (android.test.suitebuilder.annotation.MediumTest)62 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)43 ArrayList (java.util.ArrayList)43 Suppress (android.test.suitebuilder.annotation.Suppress)40 Cursor (android.database.Cursor)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)17 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)16 Bundle (android.os.Bundle)12 ContentValues (android.content.ContentValues)11 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)11 SQLException (android.database.SQLException)9 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)9 ContactsTable (com.vodafone360.people.database.tables.ContactsTable)9 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)9 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)8 LoginDetails (com.vodafone360.people.datatypes.LoginDetails)8 PersistSettings (com.vodafone360.people.service.PersistSettings)8