Search in sources :

Example 6 with MainApplication

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

the class AuthenticatorTest method testGetAccountRemovalAllowed.

/***
     * Test the getAccountRemovalAllowed() method.
     */
@SmallTest
@Suppress
public final void testGetAccountRemovalAllowed() {
    final TestStatus testStatus = new TestStatus();
    Authenticator authenticator = new Authenticator(getContext(), new MainApplication() {

        public void removeUserData() {
            /*
                 * Test that the dummy mWakeListener.notifyOfWakeupAlarm() has
                 * been called, otherwise the test must fail.
                 */
            testStatus.setPass(true);
        }
    });
    Bundle bundle = null;
    try {
        bundle = authenticator.getAccountRemovalAllowed(null, null);
    } catch (NetworkErrorException e) {
        fail("Unexpected NetworkErrorException");
    }
    /** Test if removeUserData() was called. **/
    assertTrue("Expecting the removeUserData() dummy method to have " + "been called", testStatus.isPass());
    assertEquals("Expected a KEY_BOOLEAN_RESULT boolean", true, bundle.getBoolean(AccountManager.KEY_BOOLEAN_RESULT));
}
Also used : NetworkErrorException(android.accounts.NetworkErrorException) TestStatus(com.vodafone360.people.tests.testutils.TestStatus) Bundle(android.os.Bundle) Authenticator(com.vodafone360.people.service.Authenticator) MainApplication(com.vodafone360.people.MainApplication) SmallTest(android.test.suitebuilder.annotation.SmallTest) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 7 with MainApplication

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

the class ChatDbUtilsTest method setUp.

/***
     * Set up the DatabaseHelper.
     */
public final void setUp() {
    createApplication();
    MainApplication mainApplication = getApplication();
    if (mainApplication == null) {
        throw (new RuntimeException("ChatDbUtilsTest.setUp() " + "Unable to create main application"));
    }
    mDatabaseHelper = mainApplication.getDatabase();
}
Also used : MainApplication(com.vodafone360.people.MainApplication)

Example 8 with MainApplication

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

the class TimeOutWatcherTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    mApplication = (MainApplication) Instrumentation.newApplication(MainApplication.class, getInstrumentation().getTargetContext());
    mApplication.onCreate();
    mWatcher = new TimeOutWatcher();
}
Also used : TimeOutWatcher(com.vodafone360.people.service.utils.TimeOutWatcher)

Example 9 with MainApplication

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

the class PeopleServiceTest method lazyLoadPeopleService.

private synchronized boolean lazyLoadPeopleService() {
    if (mPeopleService != null) {
        return true;
    }
    try {
        mApplication = (MainApplication) Instrumentation.newApplication(MainApplication.class, // Not good enough, must be Target Context??
        getSystemContext());
        Log.e(LOG_TAG, "Test 1 [" + testContext(getContext()) + "]");
        Log.e(LOG_TAG, "Test 2 [" + testContext(getSystemContext()) + "]");
        Log.e(LOG_TAG, "Test 3 [" + testContext(mApplication.getApplicationContext()) + "]");
        Log.e(LOG_TAG, "Test 4 [" + testContext(mApplication) + "]");
        Instrumentation i = new Instrumentation();
        i.getTargetContext();
        Log.e(LOG_TAG, "Test 5 [" + testContext(i.getTargetContext()) + "]");
        //Tests: maybe have to get getInstrumentation().getTargetContext() ??
        //Log.e(LOG_TAG, "Test 5 ["+testContext(getInstrumentation().getTargetContext())+"]");
        mApplication.onCreate();
        //Call before startService()
        setApplication(mApplication);
    } catch (ClassNotFoundException e) {
        Log.e(LOG_TAG, "ClassNotFoundException " + e.toString());
    } catch (IllegalAccessException e) {
        Log.e(LOG_TAG, "IllegalAccessException " + e.toString());
    } catch (InstantiationException e) {
        Log.e(LOG_TAG, "InstantiationException " + e.toString());
    }
    // Explicitly start the service.
    Intent serviceIntent = new Intent();
    serviceIntent.setClassName("com.vodafone360.people", "com.vodafone360.people.service.RemoteService");
    startService(serviceIntent);
    mPeopleService = mApplication.getServiceInterface();
    if (mPeopleService == null) {
        return false;
    }
    mEventWatcherThread = new Thread(new Runnable() {

        @Override
        public void run() {
            eventWatcherThreadMain();
        }
    });
    mEventWatcherThread.start();
    while (!mEventThreadStarted) {
        try {
            wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    // Add service handler.
    mPeopleService.addEventCallback(mHandler);
    // Restart thread.
    mTestConn.startThread();
    return true;
}
Also used : Instrumentation(android.app.Instrumentation) Intent(android.content.Intent) PeopleTestConnectionThread(com.vodafone360.people.tests.PeopleTestConnectionThread)

Example 10 with MainApplication

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

the class EngineManager method createSyncMeEngine.

/**
     * Create instance of SyncMeEngine.
     */
private synchronized void createSyncMeEngine() {
    final MainApplication app = (MainApplication) mService.getApplication();
    mSyncMeEngine = new SyncMeEngine(mService, mUiEventCallback, app.getDatabase());
    addEngine(mSyncMeEngine);
}
Also used : SyncMeEngine(com.vodafone360.people.engine.meprofile.SyncMeEngine) MainApplication(com.vodafone360.people.MainApplication)

Aggregations

MainApplication (com.vodafone360.people.MainApplication)12 EngineTestFramework (com.vodafone360.people.tests.engine.EngineTestFramework)4 Intent (android.content.Intent)2 ActivitiesEngine (com.vodafone360.people.engine.activities.ActivitiesEngine)2 IdentityEngine (com.vodafone360.people.engine.identities.IdentityEngine)2 LoginEngine (com.vodafone360.people.engine.login.LoginEngine)2 SyncMeEngine (com.vodafone360.people.engine.meprofile.SyncMeEngine)2 PresenceEngine (com.vodafone360.people.engine.presence.PresenceEngine)2 NetworkErrorException (android.accounts.NetworkErrorException)1 Instrumentation (android.app.Instrumentation)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 SmallTest (android.test.suitebuilder.annotation.SmallTest)1 Suppress (android.test.suitebuilder.annotation.Suppress)1 ContactSyncEngine (com.vodafone360.people.engine.contactsync.ContactSyncEngine)1 ContentEngine (com.vodafone360.people.engine.content.ContentEngine)1 GroupsEngine (com.vodafone360.people.engine.groups.GroupsEngine)1 Authenticator (com.vodafone360.people.service.Authenticator)1 RemoteService (com.vodafone360.people.service.RemoteService)1