Updated readme with instructions for running tests. Fixed for Andoid-10

Updated the README with details of how to run the tests. Also added a
minor fix to allow tests to run on pre-honeycomb devices. However their
behaviour may not be 100% defined - because the contentproviders are
not shuttind down correctly due to lack of an API to do so.
This commit is contained in:
Peter Serwylo 2015-06-24 16:06:14 +10:00
parent e7912359eb
commit 7c49f03f21
2 changed files with 23 additions and 1 deletions

View File

@ -16,11 +16,13 @@
package android.test; package android.test;
import android.annotation.TargetApi;
import android.content.ContentProvider; import android.content.ContentProvider;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.database.DatabaseUtils; import android.database.DatabaseUtils;
import android.os.Build;
import android.test.mock.MockContentResolver; import android.test.mock.MockContentResolver;
import android.test.mock.MockContext; import android.test.mock.MockContext;
@ -154,10 +156,18 @@ public abstract class ProviderTestCase2MockContext<T extends ContentProvider> ex
*/ */
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
mProvider.shutdown(); shutdownProvider();
super.tearDown(); super.tearDown();
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void shutdownProvider() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mProvider.shutdown();
}
}
/** /**
* Gets the {@link MockContentResolver} created by this class during initialization. You * Gets the {@link MockContentResolver} created by this class during initialization. You
* must use the methods of this resolver to access the provider under test. * must use the methods of this resolver to access the provider under test.

View File

@ -56,6 +56,18 @@ would like to contribute.
Running the test suite Running the test suite
---------------------- ----------------------
In order to run the F-Droid test suite, you will need to have either a real device
connected via `adb`, or an emulator running. Then, execute the following from the
command line:
> `gradle connectedAndroidTest`
This will build and install F-Droid and the test apk, then execute the entire
test suite on the device or emulator.
See the [Android Gradle user guide](http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Testing) for more details, including how to use Android Studio to run tests (which provides
more useful feedback than the command line).
License License
------- -------