Search in sources :

Example 1 with RemoteService

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

the class RemoteService method onCreate.

/**
 * Creation of RemoteService. Loads properties (i.e. supported features,
 * server URLs etc) from SettingsManager. Creates IPeopleServiceImpl,
 * NetworkAgent. Connects ConnectionManager creating Connection thread(s)
 * and DecoderThread 'Kicks' worker thread.
 */
@Override
public void onCreate() {
    LogUtils.logV("RemoteService.onCreate()");
    SettingsManager.loadProperties(this);
    mIPeopleServiceImpl = new PeopleServiceImpl(this, this);
    mNetworkAgent = new NetworkAgent(this, this, this);
    // Create NativeContactsApi here to access Application Context
    NativeContactsApi.createInstance(getApplicationContext());
    EngineManager.createEngineManager(this, mIPeopleServiceImpl);
    mNetworkAgent.onCreate();
    mIPeopleServiceImpl.setNetworkAgent(mNetworkAgent);
    /**
     * The service has now been fully initialised. *
     */
    mIsStarted = true;
    kickWorkerThread();
    final MainApplication mainApp = (MainApplication) getApplication();
    mainApp.setServiceInterface(mIPeopleServiceImpl);
    if (VersionUtils.is2XPlatform()) {
        mAccountsObjectsHolder = new NativeAccountObjectsHolder(((MainApplication) getApplication()));
    }
    final UserDataProtection userDataProtection = new UserDataProtection(this, mainApp.getDatabase());
    userDataProtection.performStartupChecks();
}
Also used : NetworkAgent(com.vodafone360.people.service.agent.NetworkAgent) UserDataProtection(com.vodafone360.people.service.utils.UserDataProtection) MainApplication(com.vodafone360.people.MainApplication)

Example 2 with RemoteService

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

the class RemoteServiceTest method testStartAlarmHbThread.

/**
 * Test starting the service with the ALARM_HB_THREAD Intent.
 *
 * @throws Exception Issue setting up the service.
 */
@MediumTest
public final void testStartAlarmHbThread() throws Exception {
    /**
     * Setup test preconditions (i.e. WorkerThread not running). *
     */
    final TestStatus testStatus = new TestStatus();
    setupService();
    RemoteService remoteService = getService();
    remoteService.registerCpuWakeupListener(new IWakeupListener() {

        @Override
        public void notifyOfWakeupAlarm() {
            /*
                 * Test that the dummy mWakeListener.notifyOfWakeupAlarm() has
                 * been called, otherwise the test must fail.
                 */
            testStatus.setPass(true);
        }
    });
    /**
     * Perform test (i.e. trigger ALARM_HB_THREAD). *
     */
    Intent alarmWorkerThreadIntent = new Intent(getContext(), RemoteService.class);
    alarmWorkerThreadIntent.putExtra(RemoteService.ALARM_KEY, IWakeupListener.ALARM_HB_THREAD);
    startService(alarmWorkerThreadIntent);
    /**
     * Test if notifyOfWakeupAlarm() was called. *
     */
    assertTrue("Expecting the notifyOfWakeupAlarm() dummy method to have " + "been called", testStatus.isPass());
}
Also used : TestStatus(com.vodafone360.people.tests.testutils.TestStatus) RemoteService(com.vodafone360.people.service.RemoteService) IWakeupListener(com.vodafone360.people.service.transport.IWakeupListener) Intent(android.content.Intent) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 3 with RemoteService

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

the class RemoteServiceTest method testStartable.

/*
     * ##########  END FRAMEWORK CLASSES.  ##########
     */
/**
 * Test basic startup/shutdown of Service.
 */
@MediumTest
public final void testStartable() {
    startService(new Intent(getContext(), RemoteService.class));
    assertNotNull("RemoteService should not be NULL", getService());
}
Also used : RemoteService(com.vodafone360.people.service.RemoteService) Intent(android.content.Intent) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 4 with RemoteService

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

the class RemoteServiceTest method testGetServiceInterface.

/**
 * Test getServiceInterface() from RemoteService.
 *
 * @throws Exception Issue setting up the service.
 */
@MediumTest
public final void testGetServiceInterface() throws Exception {
    /**
     * Setup test preconditions (i.e. startService). *
     */
    startService(new Intent(getContext(), RemoteService.class));
    /**
     * Perform test (i.e. getServiceInterface). *
     */
    IPeopleService mPeopleService = mApplication.getServiceInterface();
    /**
     * Test if mPeopleService is correctly initialised. *
     */
    assertNotNull("IPeopleService should not be NULL", mPeopleService);
    IWorkerThreadControl workerThreadControl = (IWorkerThreadControl) FrameworkUtils.get(mPeopleService, "mWorkerThreadControl");
    assertNotNull("Expecting mWorkerThreadControl not to be NULL", workerThreadControl);
    RemoteService service = (RemoteService) FrameworkUtils.get(mPeopleService, "mService");
    assertNotNull("Expecting mService not to be NULL", service);
    UiAgent handlerAgent = (UiAgent) FrameworkUtils.get(mPeopleService, "mHandlerAgent");
    assertNotNull("Expecting mHandlerAgent not to be NULL", handlerAgent);
    ApplicationCache applicationCache = (ApplicationCache) FrameworkUtils.get(mPeopleService, "mApplicationCache");
    assertNotNull("Expecting mApplicationCache not to be NULL", applicationCache);
}
Also used : IWorkerThreadControl(com.vodafone360.people.service.interfaces.IWorkerThreadControl) UiAgent(com.vodafone360.people.service.agent.UiAgent) RemoteService(com.vodafone360.people.service.RemoteService) Intent(android.content.Intent) IPeopleService(com.vodafone360.people.service.interfaces.IPeopleService) ApplicationCache(com.vodafone360.people.ApplicationCache) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 5 with RemoteService

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

the class RemoteServiceTest method testStartAlarmWorkerThread.

/**
 * Test starting the service with the ALARM_WORKER_THREAD Intent.
 *
 * @throws Exception Issue setting up framework.
 */
@MediumTest
public final void testStartAlarmWorkerThread() throws Exception {
    /**
     * Setup test preconditions (i.e. WorkerThread not running). *
     */
    startService(new Intent(getContext(), RemoteService.class));
    RemoteService remoteService = getService();
    assertNotNull("RemoteService should not be NULL", remoteService);
    FrameworkUtils.set(remoteService, "mIsStarted", true);
    FrameworkUtils.set(remoteService, "mWorkerThread", null);
    /**
     * Perform test (i.e. trigger ALARM_WORKER_THREAD). *
     */
    Intent alarmWorkerThreadIntent = new Intent(getContext(), RemoteService.class);
    alarmWorkerThreadIntent.putExtra(RemoteService.ALARM_KEY, WorkerThread.ALARM_WORKER_THREAD);
    remoteService.onStart(alarmWorkerThreadIntent, -1);
    /**
     * Test if the kickWorkerThread() was called. *
     */
    WorkerThread workerThread = (WorkerThread) FrameworkUtils.get(remoteService, "mWorkerThread");
    assertNotNull("Expecting workerThread not to be NULL", workerThread);
    assertTrue("Expecting workerThread to be alive", workerThread.isAlive());
}
Also used : WorkerThread(com.vodafone360.people.service.WorkerThread) RemoteService(com.vodafone360.people.service.RemoteService) Intent(android.content.Intent) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

Intent (android.content.Intent)8 MediumTest (android.test.suitebuilder.annotation.MediumTest)8 RemoteService (com.vodafone360.people.service.RemoteService)8 MainApplication (com.vodafone360.people.MainApplication)2 WorkerThread (com.vodafone360.people.service.WorkerThread)2 NetworkAgent (com.vodafone360.people.service.agent.NetworkAgent)2 ApplicationCache (com.vodafone360.people.ApplicationCache)1 UiAgent (com.vodafone360.people.service.agent.UiAgent)1 IPeopleService (com.vodafone360.people.service.interfaces.IPeopleService)1 IWorkerThreadControl (com.vodafone360.people.service.interfaces.IWorkerThreadControl)1 IWakeupListener (com.vodafone360.people.service.transport.IWakeupListener)1 UserDataProtection (com.vodafone360.people.service.utils.UserDataProtection)1 TestStatus (com.vodafone360.people.tests.testutils.TestStatus)1