From 29d788df5d2484c274438f31da92bab3a2ffcc00 Mon Sep 17 00:00:00 2001 From: Zach Klippenstein Date: Thu, 12 Aug 2021 08:12:01 -0700 Subject: [PATCH] Upgrade Kotlin, many 3P dependencies, and Compose to latest stable versions. --- build.gradle.kts | 2 +- buildSrc/src/main/java/Dependencies.kt | 28 +++++++++---------- .../src/androidTest/AndroidManifest.xml | 8 +++++- .../radiography/test/compose/ComposeUiTest.kt | 12 ++++---- compose-unsupported-tests/build.gradle.kts | 4 +-- .../src/androidTest/AndroidManifest.xml | 9 +++++- .../java/radiography/ViewStateRenderers.kt | 12 ++++---- sample-compose/build.gradle.kts | 2 +- .../src/androidTest/AndroidManifest.xml | 8 +++++- .../sample/compose/ComposeSampleUiTest.kt | 2 +- 10 files changed, 54 insertions(+), 33 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e769111..66bf31f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -79,7 +79,7 @@ subprojects { allWarningsAsErrors = true } - jvmTarget = "1.6" + jvmTarget = "1.8" } } diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 6461ff3..831ef61 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -3,10 +3,10 @@ object Versions { * To change this in the IDE, use `systemProp.square.kotlinVersion=x.y.z` in your * `~/.gradle/gradle.properties` file. */ - val KotlinCompiler = System.getProperty("square.kotlinVersion") ?: "1.4.30" + val KotlinCompiler = System.getProperty("square.kotlinVersion") ?: "1.5.21" - const val AndroidXTest = "1.3.0" - const val Compose = "1.0.0-beta01" + const val AndroidXTest = "1.4.0" + const val Compose = "1.0.1" } object Dependencies { @@ -15,20 +15,20 @@ object Dependencies { const val MavenPublish = "com.vanniktech:gradle-maven-publish-plugin:0.14.0" val Kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.KotlinCompiler}" const val Ktlint = "org.jlleitschuh.gradle:ktlint-gradle:9.2.1" - const val BinaryCompatibility = "org.jetbrains.kotlinx:binary-compatibility-validator:0.2.3" - const val Dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.4.20" + const val BinaryCompatibility = "org.jetbrains.kotlinx:binary-compatibility-validator:0.6.0" + const val Dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.5.0" } - const val AppCompat = "androidx.appcompat:appcompat:1.2.0" - const val ConstraintLayout = "androidx.constraintlayout:constraintlayout:1.1.3" - const val Curtains = "com.squareup.curtains:curtains:1.0.1" + const val AppCompat = "androidx.appcompat:appcompat:1.3.1" + const val ConstraintLayout = "androidx.constraintlayout:constraintlayout:2.1.0" + const val Curtains = "com.squareup.curtains:curtains:1.2.1" const val JUnit = "junit:junit:4.13" - const val Mockito = "org.mockito:mockito-core:3.4.6" - const val Robolectric = "org.robolectric:robolectric:4.3.1" - const val Truth = "com.google.truth:truth:1.0.1" + const val Mockito = "org.mockito:mockito-core:3.11.2" + const val Robolectric = "org.robolectric:robolectric:4.6.1" + const val Truth = "com.google.truth:truth:1.1.3" class Compose(composeVersion: String = Versions.Compose) { - fun Activity(version: String = "1.3.0-alpha03") = "androidx.activity:activity-compose:$version" + fun Activity(version: String = "1.3.1") = "androidx.activity:activity-compose:$version" val Material = "androidx.compose.material:material:${composeVersion}" val Testing = "androidx.compose.ui:ui-test-junit4:${composeVersion}" val Tooling = "androidx.compose.ui:ui-tooling:${composeVersion}" @@ -37,8 +37,8 @@ object Dependencies { object InstrumentationTests { const val Core = "androidx.test:core:${Versions.AndroidXTest}" - const val Espresso = "androidx.test.espresso:espresso-core:3.3.0" - const val JUnit = "androidx.test.ext:junit:1.1.2" + const val Espresso = "androidx.test.espresso:espresso-core:3.4.0" + const val JUnit = "androidx.test.ext:junit:1.1.3" const val Orchestrator = "androidx.test:orchestrator:${Versions.AndroidXTest}" const val Rules = "androidx.test:rules:${Versions.AndroidXTest}" const val Runner = "androidx.test:runner:${Versions.AndroidXTest}" diff --git a/compose-tests/src/androidTest/AndroidManifest.xml b/compose-tests/src/androidTest/AndroidManifest.xml index a7a07c0..609799b 100644 --- a/compose-tests/src/androidTest/AndroidManifest.xml +++ b/compose-tests/src/androidTest/AndroidManifest.xml @@ -1 +1,7 @@ - + + + + + + diff --git a/compose-tests/src/androidTest/java/radiography/test/compose/ComposeUiTest.kt b/compose-tests/src/androidTest/java/radiography/test/compose/ComposeUiTest.kt index 9d2811b..6db7564 100644 --- a/compose-tests/src/androidTest/java/radiography/test/compose/ComposeUiTest.kt +++ b/compose-tests/src/androidTest/java/radiography/test/compose/ComposeUiTest.kt @@ -20,7 +20,7 @@ import androidx.compose.ui.layout.SubcomposeLayout import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.testTag import androidx.compose.ui.semantics.ProgressBarRangeInfo -import androidx.compose.ui.semantics.Role.RadioButton +import androidx.compose.ui.semantics.Role.Companion.RadioButton import androidx.compose.ui.semantics.ScrollAxisRange import androidx.compose.ui.semantics.SemanticsProperties.ContentDescription import androidx.compose.ui.semantics.SemanticsProperties.Disabled @@ -46,7 +46,7 @@ import androidx.compose.ui.semantics.semantics import androidx.compose.ui.state.ToggleableState.On import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.text.TextRange -import androidx.compose.ui.text.input.ImeAction.Send +import androidx.compose.ui.text.input.ImeAction.Companion.Send import androidx.compose.ui.viewinterop.AndroidView import androidx.compose.ui.window.Dialog import com.google.common.truth.Truth.assertThat @@ -125,7 +125,7 @@ class ComposeUiTest { @Test fun semanticsAreReported() { composeRule.setContentWithExplicitRoot { Box(Modifier.semantics { set(TestTag, "test tag") }) - Box(Modifier.semantics { set(ContentDescription, "content description") }) + Box(Modifier.semantics { set(ContentDescription, listOf("content description")) }) Box(Modifier.semantics { set(StateDescription, "state description") }) Box(Modifier.semantics { set(Disabled, Unit) }) Box(Modifier.semantics { set(Focused, true) }) @@ -163,7 +163,7 @@ class ComposeUiTest { } assertThat(hierarchy).contains("Box { test-tag:\"test tag\" }") - assertThat(hierarchy).contains("Box { content-description:\"content description\" }") + assertThat(hierarchy).contains("Box { content-description:[\"content description\"] }") assertThat(hierarchy).contains("Box { state-description:\"state description\" }") assertThat(hierarchy).contains("Box { DISABLED }") assertThat(hierarchy).contains("Box { FOCUSED }") @@ -195,7 +195,7 @@ class ComposeUiTest { } assertThat(hierarchy).contains("Checkbox") - assertThat(hierarchy).contains("Checked") + assertThat(hierarchy).contains("toggle-state:On") } @Test fun textEmptyContents() { @@ -597,7 +597,7 @@ class ComposeUiTest { """ |CompositionLocalProvider: |${BLANK}CompositionLocalProvider { test-tag:"parent" } - |${BLANK}╰─LazyColumn { test-tag:"list" } + |${BLANK}╰─LazyColumn { test-tag:"list", vertical-scroll-axis-range:"ScrollAxisRange(value=0.0, maxValue=Infinity)" } |${BLANK} ├─ |${BLANK} │ ╰─SaveableStateProvider { test-tag:"child:1" } |${BLANK} ├─ diff --git a/compose-unsupported-tests/build.gradle.kts b/compose-unsupported-tests/build.gradle.kts index 2d14805..2b65cc0 100644 --- a/compose-unsupported-tests/build.gradle.kts +++ b/compose-unsupported-tests/build.gradle.kts @@ -9,9 +9,9 @@ plugins { * Allows using a different version of Compose to validate that we degrade gracefully on apps * built with unsupported Compose versions. */ -val oldComposeVersion = "1.0.0-alpha12" +val oldComposeVersion = "1.0.1" // Older version of Compose requires an older version of Kotlin. -val oldComposeCompiler = "1.4.30" +val oldComposeCompiler = "1.5.21" android { compileSdk = 30 diff --git a/compose-unsupported-tests/src/androidTest/AndroidManifest.xml b/compose-unsupported-tests/src/androidTest/AndroidManifest.xml index 9f87da8..58d7480 100644 --- a/compose-unsupported-tests/src/androidTest/AndroidManifest.xml +++ b/compose-unsupported-tests/src/androidTest/AndroidManifest.xml @@ -1 +1,8 @@ - + + + + + + + diff --git a/radiography/src/main/java/radiography/ViewStateRenderers.kt b/radiography/src/main/java/radiography/ViewStateRenderers.kt index 78527eb..2b9b96e 100644 --- a/radiography/src/main/java/radiography/ViewStateRenderers.kt +++ b/radiography/src/main/java/radiography/ViewStateRenderers.kt @@ -60,8 +60,8 @@ public object ViewStateRenderers { @OptIn(ExperimentalComposeUiApi::class) @ExperimentalRadiographyComposeApi private val ComposeViewRenderer: ViewStateRenderer = if (!isComposeAvailable) NoRenderer else { - ViewStateRenderer { - val composeView = it as? ComposeView ?: return@ViewStateRenderer + ViewStateRenderer { scannableView -> + val composeView = scannableView as? ComposeView ?: return@ViewStateRenderer // Dimensions composeView.apply { @@ -80,8 +80,10 @@ public object ViewStateRenderers { .forEach { (key, value) -> when (key) { SemanticsProperties.TestTag -> appendLabeledValue("test-tag", value) - SemanticsProperties.ContentDescription -> - appendLabeledValue("content-description", value) + SemanticsProperties.ContentDescription -> appendLabeledValue( + "content-description", + (value as List<*>).map { "\"$it\"" } + ) SemanticsProperties.StateDescription -> appendLabeledValue("state-description", value) SemanticsProperties.Disabled -> append("DISABLED") SemanticsProperties.Focused -> if (value == true) append("FOCUSED") @@ -215,7 +217,7 @@ public object ViewStateRenderers { ?.filterIsInstance() ?: return@ViewStateRenderer - semantics.mapNotNull { it.semanticsConfiguration.getOrNull(Text)?.text } + semantics.mapNotNull { it.semanticsConfiguration.getOrNull(Text)?.joinToString() } .takeUnless { it.isEmpty() } ?.joinToString(separator = " ") ?.also { diff --git a/sample-compose/build.gradle.kts b/sample-compose/build.gradle.kts index c4e7e09..9a8b000 100644 --- a/sample-compose/build.gradle.kts +++ b/sample-compose/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } /** Use a separate property for the sample so we can test with different versions easily. */ -val sampleComposeVersion = "1.0.0-beta01" +val sampleComposeVersion = "1.0.1" android { compileSdk = 30 diff --git a/sample-compose/src/androidTest/AndroidManifest.xml b/sample-compose/src/androidTest/AndroidManifest.xml index 01a432f..696f006 100644 --- a/sample-compose/src/androidTest/AndroidManifest.xml +++ b/sample-compose/src/androidTest/AndroidManifest.xml @@ -1 +1,7 @@ - + + + + + + diff --git a/sample-compose/src/androidTest/java/com/squareup/radiography/sample/compose/ComposeSampleUiTest.kt b/sample-compose/src/androidTest/java/com/squareup/radiography/sample/compose/ComposeSampleUiTest.kt index 236f145..0c8badc 100644 --- a/sample-compose/src/androidTest/java/com/squareup/radiography/sample/compose/ComposeSampleUiTest.kt +++ b/sample-compose/src/androidTest/java/com/squareup/radiography/sample/compose/ComposeSampleUiTest.kt @@ -22,7 +22,7 @@ class ComposeSampleUiTest { @Test fun displaysHierarchyInline() { composeRule.onNodeWithTag(LIVE_HIERARCHY_TEST_TAG) .assert(hasText("Remember me", substring = true)) - .assert(hasText("Unchecked", substring = true)) + .assert(hasText("toggle-state:Off", substring = true)) composeRule.onNodeWithTag(TEXT_FIELD_TEST_TAG) .performTextReplacement("foobar")