checkstyle: Also check test sources

This commit is contained in:
Daniel Martí 2015-10-09 11:19:41 +02:00
parent 6b573db3f4
commit b60afa2dc0
13 changed files with 548 additions and 548 deletions

View File

@ -190,7 +190,7 @@ android {
task checkstyle(type: Checkstyle) {
configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml")
source 'src'
source 'src', 'test/src'
include '**/*.java'
exclude '**/gen/**'

View File

@ -116,7 +116,7 @@ public abstract class ProviderTestCase2MockContext<T extends ContentProvider> ex
return mProvider;
}
abstract protected Context createMockContext(Context delegate);
protected abstract Context createMockContext(Context delegate);
/**
* Sets up the environment for the test fixture.

View File

@ -21,6 +21,6 @@ public class MockCategoryResources extends MockFDroidResources {
} else {
return "";
}
}
}
}

View File

@ -31,6 +31,6 @@ public class MockFDroidResources extends MockResources {
} else {
return 0;
}
}
}
}

View File

@ -17,13 +17,13 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
public void testKnownApks() {
for (int i = 0; i < 7; i ++)
for (int i = 0; i < 7; i++)
TestUtils.insertApk(this, "org.fdroid.fdroid", i);
for (int i = 0; i < 9; i ++)
for (int i = 0; i < 9; i++)
TestUtils.insertApk(this, "org.example", i);
for (int i = 0; i < 3; i ++)
for (int i = 0; i < 3; i++)
TestUtils.insertApk(this, "com.example", i);
TestUtils.insertApk(this, "com.apk.thingo", 1);
@ -57,7 +57,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
String[] projection = {
ApkProvider.DataColumns.APK_ID,
ApkProvider.DataColumns.VERSION_CODE
ApkProvider.DataColumns.VERSION_CODE,
};
List<Apk> knownApks = ApkProvider.Helper.knownApks(getMockContext(), apksToCheck, projection);
@ -70,13 +70,13 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
public void testFindByApp() {
for (int i = 0; i < 7; i ++)
for (int i = 0; i < 7; i++)
TestUtils.insertApk(this, "org.fdroid.fdroid", i);
for (int i = 0; i < 9; i ++)
for (int i = 0; i < 9; i++)
TestUtils.insertApk(this, "org.example", i);
for (int i = 0; i < 3; i ++)
for (int i = 0; i < 3; i++)
TestUtils.insertApk(this, "com.example", i);
TestUtils.insertApk(this, "com.apk.thingo", 1);
@ -154,7 +154,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
// Insert some random apks either side of the "com.example", so that
// the Helper.find() method doesn't stumble upon the app we are interested
// in by shear dumb luck...
for (int i = 0; i < 10; i ++)
for (int i = 0; i < 10; i++)
TestUtils.insertApk(this, "org.fdroid.apk." + i, i);
ContentValues values = new ContentValues();
@ -164,7 +164,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
TestUtils.insertApk(this, "com.example", 11, values);
// ...and a few more for good measure...
for (int i = 15; i < 20; i ++)
for (int i = 15; i < 20; i++)
TestUtils.insertApk(this, "com.other.thing." + i, i);
Apk apk = ApkProvider.Helper.find(getMockContext(), "com.example", 11);
@ -181,7 +181,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
String[] projection = {
ApkProvider.DataColumns.APK_ID,
ApkProvider.DataColumns.HASH
ApkProvider.DataColumns.HASH,
};
Apk apkLessFields = ApkProvider.Helper.find(getMockContext(), "com.example", 11, projection);

View File

@ -34,7 +34,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
assertInvalidUri(RepoProvider.getContentUri());
List<Apk> apks = new ArrayList<Apk>(3);
for (int i = 0; i < 10; i ++) {
for (int i = 0; i < 10; i++) {
apks.add(new MockApk("com.example." + i, i));
}
@ -47,7 +47,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
assertValidUri(ApkProvider.getRepoUri(1000));
List<Apk> manyApks = new ArrayList<Apk>(PublicApkProvider.MAX_APKS_TO_QUERY - 5);
for (int i = 0; i < PublicApkProvider.MAX_APKS_TO_QUERY - 1; i ++) {
for (int i = 0; i < PublicApkProvider.MAX_APKS_TO_QUERY - 1; i++) {
manyApks.add(new MockApk("com.example." + i, i));
}
assertValidUri(PublicApkProvider.getContentUri(manyApks));
@ -69,7 +69,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
}
public void testAppApks() {
for (int i = 1; i <= 10; i ++) {
for (int i = 1; i <= 10; i++) {
TestUtils.insertApk(this, "org.fdroid.fdroid", i);
TestUtils.insertApk(this, "com.example", i);
}
@ -175,18 +175,18 @@ public class ApkProviderTest extends BaseApkProviderTest {
assertCantDelete(Uri.withAppendedPath(ApkProvider.getContentUri(), "some-random-path"));
}
public void testRepoApks() {
private static final long REPO_KEEP = 1;
private static final long REPO_DELETE = 2;
final long REPO_KEEP = 1;
final long REPO_DELETE = 2;
public void testRepoApks() {
// Insert apks into two repos, one of which we will later purge the
// the apks from.
for (int i = 1; i <= 5; i ++) {
for (int i = 1; i <= 5; i++) {
insertApkForRepo("org.fdroid.fdroid", i, REPO_KEEP);
insertApkForRepo("com.example." + i, 1, REPO_DELETE);
}
for (int i = 6; i <= 10; i ++) {
for (int i = 6; i <= 10; i++) {
insertApkForRepo("org.fdroid.fdroid", i, REPO_DELETE);
insertApkForRepo("com.example." + i, 1, REPO_KEEP);
}
@ -253,9 +253,9 @@ public class ApkProviderTest extends BaseApkProviderTest {
public void testCount() {
String[] projectionFields = getMinimalProjection();
String[] projectionCount = new String[] { ApkProvider.DataColumns._COUNT };
String[] projectionCount = new String[] {ApkProvider.DataColumns._COUNT};
for (int i = 0; i < 13; i ++) {
for (int i = 0; i < 13; i++) {
TestUtils.insertApk(this, "com.example", i);
}
@ -280,7 +280,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
RepoProvider.DataColumns.ADDRESS,
RepoProvider.DataColumns.FINGERPRINT,
RepoProvider.DataColumns.NAME,
RepoProvider.DataColumns.PUBLIC_KEY
RepoProvider.DataColumns.PUBLIC_KEY,
};
for (String field : repoFields) {

View File

@ -38,7 +38,7 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
protected String[] getMinimalProjection() {
return new String[] {
AppProvider.DataColumns.APP_ID,
AppProvider.DataColumns.NAME
AppProvider.DataColumns.NAME,
};
}
@ -56,21 +56,21 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
insertApp("com.example.app100", "App 100");
insertApp("com.example.app1000", "App 1000");
for (int i = 0; i < 50; i ++) {
for (int i = 0; i < 50; i++) {
pm.install("com.example.app" + i, 1, "v" + 1);
}
InstalledAppCacheUpdater.updateInForeground(getMockContext());
assertResultCount(1, AppProvider.getInstalledUri());
for (int i = 50; i < 500; i ++) {
for (int i = 50; i < 500; i++) {
pm.install("com.example.app" + i, 1, "v" + 1);
}
InstalledAppCacheUpdater.updateInForeground(getMockContext());
assertResultCount(2, AppProvider.getInstalledUri());
for (int i = 500; i < 1100; i ++) {
for (int i = 500; i < 1100; i++) {
pm.install("com.example.app" + i, 1, "v" + 1);
}
InstalledAppCacheUpdater.updateInForeground(getMockContext());
@ -109,7 +109,7 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
}
private void insertApps(int count) {
for (int i = 0; i < count; i ++) {
for (int i = 0; i < count; i++) {
insertApp("com.example.test." + i, "Test app " + i);
}
}
@ -207,7 +207,7 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
assertResultCount(10, AppProvider.getContentUri());
String[] projection = { AppProvider.DataColumns.APP_ID };
String[] projection = {AppProvider.DataColumns.APP_ID};
List<App> ignoredApps = AppProvider.Helper.findIgnored(getMockContext(), projection);
String[] expectedIgnored = {
@ -217,7 +217,7 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
// is should only ignore if "ignored version" is >= suggested
"installed, old version, ignore all",
"installed, old version, ignore latest"
"installed, old version, ignore latest",
// NOT "installed, old version, ignore newer, but not latest"
// for the same reason as above.
};
@ -242,7 +242,7 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
assertResultCount(100, AppProvider.getContentUri());
assertResultCount(0, AppProvider.getInstalledUri());
for (int i = 10; i < 20; i ++) {
for (int i = 10; i < 20; i++) {
TestUtils.installAndBroadcast(getSwappableContext(), pm, "com.example.test." + i, i, "v1");
}
@ -305,7 +305,7 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
getMockContext().getResources().getString(R.string.category_All),
"Animal",
"Mineral",
"Vegetable"
"Vegetable",
};
TestUtils.assertContainsOnly(categories, expected);
}
@ -323,7 +323,7 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
"Animal",
"Mineral",
"Vegetable"
"Vegetable",
};
TestUtils.assertContainsOnly(categories, expected);
@ -350,7 +350,7 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
"Blah",
"Test category",
"The quick brown fox jumps over the lazy dog",
"With apostrophe's"
"With apostrophe's",
};
TestUtils.assertContainsOnly(categoriesLonger, expectedLonger);

View File

@ -29,7 +29,7 @@ abstract class BaseApkProviderTest extends FDroidProviderTest<ApkProvider> {
ApkProvider.DataColumns.APK_ID,
ApkProvider.DataColumns.VERSION_CODE,
ApkProvider.DataColumns.NAME,
ApkProvider.DataColumns.REPO_ID
ApkProvider.DataColumns.REPO_ID,
};
}

View File

@ -120,7 +120,7 @@ public abstract class FDroidProviderTest<T extends FDroidProvider> extends Provi
// uris.
getProvider().query(uri, getMinimalProjection(), null, null, null);
fail();
} catch (UnsupportedOperationException e) {}
} catch (UnsupportedOperationException e) { }
}
protected void assertValidUri(Uri uri) {

View File

@ -53,7 +53,7 @@ public class FileCompatTest extends InstrumentationTestCase {
public void testSymlinkOs() {
if (Build.VERSION.SDK_INT >= 21 ) {
if (Build.VERSION.SDK_INT >= 21) {
FileCompatForTest.symlinkOsTest(sourceFile, destFile);
assertTrue(destFile.getAbsolutePath() + " should exist after symlinking", destFile.exists());
} else {

View File

@ -28,7 +28,7 @@ public class InstalledAppCacheTest extends FDroidProviderTest<InstalledAppProvid
@Override
protected String[] getMinimalProjection() {
return new String[] {
InstalledAppProvider.DataColumns.APP_ID
InstalledAppProvider.DataColumns.APP_ID,
};
}

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ public class TestUtils {
public static <T> String listToString(List<T> list) {
String string = "[";
for (int i = 0; i < list.size(); i ++) {
for (int i = 0; i < list.size(); i++) {
if (i > 0) {
string += ", ";
}
@ -220,7 +220,7 @@ public class TestUtils {
Context context = instrumentation.getContext();
Context targetContext = instrumentation.getTargetContext();
File dir = context.getCacheDir();
Log.d(TAG, "Looking for writeable dir, trying context.getCacheDir()" );
Log.d(TAG, "Looking for writeable dir, trying context.getCacheDir()");
if (dir == null || !dir.canWrite()) {
Log.d(TAG, "Looking for writeable dir, trying context.getFilesDir()");
dir = context.getFilesDir();