Search in sources :

Example 1 with NativeContactsApi1

use of com.vodafone360.people.engine.contactsync.NativeContactsApi1 in project 360-Engine-for-Android by 360.

the class NativeContactsApiTest method testInstance.

/**
	 * Tests API functionality to do the following:
	 * - Create Instance
	 * - Get Instance
	 * - Destroy Instance
	 */
@SmallTest
public void testInstance() {
    // Need to destroy instance first for this test!
    NativeContactsApi.destroyInstance();
    NativeContactsApi nabApi = null;
    boolean caughtException = false;
    try {
        nabApi = NativeContactsApi.getInstance();
    } catch (InvalidParameterException ex) {
        caughtException = true;
    }
    assertNull(nabApi);
    assertTrue(caughtException);
    NativeContactsApi.createInstance(getInstrumentation().getContext());
    try {
        nabApi = NativeContactsApi.getInstance();
        caughtException = false;
    } catch (InvalidParameterException ex) {
    }
    assertFalse(caughtException);
    assertNotNull(nabApi);
    NativeContactsApi.destroyInstance();
    // Double Destroy
    NativeContactsApi.destroyInstance();
    try {
        nabApi = NativeContactsApi.getInstance();
    } catch (InvalidParameterException ex) {
        caughtException = true;
    }
    assertTrue(caughtException);
    NativeContactsApi.createInstance(getInstrumentation().getContext());
    try {
        nabApi = NativeContactsApi.getInstance();
        caughtException = false;
    } catch (InvalidParameterException ex) {
    }
    assertFalse(caughtException);
    if (mUsing2xApi) {
        assertTrue(nabApi instanceof NativeContactsApi2);
    } else {
        assertTrue(nabApi instanceof NativeContactsApi1);
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) NativeContactsApi(com.vodafone360.people.engine.contactsync.NativeContactsApi) NativeContactsApi1(com.vodafone360.people.engine.contactsync.NativeContactsApi1) NativeContactsApi2(com.vodafone360.people.engine.contactsync.NativeContactsApi2) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

SmallTest (android.test.suitebuilder.annotation.SmallTest)1 NativeContactsApi (com.vodafone360.people.engine.contactsync.NativeContactsApi)1 NativeContactsApi1 (com.vodafone360.people.engine.contactsync.NativeContactsApi1)1 NativeContactsApi2 (com.vodafone360.people.engine.contactsync.NativeContactsApi2)1 InvalidParameterException (java.security.InvalidParameterException)1