Search in sources :

Example 86 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project 360-Engine-for-Android by 360.

the class HeartbeatSenderThreadTest method testStopConnection.

@Suppress
@MediumTest
public void testStopConnection() {
    DataOutputStream dos = new DataOutputStream(new ByteArrayOutputStream());
    MockTcpConnectionThread connThread = new MockTcpConnectionThread(new DecoderThread(), null);
    MockHeartbeatSenderThread hbSender = new MockHeartbeatSenderThread(connThread, null, // QUICKFIX: Not sure about this value
    null);
    hbSender.setOutputStream(dos);
    hbSender.startConnection();
    try {
        Thread.sleep(500);
    } catch (Exception e) {
    }
    hbSender.stopConnection();
    try {
        Thread.sleep(1000);
    } catch (Exception e) {
    }
    assertNotNull(hbSender.getConnectionThread());
    if (null != hbSender.getConnectionThread()) {
        assertFalse(hbSender.getConnectionThread().isAlive());
        try {
            dos.write(1);
            fail("Should not be able to write here!");
        } catch (IOException e) {
            assertTrue(true);
        }
    }
}
Also used : DecoderThread(com.vodafone360.people.service.transport.DecoderThread) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) IOException(java.io.IOException) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 87 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project 360-Engine-for-Android by 360.

the class ResponseReaderThreadTest method testStartConnection.

@Suppress
@MediumTest
public void testStartConnection() {
    DecoderThread decoder = new DecoderThread();
    MockTcpConnectionThread mockThread = new MockTcpConnectionThread(decoder, null);
    MockResponseReaderThread respReader = new MockResponseReaderThread(mockThread, decoder, // QUICKFIX: Not sure about this value
    null);
    MockOTAInputStream mIs = new MockOTAInputStream(new ByteArrayInputStream(new byte[] { 1, 2, 3, 4, 5 }));
    respReader.setInputStream(new BufferedInputStream(mIs));
    assertNull(respReader.getConnectionThread());
    respReader.startConnection();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
    assertNotNull(respReader.getConnectionThread());
    if (null != respReader.getConnectionThread()) {
        assertTrue(respReader.getConnectionThread().isAlive());
    }
    assertTrue(respReader.getIsConnectionRunning());
}
Also used : DecoderThread(com.vodafone360.people.service.transport.DecoderThread) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedInputStream(java.io.BufferedInputStream) MockTcpConnectionThread(com.vodafone360.people.tests.service.transport.tcp.conn_less.hb_tests.MockTcpConnectionThread) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 88 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project 360-Engine-for-Android by 360.

the class ContactSyncEngineTest method testAutoSyncTimer.

/**
 * Checks that nothing is scheduled before the first time sync has been
 * completed.
 */
@Suppress
public void testAutoSyncTimer() {
    Log.i(LOG_TAG, "**** testAutoSyncTimer() begin ****");
    final IEngineEventCallback engineEventCallback = new HelperClasses.EngineCallbackBase() {

        @Override
        public void onUiEvent(ServiceUiRequest event, int request, int status, Object data) {
            Log.i(LOG_TAG, "onUiEvent: " + event + ", " + request + ", " + status + ", " + data);
        }
    };
    final ProcessorFactory factory = new ProcessorFactory() {

        @Override
        public BaseSyncProcessor create(int type, IContactSyncCallback callback, DatabaseHelper dbHelper) {
            Log.i(LOG_TAG, "create(), type=" + type);
            return new DummySyncProcessor(mContactSyncEngine, null);
        }
    };
    minimalEngineSetup(engineEventCallback, factory);
    // set the connection to be fine
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    // should be equal to -1 because first time sync has not been yet
    // started
    assertEquals(-1, mContactSyncEngine.getNextRunTime());
    mContactSyncEngine.run();
    assertEquals(-1, mContactSyncEngine.getNextRunTime());
    mContactSyncEngine.run();
    assertEquals(-1, mContactSyncEngine.getNextRunTime());
    Log.i(LOG_TAG, "**** testAutoSyncTimer() end ****");
}
Also used : DatabaseHelper(com.vodafone360.people.database.DatabaseHelper) ServiceUiRequest(com.vodafone360.people.service.ServiceUiRequest) ProcessorFactory(com.vodafone360.people.engine.contactsync.ProcessorFactory) IContactSyncCallback(com.vodafone360.people.engine.contactsync.IContactSyncCallback) IEngineEventCallback(com.vodafone360.people.engine.IEngineEventCallback) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 89 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project 360-Engine-for-Android by 360.

the class ContactSyncEngineTest method testFirstTimeSync_dummyReplies.

/**
 * Verifies that the first time sync can perform correctly with dummy
 * replies doing no modifications.
 */
@Suppress
public // Breaks tests.
void testFirstTimeSync_dummyReplies() {
    Log.i(LOG_TAG, "**** testFirstTimeSync_dummyReplies ****");
    final FirstTimeSyncFrameworkHandler handler = new FirstTimeSyncFrameworkHandler();
    setUpContactSyncEngineTestFramework(handler, null);
    handler.setContactSyncEngine(mContactSyncEngine);
    NetworkAgent.setAgentState(AgentState.CONNECTED);
    mContactSyncEngine.addUiStartFullSync();
    ServiceStatus status = mEngineTester.waitForEvent();
    Log.d(LOG_TAG, "AFTER waitForEvent()");
    assertEquals(ServiceStatus.SUCCESS, status);
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 90 with Suppress

use of android.test.suitebuilder.annotation.Suppress in project 360-Engine-for-Android by 360.

the class ContactSyncEngineTest method testUiRequestCompleteEvent_serverSync.

/**
 * Verifies that server sync completes correctly.
 */
@Suppress
public // Breaks tests.
void testUiRequestCompleteEvent_serverSync() {
    Log.i(LOG_TAG, "**** testUiRequestCompleteEvent_serverSync() begin ****");
    final UiEventCall uiEventCall = new UiEventCall();
    final IEngineEventCallback engineEventCallback = new HelperClasses.EngineCallbackBase() {

        @Override
        public void onUiEvent(ServiceUiRequest event, int request, int status, Object data) {
            Log.i(LOG_TAG, "onUiEvent: " + event + ", " + request + ", " + status + ", " + data);
            uiEventCall.event = event.ordinal();
            uiEventCall.request = request;
            uiEventCall.status = status;
            uiEventCall.data = data;
        }
    };
    final ProcessorFactory factory = new ProcessorFactory() {

        @Override
        public BaseSyncProcessor create(int type, IContactSyncCallback callback, DatabaseHelper dbHelper) {
            Log.i(LOG_TAG, "create(), type=" + type);
            return new DummySyncProcessor(mContactSyncEngine, null);
        }
    };
    minimalEngineSetup(engineEventCallback, factory);
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    long nextRuntime = mContactSyncEngine.getNextRunTime();
    // should be equal to -1 because first time sync has not been yet
    // started
    assertEquals(-1, nextRuntime);
    // set the connection to be fine
    NetworkAgent.setAgentState(AgentState.CONNECTED);
    // ask for a full sync
    mContactSyncEngine.addUiStartFullSync();
    nextRuntime = mContactSyncEngine.getNextRunTime();
    assertEquals(0, nextRuntime);
    mContactSyncEngine.run();
    // check that first time sync is completed
    assertEquals(ServiceUiRequest.UI_REQUEST_COMPLETE.ordinal(), uiEventCall.event);
    assertEquals(uiEventCall.status, ServiceStatus.SUCCESS.ordinal());
    // check that first time sync is completed
    assertEquals(ServiceUiRequest.UI_REQUEST_COMPLETE.ordinal(), uiEventCall.event);
    assertEquals(uiEventCall.status, ServiceStatus.SUCCESS.ordinal());
    Log.i(LOG_TAG, "**** testUiRequestCompleteEvent_serverSync() end ****");
}
Also used : DatabaseHelper(com.vodafone360.people.database.DatabaseHelper) ServiceUiRequest(com.vodafone360.people.service.ServiceUiRequest) ProcessorFactory(com.vodafone360.people.engine.contactsync.ProcessorFactory) IContactSyncCallback(com.vodafone360.people.engine.contactsync.IContactSyncCallback) IEngineEventCallback(com.vodafone360.people.engine.IEngineEventCallback) Suppress(android.test.suitebuilder.annotation.Suppress)

Aggregations

Suppress (android.test.suitebuilder.annotation.Suppress)191 MediumTest (android.test.suitebuilder.annotation.MediumTest)69 ServiceStatus (com.vodafone360.people.service.ServiceStatus)39 Cursor (android.database.Cursor)29 Contact (com.vodafone360.people.datatypes.Contact)28 ArrayList (java.util.ArrayList)26 SmallTest (android.test.suitebuilder.annotation.SmallTest)17 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)16 Intent (android.content.Intent)15 LargeTest (android.test.suitebuilder.annotation.LargeTest)14 ContentValues (android.content.ContentValues)13 NetworkStats (android.net.NetworkStats)13 Uri (android.net.Uri)12 Time (android.text.format.Time)12 Random (java.util.Random)12 DatabaseHelper (com.vodafone360.people.database.DatabaseHelper)11 IEngineEventCallback (com.vodafone360.people.engine.IEngineEventCallback)11 IContactSyncCallback (com.vodafone360.people.engine.contactsync.IContactSyncCallback)11 ProcessorFactory (com.vodafone360.people.engine.contactsync.ProcessorFactory)11 DownloadManager (android.app.DownloadManager)10