Merge branch 'dev' into feature/sync

This commit is contained in:
2020-11-28 08:55:12 -06:00
68 changed files with 77 additions and 41 deletions

View File

@@ -232,7 +232,10 @@ case "$1" in
medium-tests)
shift; parse_opts $*
run_tests medium
for attempt in {1..3}; do
(run_tests medium) && exit 0
done
exit 1
;;
large-tests)
@@ -253,7 +256,7 @@ case "$1" in
build_apk
install_apk
;;
clean)
remove_build_dir
;;

View File

@@ -1,7 +1,7 @@
VERSION_CODE = 20000
VERSION_NAME = 2.0.0
MIN_SDK_VERSION = 21
MIN_SDK_VERSION = 23
TARGET_SDK_VERSION = 29
COMPILE_SDK_VERSION = 29

View File

@@ -53,6 +53,7 @@ android {
}
compileOptions {
coreLibraryDesugaringEnabled true
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
@@ -102,6 +103,8 @@ dependencies {
implementation "io.ktor:ktor-client-jackson:$KTOR_VERSION"
implementation "com.google.guava:guava:30.0-android"
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
compileOnly "javax.annotation:jsr250-api:1.0"
compileOnly "com.google.auto.factory:auto-factory:$AUTO_FACTORY_VERSION"

View File

@@ -230,9 +230,9 @@ public class BaseAndroidTest extends TestCase
int minute) throws Exception
{
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeZone(TimeZone.getTimeZone(tz));
cal.set(Calendar.SECOND, 0);
cal.set(year, javaMonth, day, hourOfDay, minute);
cal.setTimeZone(TimeZone.getTimeZone(tz));
setSystemTime(cal);
}
@@ -249,6 +249,22 @@ public class BaseAndroidTest extends TestCase
device.executeShellCommand(command);
// Set time
String date = String.format("%02d%02d%02d%02d%02d.%02d",
cal.get(Calendar.MONTH) + 1,
cal.get(Calendar.DAY_OF_MONTH),
cal.get(Calendar.HOUR_OF_DAY),
cal.get(Calendar.MINUTE),
cal.get(Calendar.YEAR),
cal.get(Calendar.SECOND));
// Set time (method 1)
// Run twice to override daylight saving time
device.executeShellCommand("date " + date);
device.executeShellCommand("date " + date);
// Set time (method 2)
// Run in addition to the method above because one of these mail fail, depending
// on the Android API version.
command = String.format("date -u @%d", cal.getTimeInMillis() / 1000);
device.executeShellCommand(command);

View File

@@ -33,8 +33,6 @@ import org.isoron.uhabits.widgets.*;
import java.io.*;
import java.util.*;
import static android.os.Build.VERSION.*;
import static android.os.Build.VERSION_CODES.*;
import static android.view.View.MeasureSpec.*;
public class BaseViewTest extends BaseAndroidTest
@@ -51,7 +49,7 @@ public class BaseViewTest extends BaseAndroidTest
throws IOException
{
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
expectedImagePath = getVersionedPath(expectedImagePath);
expectedImagePath = "views/" + expectedImagePath;
Bitmap actual = renderView(view);
if(actual == null) throw new IllegalStateException("actual is null");
@@ -158,16 +156,6 @@ public class BaseViewTest extends BaseAndroidTest
return BitmapFactory.decodeStream(stream);
}
private String getVersionedPath(String path)
{
int version = SDK_INT;
if (version >= 26) version = 26;
else if (version >= LOLLIPOP) version = LOLLIPOP;
else if (version >= KITKAT) version = KITKAT;
return String.format("views-v%d/%s", version, path);
}
private String saveBitmap(String filename, String suffix, Bitmap bitmap)
throws IOException
{