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();
}
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);
}
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);
}
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();
}
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();
}
Aggregations