From 12d5c5c7b49bba5bf884f5a6c5d909104c3b5b80 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Sat, 7 Nov 2015 09:40:44 +1100 Subject: [PATCH] Format to make checkstyle happy. Remove unused code. --- .../src/org/fdroid/fdroid/RepoPersister.java | 24 +++--- .../fdroid/FDroidTestWithAllProviders.java | 23 ------ .../fdroid/fdroid/MultiRepoUpdaterTest.java | 81 +++++++++---------- .../test/src/org/fdroid/fdroid/TestUtils.java | 58 ++++++------- 4 files changed, 75 insertions(+), 111 deletions(-) delete mode 100644 F-Droid/test/src/org/fdroid/fdroid/FDroidTestWithAllProviders.java diff --git a/F-Droid/src/org/fdroid/fdroid/RepoPersister.java b/F-Droid/src/org/fdroid/fdroid/RepoPersister.java index 3f82422be..57aba7d34 100644 --- a/F-Droid/src/org/fdroid/fdroid/RepoPersister.java +++ b/F-Droid/src/org/fdroid/fdroid/RepoPersister.java @@ -34,13 +34,13 @@ public class RepoPersister { * values changed in the index, some fields should not be updated. Rather, they should be * ignored, because they were explicitly set by the user, and hence can't be automatically * overridden by the index. - * + *

* NOTE: In the future, these attributes will be moved to a join table, so that the app table * is essentially completely transient, and can be nuked at any time. */ private static final String[] APP_FIELDS_TO_IGNORE = { - AppProvider.DataColumns.IGNORE_ALLUPDATES, - AppProvider.DataColumns.IGNORE_THISUPDATE, + AppProvider.DataColumns.IGNORE_ALLUPDATES, + AppProvider.DataColumns.IGNORE_THISUPDATE, }; @NonNull @@ -129,9 +129,9 @@ public class RepoPersister { List toRemove = new ArrayList<>(); final String[] fields = { - ApkProvider.DataColumns.APK_ID, - ApkProvider.DataColumns.VERSION_CODE, - ApkProvider.DataColumns.VERSION, + ApkProvider.DataColumns.APK_ID, + ApkProvider.DataColumns.VERSION_CODE, + ApkProvider.DataColumns.VERSION, }; for (final Repo repo : updatedRepos) { @@ -175,14 +175,14 @@ public class RepoPersister { List operations, int currentCount, int totalUpdateCount) - throws RemoteException, OperationApplicationException { + throws RemoteException, OperationApplicationException { int i = 0; while (i < operations.size()) { int count = Math.min(operations.size() - i, 100); ArrayList o = new ArrayList<>(operations.subList(i, i + count)); UpdateService.sendStatus(context, UpdateService.STATUS_INFO, context.getString( - R.string.status_inserting, - (int) ((double) (currentCount + i) / totalUpdateCount * 100))); + R.string.status_inserting, + (int) ((double) (currentCount + i) / totalUpdateCount * 100))); context.getContentResolver().applyBatch(providerAuthority, o); i += 100; } @@ -193,9 +193,9 @@ public class RepoPersister { */ private List getKnownApks(List apks) { final String[] fields = { - ApkProvider.DataColumns.APK_ID, - ApkProvider.DataColumns.VERSION, - ApkProvider.DataColumns.VERSION_CODE, + ApkProvider.DataColumns.APK_ID, + ApkProvider.DataColumns.VERSION, + ApkProvider.DataColumns.VERSION_CODE, }; return ApkProvider.Helper.knownApks(context, apks, fields); } diff --git a/F-Droid/test/src/org/fdroid/fdroid/FDroidTestWithAllProviders.java b/F-Droid/test/src/org/fdroid/fdroid/FDroidTestWithAllProviders.java deleted file mode 100644 index aad34777a..000000000 --- a/F-Droid/test/src/org/fdroid/fdroid/FDroidTestWithAllProviders.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.fdroid.fdroid; - -import org.fdroid.fdroid.data.AppProvider; - -/** - * Class that makes available all ContentProviders that F-Droid owns. - */ -public abstract class FDroidTestWithAllProviders extends FDroidProviderTest { - - public FDroidTestWithAllProviders(Class providerClass, String providerAuthority) { - super(providerClass, providerAuthority); - } - - @Override - protected String[] getMinimalProjection() { - return new String[] { - AppProvider.DataColumns._ID, - AppProvider.DataColumns.APP_ID, - AppProvider.DataColumns.NAME, - }; - } - -} diff --git a/F-Droid/test/src/org/fdroid/fdroid/MultiRepoUpdaterTest.java b/F-Droid/test/src/org/fdroid/fdroid/MultiRepoUpdaterTest.java index 19c187d68..71c6e43ff 100644 --- a/F-Droid/test/src/org/fdroid/fdroid/MultiRepoUpdaterTest.java +++ b/F-Droid/test/src/org/fdroid/fdroid/MultiRepoUpdaterTest.java @@ -17,7 +17,6 @@ import android.util.Log; import org.fdroid.fdroid.RepoUpdater.UpdateException; import org.fdroid.fdroid.data.Apk; import org.fdroid.fdroid.data.ApkProvider; -import org.fdroid.fdroid.data.App; import org.fdroid.fdroid.data.AppProvider; import org.fdroid.fdroid.data.Repo; import org.fdroid.fdroid.data.RepoProvider; @@ -42,7 +41,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase { private RepoPersister persister; private static final String PUB_KEY = - "3082050b308202f3a003020102020420d8f212300d06092a864886f70d01010b050030363110300e0603" + + "3082050b308202f3a003020102020420d8f212300d06092a864886f70d01010b050030363110300e0603" + "55040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e7365727779" + "6c6f2e636f6d301e170d3135303931323233313632315a170d3433303132383233313632315a30363110" + "300e060355040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e73" + @@ -180,31 +179,31 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase { } private void assertApp2048() { - assertApp("com.uberspot.a2048", new int[]{ 19, 18 }); + assertApp("com.uberspot.a2048", new int[]{19, 18}); } private void assertAppAdaway() { - assertApp("org.adaway", new int[]{ 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 42, 40, 38, 37, 36, 35 }); + assertApp("org.adaway", new int[]{54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 42, 40, 38, 37, 36, 35}); } private void assertAppAdbWireless() { - assertApp("siir.es.adbWireless", new int[]{ 12 }); + assertApp("siir.es.adbWireless", new int[]{12}); } private void assertAppIcsImport() { - assertApp("org.dgtale.icsimport", new int[] { 3, 2 }); + assertApp("org.dgtale.icsimport", new int[]{3, 2}); } /** - * + 2048 (com.uberspot.a2048) - * - Version 1.96 (19) - * - Version 1.95 (18) - * + AdAway (org.adaway) - * - Version 3.0.2 (54) - * - Version 3.0.1 (53) - * - Version 3.0 (52) - * + adbWireless (siir.es.adbWireless) - * - Version 1.5.4 (12) + * + 2048 (com.uberspot.a2048) + * - Version 1.96 (19) + * - Version 1.95 (18) + * + AdAway (org.adaway) + * - Version 3.0.2 (54) + * - Version 3.0.1 (53) + * - Version 3.0 (52) + * + adbWireless (siir.es.adbWireless) + * - Version 1.5.4 (12) */ private void assertMainRepo(List allRepos) { Repo repo = findRepo(REPO_MAIN, allRepos); @@ -217,38 +216,38 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase { } /** - * + AdAway (org.adaway) - * - Version 2.9.2 (51) - * - Version 2.9.1 (50) - * - Version 2.9 (49) - * - Version 2.8.1 (48) - * - Version 2.8 (47) - * - Version 2.7 (46) - * - Version 2.6 (45) - * - Version 2.3 (42) - * - Version 2.1 (40) - * - Version 1.37 (38) - * - Version 1.36 (37) - * - Version 1.35 (36) - * - Version 1.34 (35) + * + AdAway (org.adaway) + * - Version 2.9.2 (51) + * - Version 2.9.1 (50) + * - Version 2.9 (49) + * - Version 2.8.1 (48) + * - Version 2.8 (47) + * - Version 2.7 (46) + * - Version 2.6 (45) + * - Version 2.3 (42) + * - Version 2.1 (40) + * - Version 1.37 (38) + * - Version 1.36 (37) + * - Version 1.35 (36) + * - Version 1.34 (35) */ private void assertMainArchiveRepo(List allRepos) { Repo repo = findRepo(REPO_ARCHIVE, allRepos); List apks = ApkProvider.Helper.findByRepo(context, repo, ApkProvider.DataColumns.ALL); assertEquals("Apks for main archive repo", 13, apks.size()); - assertApksExist(apks, "org.adaway", new int[] { 35, 36, 37, 38, 40, 42, 45, 46, 47, 48, 49, 50, 51 }); + assertApksExist(apks, "org.adaway", new int[]{35, 36, 37, 38, 40, 42, 45, 46, 47, 48, 49, 50, 51}); } /** * + AdAway (org.adaway) - * - Version 3.0.1 (53) * - * - Version 3.0 (52) * - * - Version 2.9.2 (51) * - * - Version 2.2.1 (50) * + * - Version 3.0.1 (53) * + * - Version 3.0 (52) * + * - Version 2.9.2 (51) * + * - Version 2.2.1 (50) * * + Add to calendar (org.dgtale.icsimport) - * - Version 1.2 (3) - * - Version 1.1 (2) + * - Version 1.2 (3) + * - Version 1.1 (2) */ private void assertConflictingRepo(List allRepos) { Repo repo = findRepo(REPO_CONFLICTING, allRepos); @@ -294,9 +293,9 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase { assertEquals("No apps present", 0, AppProvider.Helper.all(context.getContentResolver()).size()); String[] packages = { - "com.uberspot.a2048", - "org.adaway", - "siir.es.adbWireless", + "com.uberspot.a2048", + "org.adaway", + "siir.es.adbWireless", }; for (String id : packages) { @@ -308,7 +307,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase { persister.save(new ArrayList(0)); } - /* At time fo writing, the following tests did not pass. This is because the multi-repo support + /* At time fo writing, the following tests did not pass. This is because the multi-repo support in F-Droid was not sufficient. When working on proper multi repo support than this should be ucommented and all these tests should pass: @@ -360,7 +359,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase { } } - */ + */ public void testAcceptableConflictingThenMainThenArchive() throws UpdateException { assertEmpty(); diff --git a/F-Droid/test/src/org/fdroid/fdroid/TestUtils.java b/F-Droid/test/src/org/fdroid/fdroid/TestUtils.java index 21b673bda..0869383de 100644 --- a/F-Droid/test/src/org/fdroid/fdroid/TestUtils.java +++ b/F-Droid/test/src/org/fdroid/fdroid/TestUtils.java @@ -68,10 +68,10 @@ public class TestUtils { if (actualList.size() != expectedContains.size()) { String message = "List sizes don't match.\n" + - "Expected: " + - listToString(expectedContains) + "\n" + - "Actual: " + - listToString(actualList); + "Expected: " + + listToString(expectedContains) + "\n" + + "Actual: " + + listToString(actualList); throw new AssertionFailedError(message); } for (T required : expectedContains) { @@ -85,10 +85,10 @@ public class TestUtils { if (!containsRequired) { String message = "List doesn't contain \"" + required + "\".\n" + - "Expected: " + - listToString(expectedContains) + "\n" + - "Actual: " + - listToString(actualList); + "Expected: " + + listToString(expectedContains) + "\n" + + "Actual: " + + listToString(actualList); throw new AssertionFailedError(message); } } @@ -151,8 +151,8 @@ public class TestUtils { * "installed apps" table in the database. */ public static void installAndBroadcast( - MockContextSwappableComponents context, MockInstallablePackageManager pm, - String appId, int versionCode, String versionName) { + MockContextSwappableComponents context, MockInstallablePackageManager pm, + String appId, int versionCode, String versionName) { context.setPackageManager(pm); pm.install(appId, versionCode, versionName); @@ -166,8 +166,8 @@ public class TestUtils { * @see org.fdroid.fdroid.TestUtils#installAndBroadcast(mock.MockContextSwappableComponents, mock.MockInstallablePackageManager, String, int, String) */ public static void upgradeAndBroadcast( - MockContextSwappableComponents context, MockInstallablePackageManager pm, - String appId, int versionCode, String versionName) { + MockContextSwappableComponents context, MockInstallablePackageManager pm, + String appId, int versionCode, String versionName) { /* removeAndBroadcast(context, pm, appId); installAndBroadcast(context, pm, appId, versionCode, versionName); @@ -214,18 +214,6 @@ public class TestUtils { return tempFile; } - public static File getWriteableDir(Context context) { - File[] dirsToTry = new File[] { - context.getCacheDir(), - context.getFilesDir(), - context.getExternalCacheDir(), - context.getExternalFilesDir(null), - Environment.getExternalStorageDirectory() - }; - - return getWriteableDir(dirsToTry); - } - /** * Prefer internal over external storage, because external tends to be FAT filesystems, * which don't support symlinks (which we test using this method). @@ -235,21 +223,21 @@ public class TestUtils { Context targetContext = instrumentation.getTargetContext(); - File[] dirsToTry = new File[] { - context.getCacheDir(), - context.getFilesDir(), - targetContext.getCacheDir(), - targetContext.getFilesDir(), - context.getExternalCacheDir(), - context.getExternalFilesDir(null), - targetContext.getExternalCacheDir(), - targetContext.getExternalFilesDir(null), - Environment.getExternalStorageDirectory() + File[] dirsToTry = new File[]{ + context.getCacheDir(), + context.getFilesDir(), + targetContext.getCacheDir(), + targetContext.getFilesDir(), + context.getExternalCacheDir(), + context.getExternalFilesDir(null), + targetContext.getExternalCacheDir(), + targetContext.getExternalFilesDir(null), + Environment.getExternalStorageDirectory(), }; return getWriteableDir(dirsToTry); } - + private static File getWriteableDir(File[] dirsToTry) { for (File dir : dirsToTry) {