Search in sources :

Example 61 with MediumTest

use of android.test.suitebuilder.annotation.MediumTest in project platform_frameworks_base by android.

the class FileObserverTest method testRun.

@MediumTest
public void testRun() throws Exception {
    // make file changes and wait for them
    assertTrue(mTestFile.exists());
    assertNotNull(mTestFile.getParent());
    mObserver = new Observer(mTestFile.getParent());
    mObserver.startWatching();
    FileOutputStream out = new FileOutputStream(mTestFile);
    try {
        out.write(0x20);
        // open
        waitForEvent();
        // modify
        waitForEvent();
        mTestFile.delete();
        // modify
        waitForEvent();
        // delete
        waitForEvent();
        mObserver.stopWatching();
        // Ensure that we have seen at least 3 events.
        assertTrue(mObserver.totalEvents > 3);
    } finally {
        out.close();
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 62 with MediumTest

use of android.test.suitebuilder.annotation.MediumTest in project platform_frameworks_base by android.

the class HandlerThreadTest method testHandlerThread.

@MediumTest
public void testHandlerThread() throws Exception {
    HandlerThread th1 = new HandlerThread("HandlerThreadTest") {

        protected void onLooperPrepared() {
            synchronized (HandlerThreadTest.this) {
                mDidSetup = true;
                mLooperTid = Process.myTid();
                HandlerThreadTest.this.notify();
            }
        }
    };
    assertFalse(th1.isAlive());
    assertNull(th1.getLooper());
    th1.start();
    assertTrue(th1.isAlive());
    assertNotNull(th1.getLooper());
    // and fill in the values we expect.
    synchronized (this) {
        while (!mDidSetup) {
            try {
                wait();
            } catch (InterruptedException e) {
            }
        }
    }
    // Make sure that the process was set.
    assertNotSame(-1, mLooperTid);
    // Make sure that the onLooperPrepared() was called on a different thread.
    assertNotSame(Process.myTid(), mLooperTid);
    final Handler h1 = new Handler(th1.getLooper()) {

        public void handleMessage(Message msg) {
            assertEquals(TEST_WHAT, msg.what);
            // Ensure that we are running on the same thread in which the looper was setup on.
            assertEquals(mLooperTid, Process.myTid());
            mGotMessageWhat = msg.what;
            mGotMessage = true;
            synchronized (this) {
                notifyAll();
            }
        }
    };
    Message msg = h1.obtainMessage(TEST_WHAT);
    synchronized (h1) {
        // wait until we have the lock before sending the message.
        h1.sendMessage(msg);
        try {
            // wait for the message to be handled
            h1.wait();
        } catch (InterruptedException e) {
        }
    }
    assertTrue(mGotMessage);
    assertEquals(TEST_WHAT, mGotMessageWhat);
}
Also used : HandlerThread(android.os.HandlerThread) Message(android.os.Message) Handler(android.os.Handler) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 63 with MediumTest

use of android.test.suitebuilder.annotation.MediumTest in project platform_frameworks_base by android.

the class StateMachineTest method testHsm1.

@MediumTest
public void testHsm1() throws Exception {
    if (DBG)
        tlog("testHsm1 E");
    Hsm1 sm = Hsm1.makeHsm1();
    // Send messages
    sm.sendMessage(Hsm1.CMD_1);
    sm.sendMessage(Hsm1.CMD_2);
    synchronized (sm) {
        // Wait for the last state machine to notify its done
        try {
            sm.wait();
        } catch (InterruptedException e) {
            tloge("testHsm1: exception while waiting " + e.getMessage());
        }
    }
    dumpLogRecs(sm);
    assertEquals(7, sm.getLogRecCount());
    LogRec lr = sm.getLogRec(0);
    assertEquals(Hsm1.CMD_1, lr.getWhat());
    assertEquals(sm.mS1, lr.getState());
    assertEquals(sm.mS1, lr.getOriginalState());
    lr = sm.getLogRec(1);
    assertEquals(Hsm1.CMD_2, lr.getWhat());
    assertEquals(sm.mP1, lr.getState());
    assertEquals(sm.mS1, lr.getOriginalState());
    lr = sm.getLogRec(2);
    assertEquals(Hsm1.CMD_2, lr.getWhat());
    assertEquals(sm.mS2, lr.getState());
    assertEquals(sm.mS2, lr.getOriginalState());
    lr = sm.getLogRec(3);
    assertEquals(Hsm1.CMD_3, lr.getWhat());
    assertEquals(sm.mS2, lr.getState());
    assertEquals(sm.mS2, lr.getOriginalState());
    lr = sm.getLogRec(4);
    assertEquals(Hsm1.CMD_3, lr.getWhat());
    assertEquals(sm.mP2, lr.getState());
    assertEquals(sm.mP2, lr.getOriginalState());
    lr = sm.getLogRec(5);
    assertEquals(Hsm1.CMD_4, lr.getWhat());
    assertEquals(sm.mP2, lr.getState());
    assertEquals(sm.mP2, lr.getOriginalState());
    lr = sm.getLogRec(6);
    assertEquals(Hsm1.CMD_5, lr.getWhat());
    assertEquals(sm.mP2, lr.getState());
    assertEquals(sm.mP2, lr.getOriginalState());
    if (DBG)
        tlog("testStateMachineSharedThread X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 64 with MediumTest

use of android.test.suitebuilder.annotation.MediumTest in project platform_frameworks_base by android.

the class StateMachineTest method testStateMachine4.

@MediumTest
public void testStateMachine4() throws Exception {
    StateMachine4 sm4 = new StateMachine4("sm4");
    sm4.start();
    if (sm4.isDbg())
        tlog("testStateMachine4 E");
    synchronized (sm4) {
        // Send two messages
        sm4.sendMessage(TEST_CMD_1);
        sm4.sendMessage(TEST_CMD_2);
        try {
            // wait for the messages to be handled
            sm4.wait();
        } catch (InterruptedException e) {
            tloge("testStateMachine4: exception while waiting " + e.getMessage());
        }
    }
    assertEquals(2, sm4.getLogRecSize());
    LogRec lr;
    lr = sm4.getLogRec(0);
    assertEquals(TEST_CMD_1, lr.getWhat());
    assertEquals(sm4.mChildState1, lr.getState());
    assertEquals(sm4.mChildState1, lr.getOriginalState());
    lr = sm4.getLogRec(1);
    assertEquals(TEST_CMD_2, lr.getWhat());
    assertEquals(sm4.mParentState, lr.getState());
    assertEquals(sm4.mChildState2, lr.getOriginalState());
    if (sm4.isDbg())
        tlog("testStateMachine4 X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 65 with MediumTest

use of android.test.suitebuilder.annotation.MediumTest in project platform_frameworks_base by android.

the class AccessibilityManagerTest method testSendAccessibilityEvent_AccessibilityDisabled.

@MediumTest
public void testSendAccessibilityEvent_AccessibilityDisabled() throws Exception {
    AccessibilityEvent sentEvent = AccessibilityEvent.obtain();
    AccessibilityManager manager = createManager(false);
    try {
        manager.sendAccessibilityEvent(sentEvent);
        fail("No accessibility events are sent if accessibility is disabled");
    } catch (IllegalStateException ise) {
        // check expected result
        assertEquals("Accessibility off. Did you forget to check that?", ise.getMessage());
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

MediumTest (android.test.suitebuilder.annotation.MediumTest)996 View (android.view.View)246 ListView (android.widget.ListView)150 Cursor (android.database.Cursor)116 Handler (android.os.Handler)116 Suppress (android.test.suitebuilder.annotation.Suppress)69 TextView (android.widget.TextView)67 ContentValues (android.content.ContentValues)63 ServiceStatus (com.vodafone360.people.service.ServiceStatus)60 SQLiteCursor (android.database.sqlite.SQLiteCursor)54 SQLiteStatement (android.database.sqlite.SQLiteStatement)49 IOException (java.io.IOException)49 UiThreadTest (android.test.UiThreadTest)48 LogRec (com.android.internal.util.StateMachine.LogRec)42 ContentResolver (android.content.ContentResolver)37 Intent (android.content.Intent)36 Message (android.os.Message)36 GridView (android.widget.GridView)36 InputStream (java.io.InputStream)36 ByteArrayInputStream (java.io.ByteArrayInputStream)35