1 package org.robolectric.shadows.support.v4; 2 3 import static com.google.common.truth.Truth.assertThat; 4 5 import android.net.Uri; 6 import android.support.v4.content.CursorLoader; 7 import org.junit.Test; 8 import org.junit.runner.RunWith; 9 import org.robolectric.RuntimeEnvironment; 10 import org.robolectric.util.TestRunnerWithManifest; 11 12 @RunWith(TestRunnerWithManifest.class) 13 public class CursorLoaderTest { 14 @Test 15 public void testGetters() { 16 Uri uri = Uri.parse("http://robolectric.org"); 17 String[] projection = new String[] { "_id", "TestColumn" }; 18 String selection = "_id = ?"; 19 String[] selectionArgs = new String[] { "5" }; 20 String sortOrder = "_id"; 21 CursorLoader cursorLoader = new CursorLoader(RuntimeEnvironment.application, 22 uri, 23 projection, 24 selection, 25 selectionArgs, 26 sortOrder); 27 28 assertThat(cursorLoader.getUri()).isEqualTo(uri); 29 assertThat(cursorLoader.getProjection()).isEqualTo(projection); 30 assertThat(cursorLoader.getSelection()).isEqualTo(selection); 31 assertThat(cursorLoader.getSelectionArgs()).isEqualTo(selectionArgs); 32 assertThat(cursorLoader.getSortOrder()).isEqualTo(sortOrder); 33 } 34 35 @Test 36 public void testSetters() { 37 Uri uri = Uri.parse("http://robolectric.org"); 38 String[] projection = new String[] { "_id", "TestColumn" }; 39 String selection = "_id = ?"; 40 String[] selectionArgs = new String[] { "5" }; 41 String sortOrder = "_id"; 42 CursorLoader cursorLoader = new CursorLoader(RuntimeEnvironment.application); 43 cursorLoader.setUri(uri); 44 cursorLoader.setProjection(projection); 45 cursorLoader.setSelection(selection); 46 cursorLoader.setSelectionArgs(selectionArgs); 47 cursorLoader.setSortOrder(sortOrder); 48 49 assertThat(cursorLoader.getUri()).isEqualTo(uri); 50 assertThat(cursorLoader.getProjection()).isEqualTo(projection); 51 assertThat(cursorLoader.getSelection()).isEqualTo(selection); 52 assertThat(cursorLoader.getSelectionArgs()).isEqualTo(selectionArgs); 53 assertThat(cursorLoader.getSortOrder()).isEqualTo(sortOrder); 54 } 55 } 56