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");
}
}
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);
}
}
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;
}
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);
}
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, "");
}
Aggregations