use of com.vodafone360.people.engine.contactsync.NativeContactsApi2 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);
}
}
Aggregations