Skip to content

Commit b13da37

Browse files
authored
Fix BasicUITest, raise targetSdk and update dependencies (QuantumBadger#1194)
* Fix BasicUITest * Update Gradle to 8.7 * Update AGP to 8.4.1 * Update Kotlin to 2.0 * Update other dependencies * Raise compileSdk and targetSdk to 34
1 parent babbe4a commit b13da37

File tree

9 files changed

+59
-43
lines changed

9 files changed

+59
-43
lines changed

build.gradle.kts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ dependencies {
5656

5757
testImplementation(libs.junit)
5858

59+
androidTestImplementation(libs.androidx.test.core)
5960
androidTestImplementation(libs.androidx.test.espresso.core)
6061
androidTestImplementation(libs.androidx.test.espresso.contrib)
6162
androidTestImplementation(libs.androidx.test.rules)
63+
androidTestImplementation(libs.androidx.test.junit)
6264
}
6365

6466
android {
@@ -83,11 +85,11 @@ android {
8385
additionalParameters.add("--no-version-vectors")
8486
}
8587

86-
buildTypes.forEach {
87-
it.isMinifyEnabled = true
88-
it.isShrinkResources = false
88+
buildTypes.configureEach {
89+
isMinifyEnabled = true
90+
isShrinkResources = false
8991

90-
it.proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
92+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
9193
}
9294

9395
compileOptions {

gradle/libs.versions.toml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[versions]
2-
agp = "8.2.2"
3-
kotlin = "1.9.22"
2+
agp = "8.4.1"
3+
kotlin = "2.0.0"
44
java = "1.8"
55

6-
sdk-compile = "33"
6+
sdk-compile = "34"
77
sdk-min = "16"
8-
sdk-target = "33"
8+
sdk-target = "34"
99
ndk = "23.1.7779620"
1010

11-
androidx-annotation = "1.7.1"
11+
androidx-annotation = "1.8.0"
1212
androidx-appcompat = "1.6.1"
1313
androidx-constraintlayout = "2.1.4"
14-
androidx-core = "1.9.0"
14+
androidx-core = "1.12.0"
1515
androidx-fragment = "1.6.2"
1616
androidx-multidex = "2.0.1"
1717
androidx-preference = "1.2.1"
@@ -20,22 +20,24 @@ androidx-swiperefreshlayout = "1.1.0"
2020

2121
checkstyle = "10.12.5"
2222
commons-lang = "3.14.0"
23-
commons-text = "1.11.0"
23+
commons-text = "1.12.0"
2424
exoplayer = "2.19.0"
2525
google-flexbox = "3.0.0"
2626
google-material = "1.9.0"
2727
jackson = "2.16.1"
2828
jdk-desugar = "2.0.4"
29-
kotlinx-datetime = "0.5.0"
29+
kotlinx-datetime = "0.6.0"
3030
kotlinx-serialization = "1.6.3"
3131
netcipher = "2.1.0"
3232
okhttp = "3.12.13"
3333
pmd = "6.55.0"
3434
zstd = "1.5.5-11"
3535

3636
junit = "4.13.2"
37+
androidx-test-core = "1.5.0"
3738
androidx-test-espresso = "3.5.1"
3839
androidx-test-rules = "1.5.0"
40+
androidx-test-junit = "1.1.5"
3941

4042
[libraries]
4143
androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidx-annotation" }
@@ -65,9 +67,11 @@ okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
6567
zstd = { module = "com.github.luben:zstd-jni", version.ref = "zstd" }
6668

6769
junit = { module = "junit:junit", version.ref = "junit" }
70+
androidx-test-core = { module = "androidx.test:core", version.ref = "androidx-test-core" }
6871
androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx-test-espresso" }
6972
androidx-test-espresso-contrib = { module = "androidx.test.espresso:espresso-contrib", version.ref = "androidx-test-espresso" }
7073
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test-rules" }
74+
androidx-test-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-test-junit" }
7175

7276
[plugins]
7377
android-application = { id = "com.android.application", version.ref = "agp" }

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew.bat

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
4343
%JAVA_EXE% -version >NUL 2>&1
4444
if %ERRORLEVEL% equ 0 goto execute
4545

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
46+
echo. 1>&2
47+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48+
echo. 1>&2
49+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50+
echo location of your Java installation. 1>&2
5151

5252
goto fail
5353

@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5757

5858
if exist "%JAVA_EXE%" goto execute
5959

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
60+
echo. 1>&2
61+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62+
echo. 1>&2
63+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64+
echo location of your Java installation. 1>&2
6565

6666
goto fail
6767

libs/redreader-common/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
12
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
23

34
buildscript {
@@ -21,7 +22,7 @@ java {
2122
}
2223

2324
tasks.withType(KotlinJvmCompile::class) {
24-
kotlinOptions.jvmTarget = libs.versions.java.get()
25+
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(libs.versions.java.get()))
2526
}
2627

2728
dependencies {

libs/redreader-datamodel/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
12
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
23

34
plugins {
@@ -13,7 +14,7 @@ java {
1314
}
1415

1516
tasks.withType(KotlinJvmCompile::class) {
16-
kotlinOptions.jvmTarget = libs.versions.java.get()
17+
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(libs.versions.java.get()))
1718
}
1819

1920
dependencies {

proguard-rules.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@
2525
-keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept.
2626
static <1>$$serializer INSTANCE;
2727
}
28+
29+
# Needed for instrumented tests for some reason
30+
-keep class com.google.common.util.concurrent.ListenableFuture { *; }

src/androidTest/java/org/quantumbadger/redreader/activities/BasicUITest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
import android.view.View;
2222
import android.view.ViewGroup;
2323
import android.view.ViewParent;
24+
25+
import androidx.test.ext.junit.runners.AndroidJUnit4;
2426
import androidx.test.filters.LargeTest;
2527
import androidx.test.rule.ActivityTestRule;
26-
import androidx.test.runner.AndroidJUnit4;
28+
2729
import org.hamcrest.Description;
2830
import org.hamcrest.Matcher;
2931
import org.hamcrest.TypeSafeMatcher;
@@ -59,24 +61,21 @@ public void basicUITest() {
5961
.perform(click());
6062

6163
onView(allOf(
62-
withId(R.id.title),
64+
withId(androidx.appcompat.R.id.title),
6365
withText("Settings"),
6466
childAtPosition(
6567
childAtPosition(
66-
withId(R.id.content),
68+
withId(androidx.appcompat.R.id.content),
6769
0),
6870
0),
6971
isDisplayed()))
7072
.perform(click());
7173

7274
onView(allOf(
73-
withContentDescription("Navigate up"),
75+
withContentDescription("Back"),
7476
childAtPosition(
75-
allOf(withId(R.id.action_bar),
76-
childAtPosition(
77-
withId(R.id.action_bar_container),
78-
0)),
79-
1),
77+
withId(R.id.rr_actionbar_toolbar),
78+
0),
8079
isDisplayed()))
8180
.perform(click());
8281

src/androidTest/java/org/quantumbadger/redreader/activities/UITestUtils.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package org.quantumbadger.redreader.activities;
22

3+
import static androidx.test.espresso.Espresso.onView;
4+
import static androidx.test.espresso.action.ViewActions.click;
5+
import static androidx.test.espresso.matcher.ViewMatchers.withId;
6+
import static androidx.test.espresso.matcher.ViewMatchers.withText;
7+
import static org.hamcrest.Matchers.allOf;
8+
39
import android.view.View;
10+
411
import androidx.test.espresso.NoMatchingViewException;
512
import androidx.test.espresso.UiController;
613
import androidx.test.espresso.ViewAction;
14+
715
import org.hamcrest.Matcher;
816
import org.hamcrest.core.IsAnything;
9-
10-
import static androidx.test.espresso.Espresso.onView;
11-
import static androidx.test.espresso.action.ViewActions.click;
12-
import static androidx.test.espresso.matcher.ViewMatchers.withId;
13-
import static androidx.test.espresso.matcher.ViewMatchers.withText;
14-
import static org.hamcrest.Matchers.allOf;
17+
import org.quantumbadger.redreader.R;
1518

1619
public class UITestUtils {
1720

@@ -21,15 +24,18 @@ public static void handleFirstRunDialog() {
2124

2225
try {
2326
onView(allOf(
24-
withId(android.R.id.button1),
25-
withText("Log in now")))
27+
withId(R.id.terms_button_decline)))
2628
.perform(click());
27-
2829
} catch(final NoMatchingViewException e) {
2930
// Ignore, the first run dialog has already been shown
3031
return;
3132
}
3233

34+
onView(allOf(
35+
withId(android.R.id.button1),
36+
withText("Log in now")))
37+
.perform(click());
38+
3339
onView(allOf(
3440
withId(android.R.id.button3),
3541
withText("Close")))

0 commit comments

Comments
 (0)