Skip to content

Commit

Permalink
Merge pull request robolectric#245 from shazam/shazam_abstract_cursor…
Browse files Browse the repository at this point in the history
…_close

Added close method to AbtractCursor shadow
  • Loading branch information
tylerschultz committed May 14, 2012
2 parents bd35e26 + 605fe2e commit d50f87b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Expand Up @@ -25,6 +25,7 @@ public class ShadowAbstractCursor {
protected Map<Integer, Map<String, Object>> rows = new HashMap<Integer, Map<String, Object>>();
protected int rowCount;
protected Uri notificationUri;
protected boolean mClosed;

@Implementation
public int getCount() {
Expand Down Expand Up @@ -154,11 +155,23 @@ public void setNotificationUri(ContentResolver cr, Uri notifyUri) {
notificationUri = notifyUri;
}

/**
@Implementation
public boolean isClosed() {
return mClosed;
}

@Implementation
public void close() {
mClosed = true;
}

/**
* Returns the Uri set by {@code setNotificationUri()}. Method included for testing
* pre-API 11 projects.
*/
public Uri getNotificationUri_Compatibility() {
return notificationUri;
}


}
Expand Up @@ -219,6 +219,12 @@ public void testGetNotificationUri() {
assertThat(shadow.getNotificationUri_Compatibility(), is(uri));
}

@Test
public void testIsClosedWhenAfterCallingClose() {
assertThat(cursor.isClosed(), equalTo(false));
cursor.close();
assertThat(cursor.isClosed(), equalTo(true));
}

private class TestCursor extends AbstractCursor {

Expand Down

0 comments on commit d50f87b

Please sign in to comment.