Search in sources :

Example 6 with MediumTest

use of android.test.suitebuilder.annotation.MediumTest in project android_frameworks_base by ParanoidAndroid.

the class EventsTest method testPlayingDelayedEnd.

/**
     * Same as testPlayingEnd, but with a startDelayed animator
     */
@MediumTest
public void testPlayingDelayedEnd() throws Exception {
    mAnimator.setStartDelay(ANIM_DELAY);
    mFutureListener = new FutureReleaseListener(mFuture);
    getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            try {
                Handler handler = new Handler();
                mAnimator.addListener(mFutureListener);
                mRunning = true;
                mAnimator.start();
                handler.postDelayed(new Ender(mAnimator, mFuture), ANIM_MID_DURATION);
            } catch (junit.framework.AssertionFailedError e) {
                mFuture.setException(new RuntimeException(e));
            }
        }
    });
    mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
Also used : Handler(android.os.Handler) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 7 with MediumTest

use of android.test.suitebuilder.annotation.MediumTest in project android_frameworks_base by ParanoidAndroid.

the class EventsTest method testPlayingDelayedEndMidDelay.

/**
     * Same as testPlayingDelayedEnd, but end during the startDelay period
     */
@MediumTest
public void testPlayingDelayedEndMidDelay() throws Exception {
    mAnimator.setStartDelay(ANIM_DELAY);
    getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            try {
                // Set the listener to automatically timeout after an uncanceled animation
                // would have finished. This tests to make sure that we're not calling
                // the listeners with cancel/end callbacks since they won't be called
                // with the start event.
                mFutureListener = new FutureReleaseListener(mFuture, getTimeout());
                Handler handler = new Handler();
                mRunning = true;
                mAnimator.start();
                handler.postDelayed(new Ender(mAnimator, mFuture), ANIM_MID_DELAY);
            } catch (junit.framework.AssertionFailedError e) {
                mFuture.setException(new RuntimeException(e));
            }
        }
    });
    mFuture.get(getTimeout() + 100, TimeUnit.MILLISECONDS);
}
Also used : Handler(android.os.Handler) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 8 with MediumTest

use of android.test.suitebuilder.annotation.MediumTest in project android_frameworks_base by ParanoidAndroid.

the class ViewPropertyAnimatorTest method testPlayingDelayedCancelMidDelay.

/**
     * Same as testPlayingDelayedCancel, but cancel during the startDelay period
     */
@MediumTest
public void testPlayingDelayedCancelMidDelay() throws Exception {
    mAnimator.setStartDelay(ANIM_DELAY);
    getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            try {
                // Set the listener to automatically timeout after an uncanceled animation
                // would have finished. This tests to make sure that we're not calling
                // the listeners with cancel/end callbacks since they won't be called
                // with the start event.
                mFutureListener = new FutureReleaseListener(mFuture, getTimeout());
                Handler handler = new Handler();
                mRunning = true;
                mAnimator.start();
                handler.postDelayed(new Canceler(mAnimator, mFuture), ANIM_MID_DELAY);
            } catch (junit.framework.AssertionFailedError e) {
                mFuture.setException(new RuntimeException(e));
            }
        }
    });
    mFuture.get(getTimeout() + 100, TimeUnit.MILLISECONDS);
}
Also used : Handler(android.os.Handler) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 9 with MediumTest

use of android.test.suitebuilder.annotation.MediumTest in project android_frameworks_base by ParanoidAndroid.

the class DatabaseCursorTest method testCursor1.

@MediumTest
public void testCursor1() throws Exception {
    populateDefaultTable();
    Cursor c = mDatabase.query("test", null, null, null, null, null, null);
    int dataColumn = c.getColumnIndexOrThrow("data");
    // The cursor should ignore text before the last period when looking for a column. (This
    // is a temporary hack in all implementations of getColumnIndex.)
    int dataColumn2 = c.getColumnIndexOrThrow("junk.data");
    assertEquals(dataColumn, dataColumn2);
    assertSame(3, c.getCount());
    assertTrue(c.isBeforeFirst());
    try {
        c.getInt(0);
        fail("CursorIndexOutOfBoundsException expected");
    } catch (CursorIndexOutOfBoundsException ex) {
    // expected
    }
    c.moveToNext();
    assertEquals(1, c.getInt(0));
    String s = c.getString(dataColumn);
    assertEquals(sString1, s);
    c.moveToNext();
    s = c.getString(dataColumn);
    assertEquals(sString2, s);
    c.moveToNext();
    s = c.getString(dataColumn);
    assertEquals(sString3, s);
    c.moveToPosition(-1);
    c.moveToNext();
    s = c.getString(dataColumn);
    assertEquals(sString1, s);
    c.moveToPosition(2);
    s = c.getString(dataColumn);
    assertEquals(sString3, s);
    int i;
    for (c.moveToFirst(), i = 0; !c.isAfterLast(); c.moveToNext(), i++) {
        c.getInt(0);
    }
    assertEquals(3, i);
    try {
        c.getInt(0);
        fail("CursorIndexOutOfBoundsException expected");
    } catch (CursorIndexOutOfBoundsException ex) {
    // expected
    }
    c.close();
}
Also used : CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException) SQLiteCursor(android.database.sqlite.SQLiteCursor) Cursor(android.database.Cursor) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 10 with MediumTest

use of android.test.suitebuilder.annotation.MediumTest in project android_frameworks_base by ParanoidAndroid.

the class DatabaseCursorTest method testBlob.

@MediumTest
public void testBlob() throws Exception {
    // create table
    mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, s TEXT, d REAL, l INTEGER, b BLOB);");
    // insert blob
    Object[] args = new Object[4];
    byte[] blob = new byte[1000];
    byte value = 99;
    Arrays.fill(blob, value);
    args[3] = blob;
    String s = new String("text");
    args[0] = s;
    Double d = 99.9;
    args[1] = d;
    Long l = (long) 1000;
    args[2] = l;
    String sql = "INSERT INTO test (s, d, l, b) VALUES (?,?,?,?)";
    mDatabase.execSQL(sql, args);
    // use cursor to access blob
    Cursor c = mDatabase.query("test", null, null, null, null, null, null);
    c.moveToNext();
    ContentValues cv = new ContentValues();
    DatabaseUtils.cursorRowToContentValues(c, cv);
    int bCol = c.getColumnIndexOrThrow("b");
    int sCol = c.getColumnIndexOrThrow("s");
    int dCol = c.getColumnIndexOrThrow("d");
    int lCol = c.getColumnIndexOrThrow("l");
    byte[] cBlob = c.getBlob(bCol);
    assertTrue(Arrays.equals(blob, cBlob));
    assertEquals(s, c.getString(sCol));
    assertEquals((double) d, c.getDouble(dCol));
    assertEquals((long) l, c.getLong(lCol));
}
Also used : ContentValues(android.content.ContentValues) SQLiteCursor(android.database.sqlite.SQLiteCursor) Cursor(android.database.Cursor) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

MediumTest (android.test.suitebuilder.annotation.MediumTest)1023 View (android.view.View)246 ListView (android.widget.ListView)151 Cursor (android.database.Cursor)116 Handler (android.os.Handler)116 Suppress (android.test.suitebuilder.annotation.Suppress)73 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 Message (android.os.Message)43 LogRec (com.android.internal.util.StateMachine.LogRec)42 Intent (android.content.Intent)40 ContentResolver (android.content.ContentResolver)37 GridView (android.widget.GridView)36 InputStream (java.io.InputStream)36 ByteArrayInputStream (java.io.ByteArrayInputStream)35