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();
}
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());
}
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());
}
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);
}
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());
}
Aggregations