Search in sources :

Example 66 with Config

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);
}
Also used : AccessibilityWindowInfo(android.view.accessibility.AccessibilityWindowInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 67 with Config

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);
}
Also used : Account(android.accounts.Account) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 68 with Config

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("%");
}
Also used : LocaleData(libcore.icu.LocaleData) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 69 with Config

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");
}
Also used : LocaleData(libcore.icu.LocaleData) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 70 with Config

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();
}
Also used : Matrix(android.graphics.Matrix) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

Config (org.robolectric.annotation.Config)158 Test (org.junit.Test)153 Intent (android.content.Intent)21 ComponentName (android.content.ComponentName)16 Bundle (android.os.Bundle)10 Activity (android.app.Activity)7 Bitmap (android.graphics.Bitmap)7 Notification (android.app.Notification)6 Button (android.widget.Button)6 TextView (android.widget.TextView)6 BuildConfig (com.firebase.ui.auth.BuildConfig)6 BuildConfig (com.onesignal.BuildConfig)6 ShadowRecyclerView (io.github.hidroh.materialistic.test.shadow.ShadowRecyclerView)6 SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)6 Properties (java.util.Properties)6 Account (android.accounts.Account)5 Network (android.net.Network)5 NetworkInfo (android.net.NetworkInfo)5 RecyclerView (android.support.v7.widget.RecyclerView)5 BitmapDrawable (android.graphics.drawable.BitmapDrawable)4