Search in sources :

Example 31 with Config

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

the class ParameterizedRobolectricTestRunnerClassLoaderTest method parse.

@Test
@Config(manifest = Config.NONE)
public void parse() {
    Uri currentUri = Uri.parse("http://host/");
    assertThat(currentUri).isEqualTo(uri);
}
Also used : Uri(android.net.Uri) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 32 with Config

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

the class ShadowPackageManagerTest method getServiceInfo_shouldThrowNameNotFoundExceptionIfNotExist.

@Test(expected = PackageManager.NameNotFoundException.class)
@Config(manifest = "src/test/resources/TestPackageManagerGetServiceInfo.xml")
public void getServiceInfo_shouldThrowNameNotFoundExceptionIfNotExist() throws Exception {
    ComponentName nonExistComponent = new ComponentName("org.robolectric", "com.foo.NonExistService");
    try {
        shadowPackageManager.getServiceInfo(nonExistComponent, PackageManager.GET_SERVICES);
        fail("should have thrown NameNotFoundException");
    } catch (PackageManager.NameNotFoundException e) {
        assertThat(e.getMessage()).contains("com.foo.NonExistService");
        throw e;
    }
}
Also used : PackageManager(android.content.pm.PackageManager) ComponentName(android.content.ComponentName) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 33 with Config

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

the class ShadowPackageManagerTest method getServiceInfo_shouldReturnServiceInfoIfExists.

@Test
@Config(manifest = "src/test/resources/TestPackageManagerGetServiceInfo.xml")
public void getServiceInfo_shouldReturnServiceInfoIfExists() throws Exception {
    ServiceInfo serviceInfo = shadowPackageManager.getServiceInfo(new ComponentName("org.robolectric", "com.foo.Service"), PackageManager.GET_SERVICES);
    assertEquals(serviceInfo.packageName, "org.robolectric");
    assertEquals(serviceInfo.name, "com.foo.Service");
    assertEquals(serviceInfo.permission, "com.foo.MY_PERMISSION");
    assertNotNull(serviceInfo.applicationInfo);
}
Also used : ComponentName(android.content.ComponentName) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 34 with Config

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

the class ShadowPackageManagerTest method getServiceInfo_shouldReturnServiceInfoWithoutMetaDataWhenFlagsNotSet.

@Test
@Config(manifest = "src/test/resources/TestPackageManagerGetServiceInfo.xml")
public void getServiceInfo_shouldReturnServiceInfoWithoutMetaDataWhenFlagsNotSet() throws Exception {
    ServiceInfo serviceInfo = shadowPackageManager.getServiceInfo(new ComponentName("org.robolectric", "com.foo.Service"), PackageManager.GET_SERVICES);
    assertNull(serviceInfo.metaData);
}
Also used : ComponentName(android.content.ComponentName) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 35 with Config

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

the class ShadowPackageManagerTest method queryIntentActivities_EmptyResultWithNoMatchingImplicitIntents.

@Test
@Config(manifest = "src/test/resources/TestAndroidManifestForActivitiesWithIntentFilterWithData.xml")
public void queryIntentActivities_EmptyResultWithNoMatchingImplicitIntents() throws Exception {
    Intent i = new Intent(Intent.ACTION_MAIN, null);
    i.addCategory(Intent.CATEGORY_LAUNCHER);
    shadowPackageManager.setQueryIntentImplicitly(true);
    List<ResolveInfo> activities = shadowPackageManager.queryIntentActivities(i, 0);
    assertThat(activities).isEmpty();
}
Also used : Intent(android.content.Intent) 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