mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-06-18 12:49:59 -04:00
Add code style to repo and fix it
This commit is contained in:
committed by
Hans-Christoph Steiner
parent
8107e2da73
commit
2048d6f478
@@ -1,7 +1,10 @@
|
||||
package org.fdroid.fdroid;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
@@ -10,8 +13,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class AssetUtils {
|
||||
|
||||
private static final String TAG = "Utils";
|
||||
|
||||
@@ -5,11 +5,13 @@ import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -1,40 +1,5 @@
|
||||
package org.fdroid.fdroid;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.espresso.IdlingPolicies;
|
||||
import androidx.test.espresso.ViewInteraction;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.uiautomator.UiDevice;
|
||||
import androidx.test.uiautomator.UiObject;
|
||||
import androidx.test.uiautomator.UiObjectNotFoundException;
|
||||
import androidx.test.uiautomator.UiSelector;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import org.fdroid.fdroid.views.StatusBanner;
|
||||
import org.fdroid.fdroid.views.main.MainActivity;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.action.ViewActions.swipeDown;
|
||||
@@ -48,11 +13,46 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.espresso.IdlingPolicies;
|
||||
import androidx.test.espresso.ViewInteraction;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
import androidx.test.uiautomator.UiDevice;
|
||||
import androidx.test.uiautomator.UiObject;
|
||||
import androidx.test.uiautomator.UiObjectNotFoundException;
|
||||
import androidx.test.uiautomator.UiSelector;
|
||||
|
||||
import org.fdroid.fdroid.views.StatusBanner;
|
||||
import org.fdroid.fdroid.views.main.MainActivity;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class MainActivityEspressoTest {
|
||||
@@ -68,7 +68,7 @@ public class MainActivityEspressoTest {
|
||||
*/
|
||||
private static boolean canRunEspresso() {
|
||||
if (Build.VERSION.SDK_INT < 25
|
||||
|| (Build.SUPPORTED_ABIS[0].startsWith("arm") && isEmulator())) {
|
||||
|| Build.SUPPORTED_ABIS[0].startsWith("arm") && isEmulator()) {
|
||||
Log.e(TAG, "SKIPPING TEST: ARM emulators are too slow to run these tests in a useful way");
|
||||
return false;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class MainActivityEspressoTest {
|
||||
|| Build.MODEL.contains("Emulator")
|
||||
|| Build.MODEL.contains("Android SDK built for x86")
|
||||
|| Build.MANUFACTURER.contains("Genymotion")
|
||||
|| (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|
||||
|| Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic")
|
||||
|| "google_sdk".equals(Build.PRODUCT);
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ public class MainActivityEspressoTest {
|
||||
if (!BuildConfig.FLAVOR.startsWith("full")) {
|
||||
return;
|
||||
}
|
||||
onView(Matchers.<View>instanceOf(StatusBanner.class)).check(matches(not(isDisplayed())));
|
||||
onView(Matchers.instanceOf(StatusBanner.class)).check(matches(not(isDisplayed())));
|
||||
onView(allOf(withText(R.string.menu_settings), isDisplayed())).perform(click());
|
||||
onView(allOf(withText(R.string.main_menu__latest_apps), isDisplayed())).perform(click());
|
||||
onView(allOf(withId(R.id.swipe_to_refresh), isDisplayed()))
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.fdroid.fdroid;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
@@ -231,9 +233,9 @@ public class Netstat {
|
||||
/**
|
||||
* Types of connection protocol
|
||||
***/
|
||||
public static final byte TCP_CONNECTION = 0;
|
||||
public static final byte UDP_CONNECTION = 1;
|
||||
public static final byte RAW_CONNECTION = 2;
|
||||
static final byte TCP_CONNECTION = 0;
|
||||
static final byte UDP_CONNECTION = 1;
|
||||
static final byte RAW_CONNECTION = 2;
|
||||
/**
|
||||
* <code>serialVersionUID</code>
|
||||
*/
|
||||
@@ -282,11 +284,11 @@ public class Netstat {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public final void setProtocol(final byte protocol) {
|
||||
final void setProtocol(final byte protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public final String getProtocolAsString() {
|
||||
final String getProtocolAsString() {
|
||||
switch (protocol) {
|
||||
case TCP_CONNECTION:
|
||||
return "TCP";
|
||||
@@ -310,7 +312,7 @@ public class Netstat {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public final void setPID(final int pid) {
|
||||
final void setPID(final int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
@@ -318,7 +320,7 @@ public class Netstat {
|
||||
return pname;
|
||||
}
|
||||
|
||||
public final void setPName(final String pname) {
|
||||
final void setPName(final String pname) {
|
||||
this.pname = pname;
|
||||
}
|
||||
|
||||
@@ -326,7 +328,7 @@ public class Netstat {
|
||||
return localPort;
|
||||
}
|
||||
|
||||
public final void setLocalPort(final int localPort) {
|
||||
final void setLocalPort(final int localPort) {
|
||||
this.localPort = localPort;
|
||||
}
|
||||
|
||||
@@ -334,7 +336,7 @@ public class Netstat {
|
||||
return remoteAddress;
|
||||
}
|
||||
|
||||
public final void setRemoteAddress(final String remoteAddress) {
|
||||
final void setRemoteAddress(final String remoteAddress) {
|
||||
this.remoteAddress = remoteAddress;
|
||||
}
|
||||
|
||||
@@ -342,7 +344,7 @@ public class Netstat {
|
||||
return remotePort;
|
||||
}
|
||||
|
||||
public final void setRemotePort(final int remotePort) {
|
||||
final void setRemotePort(final int remotePort) {
|
||||
this.remotePort = remotePort;
|
||||
}
|
||||
|
||||
@@ -350,22 +352,21 @@ public class Netstat {
|
||||
return status;
|
||||
}
|
||||
|
||||
public final void setStatus(final String status) {
|
||||
final void setStatus(final String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("[Prot=").append(getProtocolAsString());
|
||||
buf.append(",POwner=").append(powner);
|
||||
buf.append(",PID=").append(pid);
|
||||
buf.append(",PName=").append(pname);
|
||||
buf.append(",LPort=").append(localPort);
|
||||
buf.append(",RAddress=").append(remoteAddress);
|
||||
buf.append(",RPort=").append(remotePort);
|
||||
buf.append(",Status=").append(status);
|
||||
buf.append("]");
|
||||
return buf.toString();
|
||||
return "[Prot=" + getProtocolAsString() +
|
||||
",POwner=" + powner +
|
||||
",PID=" + pid +
|
||||
",PName=" + pname +
|
||||
",LPort=" + localPort +
|
||||
",RAddress=" + remoteAddress +
|
||||
",RPort=" + remotePort +
|
||||
",Status=" + status +
|
||||
"]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.fdroid.fdroid;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.test.uiautomator.UiDevice;
|
||||
import androidx.test.uiautomator.UiObject;
|
||||
import androidx.test.uiautomator.UiObjectNotFoundException;
|
||||
import androidx.test.uiautomator.UiSelector;
|
||||
import androidx.test.uiautomator.UiWatcher;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -38,83 +38,71 @@ class UiWatchers {
|
||||
* This is a sample watcher looking for ANR and crashes. it closes it and moves on. You should
|
||||
* create your own watchers and handle error logging properly for your type of tests.
|
||||
*/
|
||||
public void registerAnrAndCrashWatchers() {
|
||||
UiDevice.getInstance().registerWatcher("ANR", new UiWatcher() {
|
||||
@Override
|
||||
public boolean checkForCondition() {
|
||||
UiObject window = new UiObject(new UiSelector().className(
|
||||
"com.android.server.am.AppNotRespondingDialog"));
|
||||
String errorText = null;
|
||||
if (window.exists()) {
|
||||
try {
|
||||
errorText = window.getText();
|
||||
} catch (UiObjectNotFoundException e) {
|
||||
Log.e(LOG_TAG, "dialog gone?", e);
|
||||
}
|
||||
onAnrDetected(errorText);
|
||||
postHandler("Wait");
|
||||
return true; // triggered
|
||||
void registerAnrAndCrashWatchers() {
|
||||
UiDevice.getInstance().registerWatcher("ANR", () -> {
|
||||
UiObject window = new UiObject(new UiSelector().className(
|
||||
"com.android.server.am.AppNotRespondingDialog"));
|
||||
String errorText = null;
|
||||
if (window.exists()) {
|
||||
try {
|
||||
errorText = window.getText();
|
||||
} catch (UiObjectNotFoundException e) {
|
||||
Log.e(LOG_TAG, "dialog gone?", e);
|
||||
}
|
||||
return false; // no trigger
|
||||
onAnrDetected(errorText);
|
||||
postHandler("Wait");
|
||||
return true; // triggered
|
||||
}
|
||||
return false; // no trigger
|
||||
});
|
||||
// class names may have changed
|
||||
UiDevice.getInstance().registerWatcher("ANR2", new UiWatcher() {
|
||||
@Override
|
||||
public boolean checkForCondition() {
|
||||
UiObject window = new UiObject(new UiSelector().packageName("android")
|
||||
.textContains("isn't responding."));
|
||||
if (window.exists()) {
|
||||
String errorText = null;
|
||||
try {
|
||||
errorText = window.getText();
|
||||
} catch (UiObjectNotFoundException e) {
|
||||
Log.e(LOG_TAG, "dialog gone?", e);
|
||||
}
|
||||
onAnrDetected(errorText);
|
||||
postHandler("Wait");
|
||||
return true; // triggered
|
||||
UiDevice.getInstance().registerWatcher("ANR2", () -> {
|
||||
UiObject window = new UiObject(new UiSelector().packageName("android")
|
||||
.textContains("isn't responding."));
|
||||
if (window.exists()) {
|
||||
String errorText = null;
|
||||
try {
|
||||
errorText = window.getText();
|
||||
} catch (UiObjectNotFoundException e) {
|
||||
Log.e(LOG_TAG, "dialog gone?", e);
|
||||
}
|
||||
return false; // no trigger
|
||||
onAnrDetected(errorText);
|
||||
postHandler("Wait");
|
||||
return true; // triggered
|
||||
}
|
||||
return false; // no trigger
|
||||
});
|
||||
UiDevice.getInstance().registerWatcher("CRASH", new UiWatcher() {
|
||||
@Override
|
||||
public boolean checkForCondition() {
|
||||
UiObject window = new UiObject(new UiSelector().className(
|
||||
"com.android.server.am.AppErrorDialog"));
|
||||
if (window.exists()) {
|
||||
String errorText = null;
|
||||
try {
|
||||
errorText = window.getText();
|
||||
} catch (UiObjectNotFoundException e) {
|
||||
Log.e(LOG_TAG, "dialog gone?", e);
|
||||
}
|
||||
onCrashDetected(errorText);
|
||||
postHandler("OK");
|
||||
return true; // triggered
|
||||
UiDevice.getInstance().registerWatcher("CRASH", () -> {
|
||||
UiObject window = new UiObject(new UiSelector().className(
|
||||
"com.android.server.am.AppErrorDialog"));
|
||||
if (window.exists()) {
|
||||
String errorText = null;
|
||||
try {
|
||||
errorText = window.getText();
|
||||
} catch (UiObjectNotFoundException e) {
|
||||
Log.e(LOG_TAG, "dialog gone?", e);
|
||||
}
|
||||
return false; // no trigger
|
||||
onCrashDetected(errorText);
|
||||
postHandler("OK");
|
||||
return true; // triggered
|
||||
}
|
||||
return false; // no trigger
|
||||
});
|
||||
UiDevice.getInstance().registerWatcher("CRASH2", new UiWatcher() {
|
||||
@Override
|
||||
public boolean checkForCondition() {
|
||||
UiObject window = new UiObject(new UiSelector().packageName("android")
|
||||
.textContains("has stopped"));
|
||||
if (window.exists()) {
|
||||
String errorText = null;
|
||||
try {
|
||||
errorText = window.getText();
|
||||
} catch (UiObjectNotFoundException e) {
|
||||
Log.e(LOG_TAG, "dialog gone?", e);
|
||||
}
|
||||
onCrashDetected(errorText);
|
||||
postHandler("OK");
|
||||
return true; // triggered
|
||||
UiDevice.getInstance().registerWatcher("CRASH2", () -> {
|
||||
UiObject window = new UiObject(new UiSelector().packageName("android")
|
||||
.textContains("has stopped"));
|
||||
if (window.exists()) {
|
||||
String errorText = null;
|
||||
try {
|
||||
errorText = window.getText();
|
||||
} catch (UiObjectNotFoundException e) {
|
||||
Log.e(LOG_TAG, "dialog gone?", e);
|
||||
}
|
||||
return false; // no trigger
|
||||
onCrashDetected(errorText);
|
||||
postHandler("OK");
|
||||
return true; // triggered
|
||||
}
|
||||
return false; // no trigger
|
||||
});
|
||||
Log.i(LOG_TAG, "Registered GUI Exception watchers");
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package org.fdroid.fdroid.compat;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import org.fdroid.fdroid.AssetUtils;
|
||||
import org.fdroid.fdroid.data.SanitizedFile;
|
||||
import org.junit.After;
|
||||
@@ -18,10 +23,6 @@ import org.junit.runner.RunWith;
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
|
||||
/**
|
||||
* This test needs to run on the emulator, even though it technically could
|
||||
@@ -78,7 +79,6 @@ public class FileCompatTest {
|
||||
assertTrue(destFile.getAbsolutePath() + " should exist after symlinking", destFile.exists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prefer internal over external storage, because external tends to be FAT filesystems,
|
||||
* which don't support symlinks (which we test using this method).
|
||||
|
||||
@@ -156,7 +156,8 @@ public class ApkVerifierTest {
|
||||
|
||||
try {
|
||||
apkVerifier.verifyApk();
|
||||
} catch (ApkVerifier.ApkVerificationException | ApkVerifier.ApkPermissionUnequalException e) {
|
||||
} catch (ApkVerifier.ApkVerificationException |
|
||||
ApkVerifier.ApkPermissionUnequalException e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.fdroid.fdroid.nearby;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -15,8 +17,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import javax.jmdns.ServiceEvent;
|
||||
import javax.jmdns.ServiceListener;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class BonjourManagerTest {
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package org.fdroid.fdroid.nearby;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.Netstat;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
@@ -23,11 +29,6 @@ import java.net.ServerSocket;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Test the nearby webserver in the emulator.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package org.fdroid.fdroid.nearby;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -7,6 +11,9 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -17,13 +24,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class PublicSourceDirProviderTest {
|
||||
public static final String TAG = "DataApkProviderTest";
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
|
||||
package org.fdroid.fdroid.net;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -11,7 +14,6 @@ import org.fdroid.download.HttpDownloader;
|
||||
import org.fdroid.download.HttpManager;
|
||||
import org.fdroid.download.Mirror;
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.ProgressListener;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.index.v1.IndexV1UpdaterKt;
|
||||
import org.junit.Test;
|
||||
@@ -26,10 +28,6 @@ import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class HttpDownloaderTest {
|
||||
private static final String TAG = "HttpDownloaderTest";
|
||||
|
||||
@@ -84,12 +82,7 @@ public class HttpDownloaderTest {
|
||||
File destFile = File.createTempFile("dl-", "");
|
||||
final DownloadRequest request = new DownloadRequest(path, mirrors, null, null, null);
|
||||
final HttpDownloader httpDownloader = new HttpDownloader(httpManager, request, destFile);
|
||||
httpDownloader.setListener(new ProgressListener() {
|
||||
@Override
|
||||
public void onProgress(long bytesRead, long totalBytes) {
|
||||
receivedProgress = true;
|
||||
}
|
||||
});
|
||||
httpDownloader.setListener((bytesRead, totalBytes) -> receivedProgress = true);
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -156,12 +149,9 @@ public class HttpDownloaderTest {
|
||||
File destFile = File.createTempFile("dl-", "");
|
||||
final DownloadRequest request = new DownloadRequest(path, mirrors, null, null, null);
|
||||
final HttpDownloader httpDownloader = new HttpDownloader(httpManager, request, destFile);
|
||||
httpDownloader.setListener(new ProgressListener() {
|
||||
@Override
|
||||
public void onProgress(long bytesRead, long totalBytes) {
|
||||
receivedProgress = true;
|
||||
latch.countDown();
|
||||
}
|
||||
httpDownloader.setListener((bytesRead, totalBytes) -> {
|
||||
receivedProgress = true;
|
||||
latch.countDown();
|
||||
});
|
||||
new Thread() {
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package org.fdroid.fdroid.updater;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@@ -8,6 +14,9 @@ import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import org.fdroid.fdroid.BuildConfig;
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.Hasher;
|
||||
@@ -30,15 +39,6 @@ import java.util.Locale;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@LargeTest
|
||||
public class SwapRepoEmulatorTest {
|
||||
public static final String TAG = "SwapRepoEmulatorTest";
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
package org.fdroid.fdroid.work;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.work.OneTimeWorkRequest;
|
||||
import androidx.work.WorkInfo;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.fdroid.fdroid.compat.FileCompatTest;
|
||||
import org.junit.Rule;
|
||||
@@ -16,10 +23,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* This test cannot run on Robolectric unfortunately since it does not support
|
||||
* getting the timestamps from the files completely.
|
||||
|
||||
@@ -18,12 +18,16 @@
|
||||
|
||||
package org.fdroid.fdroid.work;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.work.OneTimeWorkRequest;
|
||||
import androidx.work.WorkInfo;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -31,8 +35,6 @@ import org.junit.Test;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* This actually runs {@link FDroidMetricsWorker} on a device/emulator and
|
||||
* submits a report to https://metrics.cleaninsights.org
|
||||
|
||||
@@ -3,11 +3,13 @@ package org.fdroid.fdroid.work;
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.work.Configuration;
|
||||
import androidx.work.WorkManager;
|
||||
import androidx.work.testing.SynchronousExecutor;
|
||||
import androidx.work.testing.WorkManagerTestInitHelper;
|
||||
|
||||
import org.junit.rules.TestWatcher;
|
||||
import org.junit.runner.Description;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user