Search in sources :

Example 46 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project 360-Engine-for-Android by 360.

the class UploadServerContactsTest method testRunWithAddDeleteGroupChange.

@Suppress
public // Breaks tests
void testRunWithAddDeleteGroupChange() {
    final String fnName = "testRunWithAddDeleteGroupChange";
    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>();
    contact.groupList.clear();
    contactList.add(contact);
    ServiceStatus status = mDb.syncAddContactList(contactList, false, false);
    assertEquals(ServiceStatus.SUCCESS, status);
    startSubTest(fnName, "Adding group to contact");
    status = mDb.addContactToGroup(contact.localContactID, TEST_GROUP_1);
    assertEquals(ServiceStatus.SUCCESS, status);
    startSubTest(fnName, "Removing group from contact");
    status = mDb.deleteContactFromGroup(contact.localContactID, TEST_GROUP_1);
    assertEquals(ServiceStatus.SUCCESS, status);
    startSubTest(fnName, "Running processor");
    runProcessor(0, State.IDLE);
    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 : ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) Contact(com.vodafone360.people.datatypes.Contact) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 47 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project 360-Engine-for-Android by 360.

the class UploadServerContactsTest method testRunWithContactDeletion.

@MediumTest
@Suppress
public // Breaks tests
void testRunWithContactDeletion() {
    final String fnName = "testRunWithContactDeletion";
    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 - no sync");
    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, "Deleting contact");
    status = mDb.deleteContact(contact.localContactID);
    assertEquals(ServiceStatus.SUCCESS, status);
    startSubTest(fnName, "Running processor");
    runProcessor(1, State.DELETE_CONTACT_LIST);
    assertEquals(State.IDLE, mState);
    startSubTest(fnName, "Checking change list is empty");
    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 : ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) Contact(com.vodafone360.people.datatypes.Contact) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 48 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project 360-Engine-for-Android by 360.

the class ResponseReaderThreadTest method testRun_exception.

@Suppress
@MediumTest
public void testRun_exception() {
    DecoderThread decoder = new DecoderThread();
    MockTcpConnectionThread mockThread = new MockTcpConnectionThread(decoder, null);
    MockResponseReaderThread respReader = new MockResponseReaderThread(mockThread, decoder, // QUICKFIX: Not sure about this value
    null);
    MockOTAInputStream mIs = new MockOTAInputStream(new ByteArrayInputStream(new byte[] { 1, 2, 3, 4, 5 }));
    respReader.setInputStream(new BufferedInputStream(mIs));
    // IO Exception test
    try {
        mIs.close();
    } catch (IOException e) {
    }
    respReader.startConnection();
    try {
        Thread.sleep(1000);
    } catch (Exception e) {
    }
    assertTrue(mockThread.getDidErrorOccur());
    respReader.stopConnection();
    mockThread = null;
    respReader = null;
    // NP Exception test
    mockThread = new MockTcpConnectionThread(new DecoderThread(), null);
    respReader = new MockResponseReaderThread(mockThread, decoder, // QUICKFIX: Not sure about this value
    null);
    respReader.setInputStream(null);
    respReader.startConnection();
    try {
        Thread.sleep(1000);
    } catch (Exception e) {
    }
    assertTrue(mockThread.getDidErrorOccur());
    respReader.stopConnection();
    mockThread = null;
    respReader = null;
    // EOF Exception
    mockThread = new MockTcpConnectionThread(new DecoderThread(), null);
    respReader = new MockResponseReaderThread(mockThread, decoder, // QUICKFIX: Not sure about this value
    null);
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[] { 1 });
    respReader.setInputStream(new BufferedInputStream(bais));
    respReader.startConnection();
    try {
        Thread.sleep(1000);
    } catch (Exception e) {
    }
    assertTrue(mockThread.getDidErrorOccur());
    respReader.stopConnection();
    mockThread = null;
    respReader = null;
}
Also used : DecoderThread(com.vodafone360.people.service.transport.DecoderThread) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedInputStream(java.io.BufferedInputStream) MockTcpConnectionThread(com.vodafone360.people.tests.service.transport.tcp.conn_less.hb_tests.MockTcpConnectionThread) IOException(java.io.IOException) IOException(java.io.IOException) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 49 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project 360-Engine-for-Android by 360.

the class NativeContactsApiTest method testAddGetRemoveContacts.

@MediumTest
@Suppress
public void testAddGetRemoveContacts() {
    Account account = null;
    if (mUsing2xApi) {
        // Add Account for the case where we are in 2.X
        mNabApi.addPeopleAccount(PEOPLE_USERNAME);
        account = s360PeopleAccount;
        threadWait(100);
    }
    long[] ids = getContactIdsForAllAccounts();
    assertNull(ids);
    final int numRandomContacts = 10;
    long expectedContactId = ContactChange.INVALID_ID;
    for (int i = 0; i < numRandomContacts; i++) {
        long id = i;
        final ContactChange[] newContactCcList = ContactChangeHelper.randomContact(id, id, -1);
        final ContactChange[] newIds = mNabApi.addContact(account, newContactCcList);
        // expected num ids is + 1 for contact id
        verifyNewContactIds(expectedContactId, newContactCcList, newIds);
        expectedContactId = newIds[0].getNabContactId() + 1;
        // GET CONTACTS AND COMPARE
        ids = getContactIdsForAllAccounts();
        assertNotNull(ids);
        assertEquals(i + 1, ids.length);
        final ContactChange[] fetchedContactCcList = mNabApi.getContact(ids[i]);
        assertNotNull(fetchedContactCcList);
        if (!ContactChangeHelper.areChangeListsEqual(newContactCcList, fetchedContactCcList, false)) {
            Log.e(LOG_TAG, "ADD FAILED: Print of contact to be added follows:");
            ContactChangeHelper.printContactChangeList(newContactCcList);
            Log.e(LOG_TAG, "ADD FAILED: Print of contact fetched follows:");
            ContactChangeHelper.printContactChangeList(fetchedContactCcList);
            // fail test at this point
            assertFalse(true);
        }
    }
    // DELETE
    final int idCount = ids.length;
    for (int i = 0; i < idCount; i++) {
        mNabApi.removeContact(ids[i]);
    }
    ids = getContactIdsForAllAccounts();
    assertNull(ids);
}
Also used : Account(com.vodafone360.people.engine.contactsync.NativeContactsApi.Account) ContactChange(com.vodafone360.people.engine.contactsync.ContactChange) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 50 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project 360-Engine-for-Android by 360.

the class NowPlusContactsTest method testAddContactDetail.

@SmallTest
@Suppress
public void testAddContactDetail() {
    assertTrue(initialise());
    mDatabaseHelper.removeUserData();
    ServiceStatus status = mTestUtility.waitForEvent(WAIT_EVENT_TIMEOUT_MS, DbTestUtility.CONTACTS_INT_EVENT_MASK);
    assertEquals(ServiceStatus.SUCCESS, status);
    Contact addedContact = new Contact();
    status = mDatabaseHelper.addContact(addedContact);
    assertEquals(ServiceStatus.SUCCESS, status);
    ContactDetail detail = new ContactDetail();
    mTestModule.createDummyDetailsData(detail);
    detail.localContactID = addedContact.localContactID;
    status = mDatabaseHelper.addContactDetail(detail);
    assertEquals(ServiceStatus.SUCCESS, status);
    ContactDetail fetchedDetail = new ContactDetail();
    status = mDatabaseHelper.fetchContactDetail(detail.localDetailID, fetchedDetail);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertTrue(DatabaseHelper.doDetailsMatch(detail, fetchedDetail));
    assertTrue(!DatabaseHelper.hasDetailChanged(detail, fetchedDetail));
    assertEquals(ServiceStatus.SUCCESS, mDatabaseHelper.deleteAllGroups());
    List<ServerIdInfo> serverIdList = new ArrayList<ServerIdInfo>();
    ServerIdInfo info = new ServerIdInfo();
    info.localId = fetchedDetail.localDetailID;
    info.serverId = fetchedDetail.localDetailID + 1;
    serverIdList.add(info);
    status = ContactDetailsTable.syncSetServerIds(serverIdList, mDatabaseHelper.getWritableDatabase());
    assertEquals(ServiceStatus.SUCCESS, status);
    status = mDatabaseHelper.fetchContactDetail(detail.localDetailID, fetchedDetail);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(info.serverId, fetchedDetail.unique_id);
    shutdown();
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) ServerIdInfo(com.vodafone360.people.database.DatabaseHelper.ServerIdInfo) Contact(com.vodafone360.people.datatypes.Contact) SmallTest(android.test.suitebuilder.annotation.SmallTest) Suppress(android.test.suitebuilder.annotation.Suppress)

Aggregations

Suppress (android.test.suitebuilder.annotation.Suppress)191 MediumTest (android.test.suitebuilder.annotation.MediumTest)69 ServiceStatus (com.vodafone360.people.service.ServiceStatus)39 Cursor (android.database.Cursor)29 Contact (com.vodafone360.people.datatypes.Contact)28 ArrayList (java.util.ArrayList)26 SmallTest (android.test.suitebuilder.annotation.SmallTest)17 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)16 Intent (android.content.Intent)15 LargeTest (android.test.suitebuilder.annotation.LargeTest)14 ContentValues (android.content.ContentValues)13 NetworkStats (android.net.NetworkStats)13 Uri (android.net.Uri)12 Time (android.text.format.Time)12 Random (java.util.Random)12 DatabaseHelper (com.vodafone360.people.database.DatabaseHelper)11 IEngineEventCallback (com.vodafone360.people.engine.IEngineEventCallback)11 IContactSyncCallback (com.vodafone360.people.engine.contactsync.IContactSyncCallback)11 ProcessorFactory (com.vodafone360.people.engine.contactsync.ProcessorFactory)11 DownloadManager (android.app.DownloadManager)10