use of android.content.ContentResolver in project storio by pushtorefresh.
the class DefaultStorIOContentResolverTest method defaultSchedulerReturnsNullIfSpecifiedSchedulerNull.
@Test
public void defaultSchedulerReturnsNullIfSpecifiedSchedulerNull() {
StorIOContentResolver storIOContentResolver = DefaultStorIOContentResolver.builder().contentResolver(mock(ContentResolver.class)).defaultScheduler(null).build();
assertThat(storIOContentResolver.defaultScheduler()).isNull();
}
use of android.content.ContentResolver 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");
}
use of android.content.ContentResolver in project roboguice by roboguice.
the class DefaultRoboModule method providesAndroidId.
@Provides
@Named(Settings.Secure.ANDROID_ID)
public String providesAndroidId() {
String androidId = null;
final ContentResolver contentResolver = application.getContentResolver();
try {
androidId = Secure.getString(contentResolver, Secure.ANDROID_ID);
} catch (RuntimeException e) {
// ignore Stub! errors for Secure.getString() when mocking in test cases since there's no way to mock static methods
Log.e(DefaultRoboModule.class.getName(), "Impossible to get the android device Id. This may fail 'normally' when testing.", e);
}
if (!"".equals(androidId)) {
return androidId;
} else {
throw new RuntimeException("No Android Id.");
}
}
use of android.content.ContentResolver in project mechanoid by robotoworks.
the class AuthorsRecord method get.
public static AuthorsRecord get(long id) {
Cursor c = null;
ContentResolver resolver = Mechanoid.getContentResolver();
try {
c = resolver.query(Authors.CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).build(), PROJECTION, null, null, null);
if (!c.moveToFirst()) {
return null;
}
return fromCursor(c);
} finally {
Closeables.closeSilently(c);
}
}
use of android.content.ContentResolver in project mechanoid by robotoworks.
the class IngredientsRecord method get.
public static IngredientsRecord get(long id) {
Cursor c = null;
ContentResolver resolver = Mechanoid.getContentResolver();
try {
c = resolver.query(Ingredients.CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).build(), PROJECTION, null, null, null);
if (!c.moveToFirst()) {
return null;
}
return fromCursor(c);
} finally {
Closeables.closeSilently(c);
}
}
Aggregations