Search in sources :

Example 6 with SdkSuppress

use of android.support.test.filters.SdkSuppress in project sqlbrite by square.

the class BriteDatabaseTest method executeUpdateDeleteWithArgsAndTrigger.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteWithArgsAndTrigger() {
    SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.NAME + " = ?");
    statement.bindString(1, "Zach");
    db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
    o.assertCursor().hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
    db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
    o.assertCursor().hasRow("alice", "Zach").hasRow("bob", "Zach").hasRow("eve", "Zach").isExhausted();
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement) Test(org.junit.Test) SdkSuppress(android.support.test.filters.SdkSuppress) TargetApi(android.annotation.TargetApi)

Example 7 with SdkSuppress

use of android.support.test.filters.SdkSuppress in project sqlbrite by square.

the class BriteDatabaseTest method executeUpdateDeleteAndDontTrigger.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteAndDontTrigger() {
    SQLiteStatement statement = real.compileStatement("" + "UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.NAME + " = 'Zach'" + " WHERE " + TestDb.EmployeeTable.NAME + " = 'Rob'");
    db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
    o.assertCursor().hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
    db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
    o.assertNoMoreEvents();
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement) Test(org.junit.Test) SdkSuppress(android.support.test.filters.SdkSuppress) TargetApi(android.annotation.TargetApi)

Example 8 with SdkSuppress

use of android.support.test.filters.SdkSuppress in project sqlbrite by square.

the class BriteDatabaseTest method nonExclusiveTransactionWorks.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void nonExclusiveTransactionWorks() throws InterruptedException {
    final CountDownLatch transactionStarted = new CountDownLatch(1);
    final CountDownLatch transactionProceed = new CountDownLatch(1);
    final CountDownLatch transactionCompleted = new CountDownLatch(1);
    new Thread() {

        @Override
        public void run() {
            Transaction transaction = db.newNonExclusiveTransaction();
            transactionStarted.countDown();
            try {
                db.insert(TABLE_EMPLOYEE, employee("hans", "Hans Hanson"));
                transactionProceed.await(10, SECONDS);
            } catch (InterruptedException e) {
                throw new RuntimeException("Exception in transaction thread", e);
            }
            transaction.markSuccessful();
            transaction.close();
            transactionCompleted.countDown();
        }
    }.start();
    assertThat(transactionStarted.await(10, SECONDS)).isTrue();
    //Simple query
    Employee employees = db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES + " LIMIT 1").lift(Query.mapToOne(Employee.MAPPER)).toBlocking().first();
    assertThat(employees).isEqualTo(new Employee("alice", "Alice Allison"));
    transactionProceed.countDown();
    assertThat(transactionCompleted.await(10, SECONDS)).isTrue();
}
Also used : Employee(com.squareup.sqlbrite.TestDb.Employee) Transaction(com.squareup.sqlbrite.BriteDatabase.Transaction) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test) SdkSuppress(android.support.test.filters.SdkSuppress) TargetApi(android.annotation.TargetApi)

Example 9 with SdkSuppress

use of android.support.test.filters.SdkSuppress in project sqlbrite by square.

the class BriteDatabaseTest method executeUpdateDeleteWithArgsThrowsAndDoesNotTrigger.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteWithArgsThrowsAndDoesNotTrigger() {
    SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.USERNAME + " = ?");
    statement.bindString(1, "alice");
    db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).skip(// Skip initial
    1).subscribe(o);
    try {
        db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
        fail();
    } catch (SQLException ignored) {
    }
    o.assertNoMoreEvents();
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement) SQLException(android.database.SQLException) Test(org.junit.Test) SdkSuppress(android.support.test.filters.SdkSuppress) TargetApi(android.annotation.TargetApi)

Example 10 with SdkSuppress

use of android.support.test.filters.SdkSuppress in project weex-example by KalicyZhou.

the class BenchmarkTest method testFlingFPS.

@Repeat(TIMES)
@Test
@SdkSuppress(minSdkVersion = 23)
public void testFlingFPS() {
    UiObject2 uiObject2 = loadPageForFPS();
    if (uiObject2 != null) {
        uiObject2.fling(Direction.DOWN, FLING_SPEED);
        uiObject2.fling(Direction.DOWN, FLING_SPEED);
        uiObject2.fling(Direction.DOWN, FLING_SPEED);
        uiObject2.fling(Direction.DOWN, FLING_SPEED);
        processGfxInfo(flingFrameSeconds);
    }
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) Test(org.junit.Test) SdkSuppress(android.support.test.filters.SdkSuppress)

Aggregations

SdkSuppress (android.support.test.filters.SdkSuppress)11 Test (org.junit.Test)11 TargetApi (android.annotation.TargetApi)9 SQLiteStatement (android.database.sqlite.SQLiteStatement)7 SQLException (android.database.SQLException)2 UiObject2 (android.support.test.uiautomator.UiObject2)2 Espresso.onView (android.support.test.espresso.Espresso.onView)1 MediumTest (android.support.test.filters.MediumTest)1 WindowInsetsCompat (android.support.v4.view.WindowInsetsCompat)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 Transaction (com.squareup.sqlbrite.BriteDatabase.Transaction)1 Employee (com.squareup.sqlbrite.TestDb.Employee)1 CountDownLatch (java.util.concurrent.CountDownLatch)1