Search in sources :

Example 11 with MediumTest

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

the class DatabaseGeneralTest method testSchemaChange1.

@MediumTest
public void testSchemaChange1() throws Exception {
    SQLiteDatabase db1 = mDatabase;
    Cursor cursor;
    db1.execSQL("CREATE TABLE db1 (_id INTEGER PRIMARY KEY, data TEXT);");
    cursor = db1.query("db1", null, null, null, null, null, null);
    assertNotNull("Cursor is null", cursor);
    db1.execSQL("CREATE TABLE db2 (_id INTEGER PRIMARY KEY, data TEXT);");
    assertEquals(0, cursor.getCount());
    cursor.deactivate();
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 12 with MediumTest

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

the class BroadcasterTest method test4.

@MediumTest
public void test4() throws Exception {
    /*
        * Two handlers request different messages, with translations, sending
        * only one.  The other one should never get sent.
        */
    HandlerTester tester = new HandlerTester() {

        Handler h1;

        Handler h2;

        public void go() {
            Broadcaster b = new Broadcaster();
            h1 = new H();
            h2 = new H();
            b.request(MESSAGE_A, h1, MESSAGE_C);
            b.request(MESSAGE_B, h2, MESSAGE_D);
            Message msg = new Message();
            msg.what = MESSAGE_A;
            b.broadcast(msg);
        }

        public void handleMessage(Message msg) {
            if (msg.what == MESSAGE_C && msg.getTarget() == h1) {
                success();
            } else {
                failure();
            }
        }
    };
    tester.doTest(1000);
}
Also used : Message(android.os.Message) Handler(android.os.Handler) Broadcaster(android.os.Broadcaster) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 13 with MediumTest

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

the class BroadcasterTest method test6.

@MediumTest
public void test6() throws Exception {
    /*
        * Two handlers request same message. Cancel the request for the
        * 2nd handler, make sure the first still works.
        */
    HandlerTester tester = new HandlerTester() {

        Handler h1;

        Handler h2;

        public void go() {
            Broadcaster b = new Broadcaster();
            h1 = new H();
            h2 = new H();
            b.request(MESSAGE_A, h1, MESSAGE_C);
            b.request(MESSAGE_A, h2, MESSAGE_D);
            b.cancelRequest(MESSAGE_A, h2, MESSAGE_D);
            Message msg = new Message();
            msg.what = MESSAGE_A;
            b.broadcast(msg);
        }

        public void handleMessage(Message msg) {
            if (msg.what == MESSAGE_C && msg.getTarget() == h1) {
                success();
            } else {
                failure();
            }
        }
    };
    tester.doTest(1000);
}
Also used : Message(android.os.Message) Handler(android.os.Handler) Broadcaster(android.os.Broadcaster) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 14 with MediumTest

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

the class DatabaseStatementTest method testSimpleQuery.

@MediumTest
public void testSimpleQuery() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (num INTEGER NOT NULL, str TEXT NOT NULL);");
    mDatabase.execSQL("INSERT INTO test VALUES (1234, 'hello');");
    SQLiteStatement statement1 = mDatabase.compileStatement("SELECT num FROM test WHERE str = ?");
    SQLiteStatement statement2 = mDatabase.compileStatement("SELECT str FROM test WHERE num = ?");
    try {
        statement1.bindString(1, "hello");
        long value = statement1.simpleQueryForLong();
        assertEquals(1234, value);
        statement1.bindString(1, "world");
        statement1.simpleQueryForLong();
        fail("shouldn't get here");
    } catch (SQLiteDoneException e) {
    // expected
    }
    try {
        statement2.bindLong(1, 1234);
        String value = statement1.simpleQueryForString();
        assertEquals("hello", value);
        statement2.bindLong(1, 5678);
        statement1.simpleQueryForString();
        fail("shouldn't get here");
    } catch (SQLiteDoneException e) {
    // expected
    }
    statement1.close();
    statement2.close();
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement) SQLiteDoneException(android.database.sqlite.SQLiteDoneException) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 15 with MediumTest

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

the class DatabaseStatementTest method testExecuteStatement.

@MediumTest
public void testExecuteStatement() throws Exception {
    populateDefaultTable();
    SQLiteStatement statement = mDatabase.compileStatement("DELETE FROM test");
    statement.execute();
    Cursor c = mDatabase.query("test", null, null, null, null, null, null);
    assertEquals(0, c.getCount());
    c.deactivate();
    statement.close();
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement) 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