use of io.github.hidroh.materialistic.data.TestHnItem in project materialistic by hidroh.
the class BaseListActivityLandTest method testRotate.
@Test
public void testRotate() {
activity.onItemSelected(new TestHnItem(1L) {
@Override
public String getDisplayedTitle() {
return "item title";
}
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
});
assertThat(activity).hasTitle("item title");
Bundle savedState = new Bundle();
activity.onSaveInstanceState(savedState);
RuntimeEnvironment.setQualifiers("");
controller = Robolectric.buildActivity(TestListActivity.class);
activity = controller.create(savedState).postCreate(null).start().resume().get();
assertThat(activity).hasTitle(activity.getString(R.string.title_activity_list));
savedState = new Bundle();
activity.onSaveInstanceState(savedState);
RuntimeEnvironment.setQualifiers("w820dp-land");
controller = Robolectric.buildActivity(TestListActivity.class);
activity = controller.create(savedState).postCreate(null).start().resume().get();
assertThat(activity).hasTitle("item title");
assertTrue(((ShadowFloatingActionButton) ShadowExtractor.extract(activity.findViewById(R.id.reply_button))).isVisible());
}
use of io.github.hidroh.materialistic.data.TestHnItem in project materialistic by hidroh.
the class FavoriteActivityTest method testClearClearSelection.
@Test
public void testClearClearSelection() {
activity.onItemSelected(new TestHnItem(1L));
shadowOf(shadowOf(activity.getContentResolver()).getContentObservers(MaterialisticProvider.URI_FAVORITE).iterator().next()).dispatchChange(false, MaterialisticProvider.URI_FAVORITE.buildUpon().appendPath("clear").build());
assertNull(activity.getSelectedItem());
}
use of io.github.hidroh.materialistic.data.TestHnItem in project materialistic by hidroh.
the class FavoriteActivityTest method testRemoveClearSelection.
@Test
public void testRemoveClearSelection() {
ShadowContentObserver observer = shadowOf(shadowOf(activity.getContentResolver()).getContentObservers(MaterialisticProvider.URI_FAVORITE).iterator().next());
observer.dispatchChange(false, MaterialisticProvider.URI_FAVORITE.buildUpon().appendPath("remove").appendPath("3").build());
assertNull(activity.getSelectedItem());
activity.onItemSelected(new TestHnItem(1L));
observer.dispatchChange(false, MaterialisticProvider.URI_FAVORITE.buildUpon().appendPath("remove").appendPath("2").build());
assertNotNull(activity.getSelectedItem());
observer.dispatchChange(false, MaterialisticProvider.URI_FAVORITE.buildUpon().appendPath("remove").appendPath("1").build());
assertNull(activity.getSelectedItem());
}
use of io.github.hidroh.materialistic.data.TestHnItem in project materialistic by hidroh.
the class AppUtilsTest method testOpenExternalUrlNoConnection.
@Test
public void testOpenExternalUrlNoConnection() {
shadowOf((ConnectivityManager) RuntimeEnvironment.application.getSystemService(Context.CONNECTIVITY_SERVICE)).setActiveNetworkInfo(null);
AppUtils.openWebUrlExternal(RuntimeEnvironment.application, new TestHnItem(1L) {
@Override
public String getUrl() {
return "http://example.com";
}
}, "http://example.com", null);
assertThat(shadowOf(RuntimeEnvironment.application).getNextStartedActivity()).hasComponent(RuntimeEnvironment.application, OfflineWebActivity.class).hasExtra(OfflineWebActivity.EXTRA_URL, "http://example.com");
}
use of io.github.hidroh.materialistic.data.TestHnItem in project materialistic by hidroh.
the class BaseListActivityLandTest method testDefaultCommentView.
@Test
public void testDefaultCommentView() {
PreferenceManager.getDefaultSharedPreferences(activity).edit().putString(activity.getString(R.string.pref_story_display), activity.getString(R.string.pref_story_display_value_comments)).apply();
controller.pause().resume();
activity.onItemSelected(new TestHnItem(1L) {
@Override
public String getId() {
return "1";
}
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
});
assertCommentMode();
activity.findViewById(R.id.reply_button).performClick();
assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, ComposeActivity.class);
}
Aggregations