Search in sources :

Example 1 with TestStatus

use of com.vodafone360.people.tests.testutils.TestStatus 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 2 with TestStatus

use of com.vodafone360.people.tests.testutils.TestStatus 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

TestStatus (com.vodafone360.people.tests.testutils.TestStatus)2 NetworkErrorException (android.accounts.NetworkErrorException)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 MediumTest (android.test.suitebuilder.annotation.MediumTest)1 SmallTest (android.test.suitebuilder.annotation.SmallTest)1 Suppress (android.test.suitebuilder.annotation.Suppress)1 MainApplication (com.vodafone360.people.MainApplication)1 Authenticator (com.vodafone360.people.service.Authenticator)1 RemoteService (com.vodafone360.people.service.RemoteService)1 IWakeupListener (com.vodafone360.people.service.transport.IWakeupListener)1