convert SwapRepoTest into initial UpdateServiceTest

Finally, there can be a test for running UpdateService, which is essential
and has some really hairy code in it.  At least swap has been removed from
there.  This is barebones still, but it now can be developed to test quite
a bit of what is still needed in UpdateService.
This commit is contained in:
Hans-Christoph Steiner
2022-12-01 17:38:39 +01:00
parent d19c5028ac
commit 3fa5e98fc4
5 changed files with 103 additions and 75 deletions

View File

@@ -24,8 +24,6 @@ import org.junit.Ignore;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.net.Socket;
import java.security.cert.Certificate;
import java.util.HashSet;
import java.util.List;
@@ -103,7 +101,7 @@ public class SwapRepoEmulatorTest {
assertFalse(TextUtils.isEmpty(signingCert));
assertFalse(TextUtils.isEmpty(fingerprint));
assertTrue(isPortInUse(FDroidApp.ipAddressString, FDroidApp.port));
assertTrue(Utils.isPortInUse(FDroidApp.ipAddressString, FDroidApp.port));
Thread.sleep(100);
File swapJarFile = File.createTempFile("swap", "", context.getCacheDir());
@@ -151,19 +149,6 @@ public class SwapRepoEmulatorTest {
assertFalse(localHttpd.isAlive());
}
private boolean isPortInUse(String host, int port) {
boolean result = false;
try {
(new Socket(host, port)).close();
result = true;
} catch (IOException e) {
// Could not connect.
e.printStackTrace();
}
return result;
}
private boolean isSystemPackage(ResolveInfo resolveInfo) {
return (resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
}