Java Code Examples for android.support.test.filters.SdkSuppress

The following are top voted examples for showing how to use android.support.test.filters.SdkSuppress. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: material-components-android   File: BottomNavigationViewTest.java   View source code 7 votes vote down vote up
@UiThreadTest
@Test
@SmallTest
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
@TargetApi(Build.VERSION_CODES.N)
public void testPointerIcon() throws Throwable {
  final Activity activity = activityTestRule.getActivity();
  final PointerIcon expectedIcon = PointerIcon.getSystemIcon(activity, PointerIcon.TYPE_HAND);
  final MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_HOVER_MOVE, 0, 0, 0);
  final Menu menu = mBottomNavigation.getMenu();
  for (int i = 0; i < menu.size(); i++) {
    final MenuItem item = menu.getItem(i);
    assertTrue(item.isEnabled());
    final View itemView = activity.findViewById(item.getItemId());
    assertEquals(expectedIcon, itemView.onResolvePointerIcon(event, 0));
    item.setEnabled(false);
    assertEquals(null, itemView.onResolvePointerIcon(event, 0));
    item.setEnabled(true);
    assertEquals(expectedIcon, itemView.onResolvePointerIcon(event, 0));
  }
}
 
Example 2
Project: GitHub   File: TasksScreenTest.java   View source code 6 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = 21) // Blinking cursor after rotation breaks this in API 19
public void orientationChange_DuringEdit_ChangePersists() throws Throwable {
    // Add a completed task
    createTask(TITLE1, DESCRIPTION);

    // Open the task in details view
    onView(withText(TITLE1)).perform(click());

    // Click on the edit task button
    onView(withId(R.id.fab_edit_task)).perform(click());

    // Change task title (but don't save)
    onView(withId(R.id.add_task_title))
            .perform(replaceText(TITLE2), closeSoftKeyboard()); // Type new task title

    // Rotate the screen
    TestUtils.rotateOrientation(getCurrentActivity());

    // Verify task title is restored
    onView(withId(R.id.add_task_title)).check(matches(withText(TITLE2)));
}
 
Example 3
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 6 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = LOLLIPOP)
public void createNotification_withBigTextStyle_withTitleAndBody() {
    Map<String, String> input = new HashMap<>();
    input.put("title", TITLE);
    input.put("body", BODY);

    android.app.Notification result = MessagingServiceUtils.createNotification(context, input, disabledOreoConfig);

    assertEquals(TITLE, result.extras.getString(NotificationCompat.EXTRA_TITLE));
    assertEquals(TITLE, result.extras.getString(NotificationCompat.EXTRA_TITLE_BIG));
    assertEquals(BODY, result.extras.getString(NotificationCompat.EXTRA_TEXT));
    assertEquals(BODY, result.extras.getString(NotificationCompat.EXTRA_BIG_TEXT));

    assertNull(result.extras.getString(NotificationCompat.EXTRA_SUMMARY_TEXT));
}
 
Example 4
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 6 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = LOLLIPOP)
public void createNotification_withBigTextStyle_withoutTitle_withBody() {
    Map<String, String> input = new HashMap<>();
    input.put("body", BODY);

    android.app.Notification result = MessagingServiceUtils.createNotification(context, input, disabledOreoConfig);

    String expectedTitle = expectedBasedOnApiLevel(getApplicationName(), "");

    assertEquals(expectedTitle, result.extras.getString(NotificationCompat.EXTRA_TITLE));
    assertEquals(expectedTitle, result.extras.getString(NotificationCompat.EXTRA_TITLE_BIG));
    assertEquals(BODY, result.extras.getString(NotificationCompat.EXTRA_TEXT));
    assertEquals(BODY, result.extras.getString(NotificationCompat.EXTRA_BIG_TEXT));

    assertNull(result.extras.getString(NotificationCompat.EXTRA_SUMMARY_TEXT));
}
 
Example 5
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 6 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = LOLLIPOP)
public void createNotification_withBigTextStyle_withoutTitle_withBody_withDefaultTitle() {
    Map<String, String> input = new HashMap<>();
    input.put("body", BODY);
    input.put("u", "{\"test_field\":\"\",\"ems_default_title\":\"" + DEFAULT_TITLE + "\",\"image\":\"https:\\/\\/media.giphy.com\\/media\\/ktvFa67wmjDEI\\/giphy.gif\",\"deep_link\":\"lifestylelabels.com\\/mobile\\/product\\/3245678\",\"sid\":\"sid_here\"}");

    android.app.Notification result = MessagingServiceUtils.createNotification(context, input, disabledOreoConfig);

    String expectedTitle = expectedBasedOnApiLevel(DEFAULT_TITLE, "");

    assertEquals(expectedTitle, result.extras.getString(NotificationCompat.EXTRA_TITLE));
    assertEquals(expectedTitle, result.extras.getString(NotificationCompat.EXTRA_TITLE_BIG));
    assertEquals(BODY, result.extras.getString(NotificationCompat.EXTRA_TEXT));
    assertEquals(BODY, result.extras.getString(NotificationCompat.EXTRA_BIG_TEXT));

    assertNull(result.extras.getString(NotificationCompat.EXTRA_SUMMARY_TEXT));
}
 
Example 6
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 6 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = LOLLIPOP)
public void testCreateNotification_withBigPictureStyle_whenImageIsAvailable() {
    Map<String, String> input = new HashMap<>();
    input.put("title", TITLE);
    input.put("body", BODY);
    input.put("image_url", "https://ems-denna.herokuapp.com/images/Emarsys.png");

    android.app.Notification result = MessagingServiceUtils.createNotification(context, input, disabledOreoConfig);

    assertEquals(TITLE, result.extras.getString(NotificationCompat.EXTRA_TITLE));
    assertEquals(TITLE, result.extras.getString(NotificationCompat.EXTRA_TITLE_BIG));
    assertEquals(BODY, result.extras.getString(NotificationCompat.EXTRA_SUMMARY_TEXT));

    assertNotNull(result.extras.get(NotificationCompat.EXTRA_PICTURE));
    assertNotNull(result.extras.get(NotificationCompat.EXTRA_LARGE_ICON));

    assertNull(result.extras.get(NotificationCompat.EXTRA_LARGE_ICON_BIG));
}
 
Example 7
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 6 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = LOLLIPOP)
public void testCreateNotification_withBigTextStyle_whenImageCannotBeLoaded() {
    Map<String, String> input = new HashMap<>();
    input.put("title", TITLE);
    input.put("body", BODY);
    input.put("image_url", "https://fa.il/img.jpg");

    android.app.Notification result = MessagingServiceUtils.createNotification(context, input, disabledOreoConfig);

    assertEquals(TITLE, result.extras.getString(NotificationCompat.EXTRA_TITLE));
    assertEquals(TITLE, result.extras.getString(NotificationCompat.EXTRA_TITLE_BIG));
    assertEquals(BODY, result.extras.getString(NotificationCompat.EXTRA_TEXT));
    assertEquals(BODY, result.extras.getString(NotificationCompat.EXTRA_BIG_TEXT));

    assertNull(result.extras.getString(NotificationCompat.EXTRA_SUMMARY_TEXT));
}
 
Example 8
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 6 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = O)
public void testCreateNotification_withChannelId() {
    Map<String, String> input = new HashMap<>();
    input.put("title", TITLE);
    input.put("body", BODY);
    input.put("channel_id", CHANNEL_ID);

    android.app.Notification result = MessagingServiceUtils.createNotification(context, input, disabledOreoConfig);

    assertEquals(CHANNEL_ID, result.getChannelId());
}
 
Example 9
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 6 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = O)
public void testCreateChannel_overridesPrevious(){
    NotificationManager manager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    manager.deleteNotificationChannel("ems_me_default");
    assertNull(manager.getNotificationChannel("ems_me_default"));
    MessagingServiceUtils.createDefaultChannel(context, enabledOreoConfig);
    NotificationChannel channel = manager.getNotificationChannel("ems_me_default");
    assertNotNull(channel);

    OreoConfig updatedConfig = new OreoConfig(true, "updatedName", "updatedDescription");
    MessagingServiceUtils.createDefaultChannel(context, updatedConfig);

    NotificationChannel updatedChannel = manager.getNotificationChannel("ems_me_default");
    assertEquals(updatedConfig.getDefaultChannelName(), updatedChannel.getName());
    assertEquals(updatedConfig.getDefaultChannelDescription(), updatedChannel.getDescription());
}
 
Example 10
Project: sqlbrite-sqlcipher   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndTrigger() {
  SQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + 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();
}
 
Example 11
Project: sqlbrite-sqlcipher   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndDontTrigger() {
  SQLiteStatement statement = real.compileStatement(""
      + "UPDATE " + TABLE_EMPLOYEE
      + " SET " + NAME + " = 'Zach'"
      + " WHERE " + 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();
}
 
Example 12
Project: sqlbrite-sqlcipher   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndTriggerWithNoTables() {
  SQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + 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();
}
 
Example 13
Project: sqlbrite-sqlcipher   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteThrowsAndDoesNotTrigger() {
  SQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + USERNAME + " = 'alice'");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES)
      .skip(1) // Skip initial
      .subscribe(o);

  try {
    db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
    fail();
  } catch (SQLException ignored) {
  }
  o.assertNoMoreEvents();
}
 
Example 14
Project: sqlbrite-sqlcipher   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteWithArgsAndTrigger() {
  SQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + 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();
}
 
Example 15
Project: sqlbrite-sqlcipher   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteWithArgsThrowsAndDoesNotTrigger() {
  SQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + USERNAME + " = ?");
  statement.bindString(1, "alice");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES)
      .skip(1) // Skip initial
      .subscribe(o);

  try {
    db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
    fail();
  } catch (SQLException ignored) {
  }
  o.assertNoMoreEvents();
}
 
Example 16
Project: force-update   File: CarretoVersionProviderTest.java   View source code 6 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion=19)
public void loadVersionOffline() throws Exception {
    CarretoGooglePlayVersionProvider provider = new CarretoGooglePlayVersionProvider("com.vocabularyminer.android");

    TestButler.setGsmState(false);
    TestButler.setWifiState(false);

    try {
        VersionResult result = provider.getVersionResult();

        assertTrue(result.isError());
        assertNotNull(result);
        assertNull(result.getVersion());
        assertNotNull(result.getErrorMessage());
        assertNotNull(result.getErrorException());

    } finally {
        TestButler.setGsmState(true);
        TestButler.setWifiState(true);
        Thread.sleep(1000);
    }

}
 
Example 17
Project: force-update   File: JsonHttpVersionProviderTest.java   View source code 6 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion=19)
public void loadVersionOffline() throws Exception {
    JsonHttpVersionProvider provider = new JsonHttpVersionProvider("https://raw.githubusercontent.com/skoumalcz/force-update/master/force-update/src/androidTest/java/net/skoumal/forceupdate/provider/JsonHttpVersionProviderTest.DefaultAttributes.json");

    TestButler.setGsmState(false);
    TestButler.setWifiState(false);

    try {
        VersionResult result = provider.getVersionResult();

        assertTrue(result.isError());
        assertNotNull(result);
        assertNull(result.getVersion());
        assertNull(result.getPayload());
        assertNotNull(result.getErrorMessage());
        assertNotNull(result.getErrorException());

    } finally {
        TestButler.setGsmState(true);
        TestButler.setWifiState(true);
        Thread.sleep(1000);
    }

}
 
Example 18
Project: test-butler   File: ShowImeWithHardKeyboardHelperTest.java   View source code 6 votes vote down vote up
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP_MR1)
@Test
public void keyboardDoesNotShow() {
    TestButler.setShowImeWithHardKeyboardState(false);
    EditText editText = (EditText) testRule.getActivity().findViewById(R.id.editText);

    int before[] = new int[2];
    editText.getLocationOnScreen(before);

    onView(withId(R.id.editText)).perform(click());

    int after[] = new int[2];
    editText.getLocationOnScreen(after);

    // Check that the position has not changed at all
    assertEquals(before[0], after[0]);
    assertEquals(before[1], after[1]);
}
 
Example 19
Project: test-butler   File: ShowImeWithHardKeyboardHelperTest.java   View source code 6 votes vote down vote up
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP_MR1)
@Test
public void keyboardDoesShow() {
    TestButler.setShowImeWithHardKeyboardState(true);
    EditText editText = (EditText) testRule.getActivity().findViewById(R.id.editText);

    int before[] = new int[2];
    editText.getLocationOnScreen(before);

    onView(withId(R.id.editText)).perform(click());

    int after[] = new int[2];
    editText.getLocationOnScreen(after);

    // Only check that the y position changed
    assertNotEquals(before[1], after[1]);
}
 
Example 20
Project: material-components-android   File: TextInputLayoutTest.java   View source code 6 votes vote down vote up
@UiThreadTest
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
public void testDispatchProvideAutofillStructure() {
  final Activity activity = activityTestRule.getActivity();

  final TextInputLayout layout = activity.findViewById(R.id.textinput);

  final ViewStructureImpl structure = new ViewStructureImpl();
  layout.dispatchProvideAutofillStructure(structure, 0);

  assertEquals(2, structure.getChildCount()); // EditText and TextView

  // Asserts the structure.
  final ViewStructureImpl childStructure = structure.getChildAt(0);
  assertEquals(EditText.class.getName(), childStructure.getClassName());
  assertEquals("Hint to the user", childStructure.getHint());

  // Make sure the widget's hint was restored.
  assertEquals("Hint to the user", layout.getHint());
  final EditText editText = activity.findViewById(R.id.textinput_edittext);
  assertNull(editText.getHint());
}
 
Example 21
Project: material-components-android   File: TabLayoutTest.java   View source code 6 votes vote down vote up
@Test
@UiThreadTest
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
@TargetApi(Build.VERSION_CODES.N)
public void testPointerIcon() {
  final LayoutInflater inflater = LayoutInflater.from(activityTestRule.getActivity());
  final TabLayout tabLayout = (TabLayout) inflater.inflate(R.layout.design_tabs_items, null);
  final PointerIcon expectedIcon =
      PointerIcon.getSystemIcon(activityTestRule.getActivity(), PointerIcon.TYPE_HAND);

  final int tabCount = tabLayout.getTabCount();
  assertEquals(3, tabCount);

  final MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_HOVER_MOVE, 0, 0, 0);
  for (int i = 0; i < tabCount; i++) {
    assertEquals(expectedIcon, tabLayout.getTabAt(i).view.onResolvePointerIcon(event, 0));
  }
}
 
Example 22
Project: RxBinding   File: RxAppBarLayoutTest.java   View source code 6 votes vote down vote up
@TargetApi(JELLY_BEAN_MR1)
@SdkSuppress(minSdkVersion = JELLY_BEAN_MR1)
@Test @UiThreadTest public void offsetChanges() {
  RecordingObserver<Integer> o = new RecordingObserver<>();
  RxAppBarLayout.offsetChanges(view).subscribe(o);
  o.assertNoMoreEvents();

  CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
  AppBarLayout.Behavior behavior = new AppBarLayout.Behavior();
  params.setBehavior(behavior);
  behavior.onLayoutChild(parent, view, View.LAYOUT_DIRECTION_LTR);
  assertEquals(0, o.takeNext().intValue());

  o.dispose();

  behavior.onLayoutChild(parent, view, View.LAYOUT_DIRECTION_LTR);
  o.assertNoMoreEvents();
}
 
Example 23
Project: sqlbrite   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndTrigger() {
  SupportSQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + 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();
}
 
Example 24
Project: sqlbrite   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndDontTrigger() {
  SupportSQLiteStatement statement = real.compileStatement(""
      + "UPDATE " + TABLE_EMPLOYEE
      + " SET " + NAME + " = 'Zach'"
      + " WHERE " + 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();
}
 
Example 25
Project: sqlbrite   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndTriggerWithNoTables() {
  SupportSQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + 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();
}
 
Example 26
Project: sqlbrite   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteThrowsAndDoesNotTrigger() {
  SupportSQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + USERNAME + " = 'alice'");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES)
      .skip(1) // Skip initial
      .subscribe(o);

  try {
    db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
    fail();
  } catch (SQLException ignored) {
  }
  o.assertNoMoreEvents();
}
 
Example 27
Project: sqlbrite   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteWithArgsAndTrigger() {
  SupportSQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + 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();
}
 
Example 28
Project: sqlbrite   File: BriteDatabaseTest.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteWithArgsThrowsAndDoesNotTrigger() {
  SupportSQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + USERNAME + " = ?");
  statement.bindString(1, "alice");

  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES)
      .skip(1) // Skip initial
      .subscribe(o);

  try {
    db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
    fail();
  } catch (SQLException ignored) {
  }
  o.assertNoMoreEvents();
}
 
Example 29
Project: android-proxy   File: BasicAppTests.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
public void testCreateNewPACProxy()
{
    openDrawer(R.id.drawer_layout);

    onView(withText(R.string.pac_proxies)).perform(click());
    onView(withId(R.id.add_new_pac_proxy)).perform(click());

    PacEntity pacProxy = TestUtils.createRandomPACProxy();

    onView(allOf(withId(R.id.field_value), isDescendantOfA(withId(R.id.pac_url)))).perform(typeText(String.valueOf(pacProxy.getPacUriFile())));

    onView(withId(R.id.menu_save)).perform(click());
}
 
Example 30
Project: GitHub   File: TasksScreenTest.java   View source code 5 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = 21) // Blinking cursor after rotation breaks this in API 19
public void orientationChange_DuringEdit_NoDuplicate() throws IllegalStateException {
    // Add a completed task
    createTask(TITLE1, DESCRIPTION);

    // Open the task in details view
    onView(withText(TITLE1)).perform(click());

    // Click on the edit task button
    onView(withId(R.id.fab_edit_task)).perform(click());

    // Rotate the screen
    TestUtils.rotateOrientation(getCurrentActivity());

    // Edit task title and description
    onView(withId(R.id.add_task_title))
            .perform(replaceText(TITLE2), closeSoftKeyboard()); // Type new task title
    onView(withId(R.id.add_task_description)).perform(replaceText(DESCRIPTION),
            closeSoftKeyboard()); // Type new task description and close the keyboard

    // Save the task
    onView(withId(R.id.fab_edit_task_done)).perform(click());

    // Verify task is displayed on screen in the task list.
    onView(withItemText(TITLE2)).check(matches(isDisplayed()));

    // Verify previous task is not displayed
    onView(withItemText(TITLE1)).check(doesNotExist());
}
 
Example 31
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 5 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = LOLLIPOP)
public void createNotification_withBigTextStyle_withTitle_withoutBody() {
    Map<String, String> input = new HashMap<>();
    input.put("title", TITLE);

    android.app.Notification result = MessagingServiceUtils.createNotification(context, input, disabledOreoConfig);

    assertEquals(TITLE, result.extras.getString(NotificationCompat.EXTRA_TITLE));
    assertEquals(TITLE, result.extras.getString(NotificationCompat.EXTRA_TITLE_BIG));

    assertNull(result.extras.getString(NotificationCompat.EXTRA_TEXT));
    assertNull(result.extras.getString(NotificationCompat.EXTRA_BIG_TEXT));
    assertNull(result.extras.getString(NotificationCompat.EXTRA_SUMMARY_TEXT));
}
 
Example 32
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 5 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = O)
public void testCreateNotification_withoutChannelId_withDefaultChannelEnabled() {
    Map<String, String> input = new HashMap<>();
    input.put("title", TITLE);
    input.put("body", BODY);

    android.app.Notification result = MessagingServiceUtils.createNotification(context, input, enabledOreoConfig);

    String expected = "ems_me_default";

    assertEquals(expected, result.getChannelId());
}
 
Example 33
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 5 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = O)
public void testCreateNotification_withoutChannelId_withDefaultChannelDisabled() {
    Map<String, String> input = new HashMap<>();
    input.put("title", TITLE);
    input.put("body", BODY);

    android.app.Notification result = MessagingServiceUtils.createNotification(context, input, disabledOreoConfig);

    assertNull(result.getChannelId());
}
 
Example 34
Project: android-mobile-engage-sdk   File: MessagingServiceUtilsTest.java   View source code 5 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = O)
public void testCreateChannel(){
    NotificationManager manager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    manager.deleteNotificationChannel("ems_me_default");
    assertNull(manager.getNotificationChannel("ems_me_default"));

    MessagingServiceUtils.createDefaultChannel(context, enabledOreoConfig);

    NotificationChannel channel = manager.getNotificationChannel("ems_me_default");
    assertNotNull(channel);
    assertEquals(NotificationManager.IMPORTANCE_DEFAULT, channel.getImportance());
    assertEquals(enabledOreoConfig.getDefaultChannelName(), channel.getName());
    assertEquals(enabledOreoConfig.getDefaultChannelDescription(), channel.getDescription());
}
 
Example 35
Project: wulkanowy   File: SafetyTest.java   View source code 5 votes vote down vote up
@Test
@SdkSuppress(minSdkVersion = 18)
public void encryptDecryptTest() throws Exception {
    Context targetContext = InstrumentationRegistry.getTargetContext();

    Safety safety = new Safety();
    Assert.assertEquals("PASS", safety.decrypt("TEST", safety.encrypt("TEST", "PASS", targetContext)));
}
 
Example 36
Project: sqlbrite-sqlcipher   File: BriteDatabaseTest.java   View source code 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test public void executeUpdateDeleteAndTriggerWithMultipleTables() {
  SQLiteStatement statement = real.compileStatement(
      "UPDATE " + TABLE_EMPLOYEE + " SET " + 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();
}
 
Example 37
Project: sqlbrite-sqlcipher   File: BriteDatabaseTest.java   View source code 5 votes vote down vote up
@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))
          .blockingFirst();
  assertThat(employees).isEqualTo(new Employee("alice", "Alice Allison"));

  transactionProceed.countDown();
  assertThat(transactionCompleted.await(10, SECONDS)).isTrue();
}
 
Example 38
Project: sqlbrite-sqlcipher   File: QueryTest.java   View source code 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.N) // TODO remove after upgrading Android Gradle plugin to 2.3+
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
@Test public void mapToOptional() {
  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES + " LIMIT 1")
      .lift(Query.mapToOptional(MAPPER))
      .test()
      .assertValue(Optional.of(new Employee("alice", "Alice Allison")));
}
 
Example 39
Project: sqlbrite-sqlcipher   File: QueryTest.java   View source code 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.N) // TODO remove after upgrading Android Gradle plugin to 2.3+
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
@Test public void mapToOptionalThrowsWhenMapperReturnsNull() {
  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES + " LIMIT 1")
      .lift(Query.mapToOptional(new Function<Cursor, Employee>() {
        @Override public Employee apply(Cursor cursor) throws Exception {
          return null;
        }
      }))
      .test()
      .assertError(NullPointerException.class)
      .assertErrorMessage("QueryToOne mapper returned null");
}
 
Example 40
Project: sqlbrite-sqlcipher   File: QueryTest.java   View source code 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.N) // TODO remove after upgrading Android Gradle plugin to 2.3+
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
@Test public void mapToOptionalThrowsOnMultipleRows() {
  db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES + " LIMIT 2") //
      .lift(Query.mapToOptional(MAPPER))
      .test()
      .assertError(IllegalStateException.class)
      .assertErrorMessage("Cursor returned more than 1 row");
}