Search in sources :

Example 1 with IWakeupListener

use of com.vodafone360.people.service.transport.IWakeupListener 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)

Aggregations

Intent (android.content.Intent)1 MediumTest (android.test.suitebuilder.annotation.MediumTest)1 RemoteService (com.vodafone360.people.service.RemoteService)1 IWakeupListener (com.vodafone360.people.service.transport.IWakeupListener)1 TestStatus (com.vodafone360.people.tests.testutils.TestStatus)1