use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowAccessibilityNodeInfoTest method shouldRecordFlagsProperly.
@Test
@Config(minSdk = LOLLIPOP)
public void shouldRecordFlagsProperly() {
node = AccessibilityNodeInfo.obtain();
node.setClickable(false);
shadow = (ShadowAccessibilityNodeInfo) ShadowExtractor.extract(node);
shadow.setPasteable(false);
assertThat(shadow.isClickable()).isEqualTo(false);
assertThat(shadow.isPasteable()).isEqualTo(false);
node.setText("Test");
shadow.setTextSelectionSetable(true);
shadow.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION);
node.setTextSelection(0, 1);
assertThat(shadow.getActions()).isEqualTo(AccessibilityNodeInfo.ACTION_SET_SELECTION);
assertThat(shadow.getTextSelectionStart()).isEqualTo(0);
assertThat(shadow.getTextSelectionEnd()).isEqualTo(1);
AccessibilityWindowInfo window = ShadowAccessibilityWindowInfo.obtain();
shadow.setAccessibilityWindowInfo(window);
assertThat(node.getWindow()).isEqualTo(window);
shadow.setAccessibilityWindowInfo(null);
// Remove action was added in API 21
node.removeAction(AccessibilityAction.ACTION_SET_SELECTION);
shadow.setPasteable(true);
shadow.setTextSelectionSetable(false);
node.addAction(AccessibilityNodeInfo.ACTION_PASTE);
assertThat(shadow.getActions()).isEqualTo(AccessibilityNodeInfo.ACTION_PASTE);
node.setClickable(true);
assertThat(shadow.isClickable()).isEqualTo(true);
node.setClickable(false);
shadow.setPasteable(false);
node.removeAction(AccessibilityNodeInfo.ACTION_PASTE);
node.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
assertThat(shadow.getActions()).isEqualTo(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
node.removeAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowAccountManagerTest method getAccountsByTypeForPackage.
@Test
@Config(minSdk = JELLY_BEAN_MR2)
public void getAccountsByTypeForPackage() {
Account[] accountsByTypeForPackage = am.getAccountsByTypeForPackage(null, "org.somepackage");
assertThat(accountsByTypeForPackage).isEmpty();
Account accountVisibleToPackage = new Account("user@gmail.com", "gmail.com");
shadowOf(am).addAccount(accountVisibleToPackage, "org.somepackage");
accountsByTypeForPackage = am.getAccountsByTypeForPackage("other_type", "org.somepackage");
assertThat(accountsByTypeForPackage).isEmpty();
accountsByTypeForPackage = am.getAccountsByTypeForPackage("gmail.com", "org.somepackage");
assertThat(accountsByTypeForPackage).containsOnly(accountVisibleToPackage);
accountsByTypeForPackage = am.getAccountsByTypeForPackage(null, "org.somepackage");
assertThat(accountsByTypeForPackage).containsOnly(accountVisibleToPackage);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowLocaleDataTest method shouldSupportLocaleEn_US_percentPost22.
@Test
@Config(minSdk = LOLLIPOP_MR1)
public void shouldSupportLocaleEn_US_percentPost22() throws Exception {
LocaleData localeData = LocaleData.get(Locale.US);
assertThat(localeData.percent).isEqualTo("%");
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowLocaleDataTest method shouldSupportLocaleEn_US_since_m.
@Test
@Config(minSdk = M)
public void shouldSupportLocaleEn_US_since_m() throws Exception {
LocaleData localeData = LocaleData.get(Locale.US);
assertThat(localeData.timeFormat_Hm).isEqualTo("HH:mm");
assertThat(localeData.timeFormat_hm).isEqualTo("h:mm a");
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowMatrixTest method testIsAffine.
@Test
@Config(sdk = { Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.LOLLIPOP_MR1, Build.VERSION_CODES.M })
public void testIsAffine() {
final Matrix matrix = new Matrix();
assertThat(matrix.isAffine()).isTrue();
matrix.postScale(2.0f, 2.0f);
assertThat(matrix.isAffine()).isTrue();
matrix.postTranslate(1.0f, 2.0f);
assertThat(matrix.isAffine()).isTrue();
matrix.postRotate(45.0f);
assertThat(matrix.isAffine()).isTrue();
matrix.setValues(new float[] { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 2.0f });
assertThat(matrix.isAffine()).isFalse();
}
Aggregations