Javadoc for test case classes
Change-Id: Ibfa035cfe9091a81fca8bd0a6c141ec26c2de139
diff --git a/test-runner/src/android/test/mock/MockContentResolver.java b/test-runner/src/android/test/mock/MockContentResolver.java
index 3a1dc36c..ab511f8 100644
--- a/test-runner/src/android/test/mock/MockContentResolver.java
+++ b/test-runner/src/android/test/mock/MockContentResolver.java
@@ -28,29 +28,59 @@
import java.util.Map;
/**
- * A mock {@link android.content.ContentResolver} class that isolates the test code from the real
- * content system. All methods are non-functional and throw
- * {@link java.lang.UnsupportedOperationException}.
- *
- * <p>This only isolates the test code in ways that have proven useful so far. More should be
- * added as they become a problem.
+ * <p>
+ * An extension of {@link android.content.ContentResolver} that is designed for
+ * testing.
+ * </p>
+ * <p>
+ * MockContentResolver overrides Android's normal way of resolving providers by
+ * authority. To have access to a provider based on its authority, users of
+ * MockContentResolver first instantiate the provider and
+ * use {@link MockContentResolver#addProvider(String, ContentProvider)}. Resolution of an
+ * authority occurs entirely within MockContentResolver.
+ * </p>
+ * <p>
+ * Users can also set an authority's entry in the map to null, so that a provider is completely
+ * mocked out.
+ * </p>
*/
+
public class MockContentResolver extends ContentResolver {
Map<String, ContentProvider> mProviders;
+ /*
+ * Creates a local map of providers. This map is used instead of the global map when an
+ * API call tries to acquire a provider.
+ */
public MockContentResolver() {
super(null);
mProviders = Maps.newHashMap();
}
+ /**
+ * Adds access to a provider based on its authority
+ *
+ * @param name The authority name associated with the provider.
+ * @param provider An instance of {@link android.content.ContentProvider} or one of its
+ * subclasses, or null.
+ */
public void addProvider(String name, ContentProvider provider) {
+
+ /*
+ * Maps the authority to the provider locally.
+ */
mProviders.put(name, provider);
}
/** @hide */
@Override
protected IContentProvider acquireProvider(Context context, String name) {
+
+ /*
+ * Gets the content provider from the local map
+ */
final ContentProvider provider = mProviders.get(name);
+
if (provider != null) {
return provider.getIContentProvider();
} else {
@@ -64,7 +94,18 @@
return true;
}
+ /**
+ * Overrides {@link android.content.ContentResolver#notifyChange(Uri, ContentObserver, boolean)
+ * ContentResolver.notifChange(Uri, ContentObserver, boolean)}. All parameters are ignored.
+ * The method hides providers linked to MockContentResolver from other observers in the system.
+ *
+ * @param uri (Ignored) The uri of the content provider.
+ * @param observer (Ignored) The observer that originated the change.
+ * @param syncToNetwork (Ignored) If true, attempt to sync the change to the network.
+ */
@Override
- public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) {
+ public void notifyChange(Uri uri,
+ ContentObserver observer,
+ boolean syncToNetwork) {
}
}