Search in sources :

Example 26 with Config

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

the class ShadowConnectivityManagerTest method getNetworkInfo_shouldReturnSomeForAllNetworks.

@Test
@Config(minSdk = LOLLIPOP)
public void getNetworkInfo_shouldReturnSomeForAllNetworks() throws Exception {
    Network[] allNetworks = connectivityManager.getAllNetworks();
    for (Network network : allNetworks) {
        NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
        assertThat(networkInfo).isNotNull();
    }
}
Also used : NetworkInfo(android.net.NetworkInfo) Network(android.net.Network) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 27 with Config

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

the class ShadowConnectivityManagerTest method getNetworkInfo_shouldReturnAddedNetwork.

@Test
@Config(minSdk = LOLLIPOP)
public void getNetworkInfo_shouldReturnAddedNetwork() throws Exception {
    Network vpnNetwork = ShadowNetwork.newInstance(123);
    NetworkInfo vpnNetworkInfo = ShadowNetworkInfo.newInstance(NetworkInfo.DetailedState.CONNECTED, ConnectivityManager.TYPE_VPN, 0, true, true);
    shadowConnectivityManager.addNetwork(vpnNetwork, vpnNetworkInfo);
    NetworkInfo returnedNetworkInfo = connectivityManager.getNetworkInfo(vpnNetwork);
    assertThat(returnedNetworkInfo).isSameAs(vpnNetworkInfo);
}
Also used : NetworkInfo(android.net.NetworkInfo) Network(android.net.Network) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 28 with Config

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

the class ShadowBitmapTest method hasMipmap.

@Test
@Config(minSdk = JELLY_BEAN_MR1)
public void hasMipmap() {
    Bitmap bitmap = Bitmap.createBitmap(100, 200, Bitmap.Config.ARGB_8888);
    assertThat(bitmap.hasMipMap()).isFalse();
    bitmap.setHasMipMap(true);
    assertThat(bitmap.hasMipMap()).isTrue();
}
Also used : Bitmap(android.graphics.Bitmap) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 29 with Config

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

the class ShadowViewTest method getWindowId_shouldReturnValidObjectWhenAttached.

@Test
@Config(minSdk = JELLY_BEAN_MR2)
public void getWindowId_shouldReturnValidObjectWhenAttached() throws Exception {
    MyView parent = new MyView("parent", transcript);
    MyView child = new MyView("child", transcript);
    parent.addView(child);
    assertThat(parent.getWindowId()).isNull();
    assertThat(child.getWindowId()).isNull();
    Activity activity = Robolectric.buildActivity(ContentViewActivity.class).create().get();
    activity.getWindowManager().addView(parent, new WindowManager.LayoutParams(100, 100));
    WindowId windowId = parent.getWindowId();
    assertThat(windowId).isNotNull();
    assertThat(child.getWindowId()).isSameAs(windowId);
    // equals must work!
    assertThat(child.getWindowId()).isEqualTo(windowId);
    MyView anotherChild = new MyView("another child", transcript);
    parent.addView(anotherChild);
    assertThat(anotherChild.getWindowId()).isEqualTo(windowId);
    parent.removeView(anotherChild);
    assertThat(anotherChild.getWindowId()).isNull();
}
Also used : Robolectric.buildActivity(org.robolectric.Robolectric.buildActivity) Activity(android.app.Activity) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 30 with Config

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

the class ShadowTimeTest method shouldParseRfc3339_withQuestionableFormat.

@Test
@Config(maxSdk = KITKAT)
public // this fails on LOLLIPOP+; is the shadow impl of parse3339 correct for pre-LOLLIPOP?
void shouldParseRfc3339_withQuestionableFormat() {
    for (String tz : Arrays.asList("Europe/Berlin", "America/Los Angeles", "Australia/Adelaide")) {
        String desc = "Eval when local timezone is " + tz;
        TimeZone.setDefault(TimeZone.getTimeZone(tz));
        Time t = new Time("Europe/Berlin");
        assertTrue(desc, t.parse3339("2008-10-13T16:30:50.999-03"));
        assertEquals(desc, 2008, t.year);
        assertEquals(desc, 9, t.month);
        assertEquals(desc, 13, t.monthDay);
        assertEquals(desc, 19, t.hour);
        assertEquals(desc, 30, t.minute);
        assertEquals(desc, 50, t.second);
        assertEquals(desc, "UTC", t.timezone);
        assertFalse(desc, t.allDay);
    }
}
Also used : Time(android.text.format.Time) 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