Add unit test for startManagingCursor/stopManagingCursor
diff --git a/src/test/java/com/xtremelabs/robolectric/shadows/ActivityTest.java b/src/test/java/com/xtremelabs/robolectric/shadows/ActivityTest.java
index d26ae96..d5b8376 100644
--- a/src/test/java/com/xtremelabs/robolectric/shadows/ActivityTest.java
+++ b/src/test/java/com/xtremelabs/robolectric/shadows/ActivityTest.java
@@ -3,11 +3,13 @@
import android.app.Activity;
import android.app.Dialog;
import android.appwidget.AppWidgetProvider;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.SharedPreferences;
+import android.content.*;
import android.content.pm.ActivityInfo;
+import android.database.CharArrayBuffer;
+import android.database.ContentObserver;
+import android.database.Cursor;
+import android.database.DataSetObserver;
+import android.database.sqlite.SQLiteCursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
@@ -429,6 +431,28 @@
Integer storedValue = (Integer) activity.getLastNonConfigurationInstance();
assertEquals(5, storedValue.intValue());
}
+
+ @Test
+ public void startAndStopManagingCursorTracksCursors() throws Exception {
+ TestActivity activity = new TestActivity();
+
+ ShadowActivity shadow = shadowOf(activity);
+
+ assertThat( shadow.getManagedCursors(), notNullValue() );
+ assertThat( shadow.getManagedCursors().size(), equalTo(0) );
+
+ Cursor c = Robolectric.newInstanceOf(SQLiteCursor.class);
+ activity.startManagingCursor(c);
+
+ assertThat( shadow.getManagedCursors(), notNullValue() );
+ assertThat( shadow.getManagedCursors().size(), equalTo(1) );
+ assertThat( shadow.getManagedCursors().get(0), sameInstance(c) );
+
+ activity.stopManagingCursor(c);
+
+ assertThat( shadow.getManagedCursors(), notNullValue() );
+ assertThat( shadow.getManagedCursors().size(), equalTo(0) );
+ }
private static class TestActivity extends Activity {
Transcript transcript = new Transcript();