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();
}
}
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);
}
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();
}
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();
}
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);
}
}
Aggregations