use of android.support.test.filters.SdkSuppress in project material-components-android by material-components.
the class CoordinatorLayoutTest method testSetFitSystemWindows.
@Test
@TargetApi(21)
@SdkSuppress(minSdkVersion = 21)
public void testSetFitSystemWindows() throws Throwable {
final CoordinatorLayout col = activityTestRule.getActivity().mCoordinatorLayout;
final View view = new View(col.getContext());
// Create a mock which calls the default impl of onApplyWindowInsets()
final CoordinatorLayout.Behavior<View> mockBehavior = mock(CoordinatorLayout.Behavior.class);
doCallRealMethod().when(mockBehavior).onApplyWindowInsets(same(col), same(view), any(WindowInsetsCompat.class));
// Assert that the CoL is currently not set to fitSystemWindows
assertFalse(col.getFitsSystemWindows());
// Now add a view with our mocked behavior to the CoordinatorLayout
view.setFitsSystemWindows(true);
activityTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
final CoordinatorLayout.LayoutParams lp = col.generateDefaultLayoutParams();
lp.setBehavior(mockBehavior);
col.addView(view, lp);
}
});
getInstrumentation().waitForIdleSync();
// Now request some insets and wait for the pass to happen
activityTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
col.requestApplyInsets();
}
});
getInstrumentation().waitForIdleSync();
// Verify that onApplyWindowInsets() has not been called
verify(mockBehavior, never()).onApplyWindowInsets(same(col), same(view), any(WindowInsetsCompat.class));
// Now enable fits system windows and wait for a pass to happen
activityTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
col.setFitsSystemWindows(true);
}
});
getInstrumentation().waitForIdleSync();
// Verify that onApplyWindowInsets() has been called with some insets
verify(mockBehavior, atLeastOnce()).onApplyWindowInsets(same(col), same(view), any(WindowInsetsCompat.class));
}
use of android.support.test.filters.SdkSuppress in project sqlbrite by square.
the class BriteDatabaseTest method executeUpdateDeleteAndTriggerWithMultipleTables.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteAndTriggerWithMultipleTables() {
SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.NAME + " = 'Zach'");
final RecordingObserver managerObserver = new RecordingObserver();
db.createQuery(TABLE_MANAGER, SELECT_MANAGER_LIST).subscribe(managerObserver);
managerObserver.assertCursor().hasRow("Eve Evenson", "Alice Allison").isExhausted();
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
o.assertCursor().hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
final Set<String> employeeAndManagerTables = Collections.unmodifiableSet(new HashSet<>(BOTH_TABLES));
db.executeUpdateDelete(employeeAndManagerTables, statement);
o.assertCursor().hasRow("alice", "Zach").hasRow("bob", "Zach").hasRow("eve", "Zach").isExhausted();
managerObserver.assertCursor().hasRow("Zach", "Zach").isExhausted();
}
use of android.support.test.filters.SdkSuppress in project sqlbrite by square.
the class BriteDatabaseTest method executeUpdateDeleteThrowsAndDoesNotTrigger.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteThrowsAndDoesNotTrigger() {
SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.USERNAME + " = '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();
}
use of android.support.test.filters.SdkSuppress in project sqlbrite by square.
the class BriteDatabaseTest method executeUpdateDeleteAndTriggerWithNoTables.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteAndTriggerWithNoTables() {
SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.NAME + " = '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(Collections.<String>emptySet(), statement);
o.assertNoMoreEvents();
}
use of android.support.test.filters.SdkSuppress in project sqlbrite by square.
the class BriteDatabaseTest method executeUpdateDeleteAndTrigger.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteAndTrigger() {
SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.NAME + " = '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();
}
Aggregations