use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.
the class DefaultStorIOContentResolverTest method defaultRxSchedulerReturnsNullIfSpecifiedSchedulerNull.
@Test
public void defaultRxSchedulerReturnsNullIfSpecifiedSchedulerNull() {
StorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(mock(ContentResolver.class)).defaultRxScheduler(null).build();
assertThat(storIOContentResolver.defaultRxScheduler()).isNull();
}
use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.
the class DefaultStorIOContentResolverTest method shouldUseCustomHandlerForContentObservers.
@Test
public void shouldUseCustomHandlerForContentObservers() {
ContentResolver contentResolver = mock(ContentResolver.class);
ArgumentCaptor<ContentObserver> observerArgumentCaptor = ArgumentCaptor.forClass(ContentObserver.class);
doNothing().when(contentResolver).registerContentObserver(any(Uri.class), anyBoolean(), observerArgumentCaptor.capture());
Handler handler = mock(Handler.class);
StorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(contentResolver).contentObserverHandler(handler).defaultRxScheduler(null).build();
Disposable disposable = storIOContentResolver.observeChangesOfUri(mock(Uri.class), LATEST).subscribe();
assertThat(observerArgumentCaptor.getAllValues()).hasSize(1);
ContentObserver contentObserver = observerArgumentCaptor.getValue();
Object actualHandler = ReflectionHelpers.getField(contentObserver, "mHandler");
assertThat(actualHandler).isEqualTo(handler);
disposable.dispose();
}
use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.
the class DefaultStorIOContentResolverTest method shouldReturnSameContentResolver.
@Test
public void shouldReturnSameContentResolver() {
ContentResolver contentResolver = mock(ContentResolver.class);
StorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(contentResolver).build();
assertThat(storIOContentResolver.lowLevel().contentResolver()).isSameAs(contentResolver);
}
use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.
the class DefaultStorIOContentResolverTest method shouldThrowExceptionIfContentResolverReturnsNull.
@Test
public void shouldThrowExceptionIfContentResolverReturnsNull() {
ContentResolver contentResolver = mock(ContentResolver.class);
StorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(contentResolver).build();
Query query = Query.builder().uri(mock(Uri.class)).build();
when(contentResolver.query(any(Uri.class), any(String[].class), anyString(), any(String[].class), anyString())).thenReturn(// Notice, we return null instead of Cursor
null);
try {
storIOContentResolver.lowLevel().query(query);
} catch (IllegalStateException expected) {
assertThat(expected).hasMessage("Cursor returned by content provider is null");
}
}
use of com.pushtorefresh.storio3.contentresolver.StorIOContentResolver in project storio by pushtorefresh.
the class DefaultStorIOContentResolverTest method deprecatedInternalImplShouldReturnSentToConstructorTypeMapping.
@Test
public void deprecatedInternalImplShouldReturnSentToConstructorTypeMapping() throws NoSuchFieldException, IllegalAccessException {
ContentResolver contentResolver = mock(ContentResolver.class);
TypeMappingFinder typeMappingFinder = mock(TypeMappingFinder.class);
TestDefaultStorIOContentResolver storIOContentResolver = new TestDefaultStorIOContentResolver(contentResolver, mock(Handler.class), typeMappingFinder);
assertThat(storIOContentResolver.typeMappingFinder()).isSameAs(typeMappingFinder);
}
Aggregations