Java Code Examples for android.support.test.espresso.core.deps.guava.base.Preconditions

The following are top voted examples for showing how to use android.support.test.espresso.core.deps.guava.base.Preconditions. 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: kgb   File: KeyboardTypeAction.java   View source code 5 votes vote down vote up
public KeyboardTypeAction add(String stringToBeTyped) {
  Preconditions.checkNotNull(stringToBeTyped);
  appendDescription(stringToBeTyped);

  for (char c : stringToBeTyped.toCharArray()) {
    if (c == '\n') {
      keysToBeHit.add(KeyLocations.instance().findSpecial(KeyEvent.KEYCODE_ENTER));
    } else {
      if (Character.isUpperCase(c)) {
        keysToBeHit.add(KeyLocations.instance().findSpecial(KeyEvent.KEYCODE_SHIFT_LEFT));
        c = Character.toLowerCase(c);
      }

      try {
        keysToBeHit.add(KeyLocations.instance().findStandard(c));
      } catch (IllegalStateException e) {
        if (fallbackToInjection) {
          Log.w(TAG, "Using fallback for " + c);

          keysToBeHit.add(KeyInfo.getFallbackKey("" + c));
        } else {
          throw e;
        }
      }
    }
  }

  return this;
}
 
Example 2
Project: espresso-macchiato   File: EspIsDisplayedMatcher.java   View source code 2 votes vote down vote up
/**
 * Assume visible area percentage.
 *
 * There is an bug on pre Android v11 versions where actionbar height can't be resolved when
 * using appcompat actionbar. This method use the appcompat actionbar height attribute when
 * on pre v11 versions.
 *
 * @see ViewMatchers#isDisplayingAtLeast(int)
 */
public static Matcher<View> isDisplayingAtLeast(final int areaPercentage) {
    Preconditions.checkState(areaPercentage <= 100, "Cannot have over 100 percent: %s", areaPercentage);
    Preconditions.checkState(areaPercentage > 0, "Must have a positive, non-zero value: %s", areaPercentage);
    return new IsDisplayingAtLeastMatcher(areaPercentage);
}