Search in sources :

Example 16 with MediumTest

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

the class DatabaseStatementTest method testStatementMultiThreaded.

@MediumTest
public void testStatementMultiThreaded() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (num INTEGER, str TEXT);");
    SQLiteStatement statement = mDatabase.compileStatement("INSERT INTO test (num, str) VALUES (?, ?)");
    StatementTestThread thread = new StatementTestThread(mDatabase, statement);
    thread.start();
    try {
        thread.join();
    } finally {
        statement.close();
    }
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 17 with MediumTest

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

the class DatabaseStatementTest method testStatementClearBindings.

@MediumTest
public void testStatementClearBindings() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (num INTEGER);");
    SQLiteStatement statement = mDatabase.compileStatement("INSERT INTO test (num) VALUES (?)");
    for (long i = 0; i < 10; i++) {
        statement.bindLong(1, i);
        statement.clearBindings();
        statement.execute();
    }
    statement.close();
    Cursor c = mDatabase.query("test", null, null, null, null, null, "ROWID");
    int numCol = c.getColumnIndexOrThrow("num");
    assertTrue(c.moveToFirst());
    for (long i = 0; i < 10; i++) {
        assertTrue(c.isNull(numCol));
        c.moveToNext();
    }
    c.close();
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement) Cursor(android.database.Cursor) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 18 with MediumTest

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

the class DatabaseStatementTest method testSimpleStringBinding.

@MediumTest
public void testSimpleStringBinding() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (num TEXT, value TEXT);");
    String statement = "INSERT INTO test (num, value) VALUES (?,?)";
    String[] args = new String[2];
    for (int i = 0; i < 2; i++) {
        args[i] = Integer.toHexString(i);
    }
    mDatabase.execSQL(statement, args);
    Cursor c = mDatabase.query("test", null, null, null, null, null, null);
    int numCol = c.getColumnIndexOrThrow("num");
    int valCol = c.getColumnIndexOrThrow("value");
    c.moveToFirst();
    String num = c.getString(numCol);
    assertEquals(Integer.toHexString(0), num);
    String val = c.getString(valCol);
    assertEquals(Integer.toHexString(1), val);
    c.close();
}
Also used : Cursor(android.database.Cursor) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 19 with MediumTest

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

the class SpannableTest method testGetSpans.

@MediumTest
public void testGetSpans() {
    Spannable spannable = newSpannableWithText("abcdef");
    Object emptySpan = new Object();
    spannable.setSpan(emptySpan, 1, 1, 0);
    Object unemptySpan = new Object();
    spannable.setSpan(unemptySpan, 1, 2, 0);
    Object[] spans;
    // Empty spans are included when they merely abut the query region
    // but other spans are not, unless the query region is empty, in
    // in which case any abutting spans are returned.
    spans = spannable.getSpans(0, 1, Object.class);
    MoreAsserts.assertEquals(new Object[] { emptySpan }, spans);
    spans = spannable.getSpans(0, 2, Object.class);
    MoreAsserts.assertEquals(new Object[] { emptySpan, unemptySpan }, spans);
    spans = spannable.getSpans(1, 2, Object.class);
    MoreAsserts.assertEquals(new Object[] { emptySpan, unemptySpan }, spans);
    spans = spannable.getSpans(2, 2, Object.class);
    MoreAsserts.assertEquals(new Object[] { unemptySpan }, spans);
}
Also used : Spannable(android.text.Spannable) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 20 with MediumTest

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

the class SettingsProviderTest method testParseProviderList.

@MediumTest
public void testParseProviderList() {
    ContentResolver r = getContext().getContentResolver();
    // Make sure we get out what we put in.
    Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "test1,test2,test3");
    assertEquals(Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED), "test1,test2,test3");
    // Test adding a value
    Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "");
    Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+test1");
    assertEquals("test1", Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED));
    // Test adding a second value
    Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+test2");
    assertEquals("test1,test2", Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED));
    // Test adding a third value
    Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+test3");
    assertEquals("test1,test2,test3", Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED));
    // Test deleting the first value in a 3 item list
    Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-test1");
    assertEquals("test2,test3", Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED));
    // Test deleting the middle value in a 3 item list
    Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "test1,test2,test3");
    Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-test2");
    assertEquals("test1,test3", Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED));
    // Test deleting the last value in a 3 item list
    Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "test1,test2,test3");
    Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-test3");
    assertEquals("test1,test2", Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED));
}
Also used : ContentResolver(android.content.ContentResolver) 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