Search in sources :

Example 1 with TestContentProvider1

use of org.robolectric.shadows.testing.TestContentProvider1 in project robolectric by robolectric.

the class ContentProviderControllerTest method create_shouldCallOnCreate.

@Test
public void create_shouldCallOnCreate() throws Exception {
    TestContentProvider1 myContentProvider = controller.create().get();
    assertThat(myContentProvider.transcript).containsExactly("onCreate");
}
Also used : TestContentProvider1(org.robolectric.shadows.testing.TestContentProvider1) Test(org.junit.Test)

Example 2 with TestContentProvider1

use of org.robolectric.shadows.testing.TestContentProvider1 in project robolectric by robolectric.

the class ContentProviderControllerTest method shouldInitializeFromManifestProviderInfo.

@Test
public void shouldInitializeFromManifestProviderInfo() throws Exception {
    TestContentProvider1 myContentProvider = controller.create().get();
    assertThat(myContentProvider.getReadPermission()).isEqualTo("READ_PERMISSION");
    assertThat(myContentProvider.getWritePermission()).isEqualTo("WRITE_PERMISSION");
    assertThat(myContentProvider.getPathPermissions()).hasLength(1);
    PathPermission pathPermission = myContentProvider.getPathPermissions()[0];
    assertThat(pathPermission.getPath()).isEqualTo("/path/*");
    assertThat(pathPermission.getType()).isEqualTo(PathPermission.PATTERN_SIMPLE_GLOB);
    assertThat(pathPermission.getReadPermission()).isEqualTo("PATH_READ_PERMISSION");
    assertThat(pathPermission.getWritePermission()).isEqualTo("PATH_WRITE_PERMISSION");
}
Also used : PathPermission(android.content.pm.PathPermission) TestContentProvider1(org.robolectric.shadows.testing.TestContentProvider1) Test(org.junit.Test)

Example 3 with TestContentProvider1

use of org.robolectric.shadows.testing.TestContentProvider1 in project robolectric by robolectric.

the class ShadowContentProviderTest method testSetCallingPackage.

@Config(minSdk = KITKAT)
@Test
public void testSetCallingPackage() {
    ContentProvider provider = new TestContentProvider1();
    shadowOf(provider).setCallingPackage("calling-package");
    assertThat(provider.getCallingPackage()).isEqualTo("calling-package");
}
Also used : ContentProvider(android.content.ContentProvider) TestContentProvider1(org.robolectric.shadows.testing.TestContentProvider1) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 4 with TestContentProvider1

use of org.robolectric.shadows.testing.TestContentProvider1 in project robolectric by robolectric.

the class ContentProviderControllerTest method whenNoProviderManifestEntryFound_shouldStillInitialize.

@Test
public void whenNoProviderManifestEntryFound_shouldStillInitialize() throws Exception {
    TestContentProvider1 myContentProvider = Robolectric.buildContentProvider(NotInManifestContentProvider.class).create().get();
    assertThat(myContentProvider.getReadPermission()).isNull();
    assertThat(myContentProvider.getWritePermission()).isNull();
    assertThat(myContentProvider.getPathPermissions()).isNull();
}
Also used : TestContentProvider1(org.robolectric.shadows.testing.TestContentProvider1) Test(org.junit.Test)

Example 5 with TestContentProvider1

use of org.robolectric.shadows.testing.TestContentProvider1 in project robolectric by robolectric.

the class ContentProviderControllerTest method shutdown_shouldCallShutdown.

@Test
public void shutdown_shouldCallShutdown() throws Exception {
    TestContentProvider1 myContentProvider = controller.shutdown().get();
    assertThat(myContentProvider.transcript).containsExactly("shutdown");
}
Also used : TestContentProvider1(org.robolectric.shadows.testing.TestContentProvider1) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 TestContentProvider1 (org.robolectric.shadows.testing.TestContentProvider1)6 ContentProvider (android.content.ContentProvider)1 PathPermission (android.content.pm.PathPermission)1 Config (org.robolectric.annotation.Config)1