Search in sources :

Example 6 with Config

use of org.robolectric.annotation.Config in project android-oss by kickstarter.

the class DateTimeUtilsTest method testRelative_withLocale.

@Test
@Config(qualifiers = "de")
public void testRelative_withLocale() {
    final Context context = context();
    final KSString ksString = ksString();
    final DateTime dateTime = DateTime.parse("2015-12-17T18:35:05Z");
    final RelativeDateTimeOptions.Builder builder = RelativeDateTimeOptions.builder();
    assertEquals("vor 2 Minuten", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T18:37:05Z")).build()));
    assertEquals("in 2 Minuten", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T18:33:05Z")).build()));
}
Also used : Context(android.content.Context) RelativeDateTimeOptions(com.kickstarter.libs.RelativeDateTimeOptions) KSString(com.kickstarter.libs.KSString) DateTime(org.joda.time.DateTime) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 7 with Config

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

the class UserActivityTest method testScrollToTop.

@Config(shadows = ShadowRecyclerView.class)
@Test
public void testScrollToTop() {
    verify(userManager).getUser(eq("username"), userCaptor.capture());
    userCaptor.getValue().onResponse(user);
    RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
    recyclerView.smoothScrollToPosition(1);
    assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(1);
    TabLayout.Tab tab = ((TabLayout) activity.findViewById(R.id.tab_layout)).getTabAt(0);
    tab.select();
    tab.select();
    assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(0);
}
Also used : TabLayout(android.support.design.widget.TabLayout) RecyclerView(android.support.v7.widget.RecyclerView) ShadowRecyclerView(io.github.hidroh.materialistic.test.shadow.ShadowRecyclerView) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 8 with Config

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

the class ResourceLoaderTest method testChoosesLayoutBasedOnSearchPath_respectsOrderOfPath.

@Test
@Config(qualifiers = "doesnotexist-land-xlarge")
public void testChoosesLayoutBasedOnSearchPath_respectsOrderOfPath() throws Exception {
    View view = LayoutInflater.from(RuntimeEnvironment.application).inflate(R.layout.different_screen_sizes, null);
    TextView textView = (TextView) view.findViewById(android.R.id.text1);
    assertThat(textView.getText().toString()).isEqualTo("land");
}
Also used : TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 9 with Config

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

the class ContentProviderControllerTest method shouldRegisterWithContentResolver.

@Test
@Config(manifest = "src/test/resources/TestAndroidManifestWithContentProviders.xml")
public void shouldRegisterWithContentResolver() throws Exception {
    controller.create().get();
    ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
    ContentProviderClient client = contentResolver.acquireContentProviderClient("org.robolectric.authority2");
    client.query(Uri.parse("something"), new String[] { "title" }, "*", new String[] {}, "created");
    assertThat(controller.get().transcript).containsExactly("onCreate", "query for something");
}
Also used : ContentProviderClient(android.content.ContentProviderClient) ContentResolver(android.content.ContentResolver) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 10 with Config

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

the class ContentProviderControllerTest method shouldInitializeFromManifestProviderInfo.

@Test
@Config(manifest = "src/test/resources/TestAndroidManifestWithContentProviders.xml")
public void shouldInitializeFromManifestProviderInfo() throws Exception {
    MyContentProvider myContentProvider = controller.create().get();
    assertThat(myContentProvider.getReadPermission()).isEqualTo("READ_PERMISSION");
    assertThat(myContentProvider.getWritePermission()).isEqualTo("WRITE_PERMISSION");
    assertThat(myContentProvider.getPathPermissions()).hasSize(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) 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