Search in sources :

Example 6 with ShadowContentObserver

use of org.robolectric.shadows.ShadowContentObserver 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());
}
Also used : ShadowContentObserver(org.robolectric.shadows.ShadowContentObserver) TestHnItem(io.github.hidroh.materialistic.data.TestHnItem) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test)

Aggregations

SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)6 Test (org.junit.Test)6 ShadowContentObserver (org.robolectric.shadows.ShadowContentObserver)6 TestHnItem (io.github.hidroh.materialistic.data.TestHnItem)3 Context (android.content.Context)2 Intent (android.content.Intent)2 RecyclerView (android.support.v7.widget.RecyclerView)2 ShadowRecyclerView (io.github.hidroh.materialistic.test.shadow.ShadowRecyclerView)2 TargetApi (android.annotation.TargetApi)1 View (android.view.View)1 PopupMenu (android.widget.PopupMenu)1 TextView (android.widget.TextView)1 RoboMenuItem (org.robolectric.fakes.RoboMenuItem)1 ShadowPopupMenu (org.robolectric.shadows.ShadowPopupMenu)1