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