Fix medium tests for Android APIs 23-25

pull/699/head
Alinson S. Xavier 5 years ago
parent 8c6e2ef461
commit 2bf7358207

@ -32,7 +32,7 @@ jobs:
runs-on: macOS-latest runs-on: macOS-latest
strategy: strategy:
matrix: matrix:
api-level: [26, 27, 28, 29] api-level: [23, 24, 25, 26, 27, 28, 29]
steps: steps:
- name: Check out source code - name: Check out source code
uses: actions/checkout@v1 uses: actions/checkout@v1

@ -53,6 +53,7 @@ android {
} }
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
} }
@ -94,6 +95,8 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION"
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4" implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
compileOnly "javax.annotation:jsr250-api:1.0" compileOnly "javax.annotation:jsr250-api:1.0"
compileOnly "com.google.auto.factory:auto-factory:$AUTO_FACTORY_VERSION" compileOnly "com.google.auto.factory:auto-factory:$AUTO_FACTORY_VERSION"

@ -230,9 +230,9 @@ public class BaseAndroidTest extends TestCase
int minute) throws Exception int minute) throws Exception
{ {
GregorianCalendar cal = new GregorianCalendar(); GregorianCalendar cal = new GregorianCalendar();
cal.setTimeZone(TimeZone.getTimeZone(tz));
cal.set(Calendar.SECOND, 0); cal.set(Calendar.SECOND, 0);
cal.set(year, javaMonth, day, hourOfDay, minute); cal.set(year, javaMonth, day, hourOfDay, minute);
cal.setTimeZone(TimeZone.getTimeZone(tz));
setSystemTime(cal); setSystemTime(cal);
} }
@ -249,8 +249,17 @@ public class BaseAndroidTest extends TestCase
device.executeShellCommand(command); device.executeShellCommand(command);
// Set time // Set time
command = String.format("date -u @%d", cal.getTimeInMillis() / 1000); String date = String.format("%02d%02d%02d%02d%02d.%02d",
device.executeShellCommand(command); 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));
// Run twice to override daylight saving time
device.executeShellCommand("date " + date);
device.executeShellCommand("date " + date);
// Wait for system events to settle // Wait for system events to settle
Thread.sleep(1000); Thread.sleep(1000);

@ -33,8 +33,6 @@ import org.isoron.uhabits.widgets.*;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import static android.os.Build.VERSION.*;
import static android.os.Build.VERSION_CODES.*;
import static android.view.View.MeasureSpec.*; import static android.view.View.MeasureSpec.*;
public class BaseViewTest extends BaseAndroidTest public class BaseViewTest extends BaseAndroidTest
@ -51,7 +49,7 @@ public class BaseViewTest extends BaseAndroidTest
throws IOException throws IOException
{ {
InstrumentationRegistry.getInstrumentation().waitForIdleSync(); InstrumentationRegistry.getInstrumentation().waitForIdleSync();
expectedImagePath = getVersionedPath(expectedImagePath); expectedImagePath = "views/" + expectedImagePath;
Bitmap actual = renderView(view); Bitmap actual = renderView(view);
if(actual == null) throw new IllegalStateException("actual is null"); if(actual == null) throw new IllegalStateException("actual is null");
@ -158,16 +156,6 @@ public class BaseViewTest extends BaseAndroidTest
return BitmapFactory.decodeStream(stream); 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) private String saveBitmap(String filename, String suffix, Bitmap bitmap)
throws IOException throws IOException
{ {

Loading…
Cancel
Save