Search in sources :

Example 11 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ParallelUniverseTest method setUpApplicationState_setsVersionQualifierFromConfigQualifiers.

@Test
public void setUpApplicationState_setsVersionQualifierFromConfigQualifiers() {
    String givenQualifiers = "land-v17";
    Config c = new Config.Builder().setQualifiers(givenQualifiers).build();
    setUpApplicationState(c);
    assertThat(RuntimeEnvironment.getQualifiers()).contains("land-v17");
}
Also used : Config(org.robolectric.annotation.Config) SdkConfig(org.robolectric.internal.SdkConfig) Test(org.junit.Test)

Example 12 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ParallelUniverseTest method setUpApplicationState_setsVersionQualifierFromSdkConfigWithOtherQualifiers.

@Test
public void setUpApplicationState_setsVersionQualifierFromSdkConfigWithOtherQualifiers() {
    String givenQualifiers = "large-land";
    Config c = new Config.Builder().setQualifiers(givenQualifiers).build();
    setUpApplicationState(c);
    assertThat(RuntimeEnvironment.getQualifiers()).contains("large-land-v18");
}
Also used : Config(org.robolectric.annotation.Config) SdkConfig(org.robolectric.internal.SdkConfig) Test(org.junit.Test)

Example 13 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ParallelUniverseTest method setUpApplicationState_setsVersionQualifierFromSdkConfig.

@Test
public void setUpApplicationState_setsVersionQualifierFromSdkConfig() {
    String givenQualifiers = "";
    Config c = new Config.Builder().setQualifiers(givenQualifiers).build();
    setUpApplicationState(c);
    assertThat(RuntimeEnvironment.getQualifiers()).contains("v18");
}
Also used : Config(org.robolectric.annotation.Config) SdkConfig(org.robolectric.internal.SdkConfig) Test(org.junit.Test)

Example 14 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowDateUtilsTest method formatDateTime_withCurrentYear_worksPreKitKat.

@Test
@Config(maxSdk = JELLY_BEAN_MR2)
public void formatDateTime_withCurrentYear_worksPreKitKat() {
    Calendar calendar = Calendar.getInstance();
    final int currentYear = calendar.get(Calendar.YEAR);
    final long millisAtStartOfYear = getMillisAtStartOfYear();
    String actual = DateUtils.formatDateTime(RuntimeEnvironment.application, millisAtStartOfYear, DateUtils.FORMAT_NUMERIC_DATE);
    assertThat(actual).isEqualTo("1/1/" + currentYear);
}
Also used : Calendar(java.util.Calendar) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 15 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowDrawableTest method testGetBitmapOrVectorDrawableAt19.

@Test
@Config(minSdk = KITKAT)
public void testGetBitmapOrVectorDrawableAt19() {
    final Drawable aDrawable = RuntimeEnvironment.application.getResources().getDrawable(R.drawable.an_image_or_vector);
    assertThat(aDrawable).isInstanceOf(BitmapDrawable.class);
}
Also used : BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) VectorDrawable(android.graphics.drawable.VectorDrawable) 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