Skip to content

Commit

Permalink
Merge pull request #141 from square/zachklipp/upgrade-androidx-compos…
Browse files Browse the repository at this point in the history
…e-kotlin

Upgrade Kotlin, many 3P dependencies, and Compose to latest stable versions.
  • Loading branch information
zach-klippenstein authored Aug 12, 2021
2 parents 4639ede + 29d788d commit dcf358a
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ subprojects {
allWarningsAsErrors = true
}

jvmTarget = "1.6"
jvmTarget = "1.8"
}
}

Expand Down
28 changes: 14 additions & 14 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}"
Expand All @@ -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}"
Expand Down
8 changes: 7 additions & 1 deletion compose-tests/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
<manifest package="com.squareup.radiography.test.compose" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.squareup.radiography.test.compose">

<application>
<activity android:name="androidx.activity.ComponentActivity" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) })
Expand Down Expand Up @@ -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 }")
Expand Down Expand Up @@ -195,7 +195,7 @@ class ComposeUiTest {
}

assertThat(hierarchy).contains("Checkbox")
assertThat(hierarchy).contains("Checked")
assertThat(hierarchy).contains("toggle-state:On")
}

@Test fun textEmptyContents() {
Expand Down Expand Up @@ -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} ├─<subcomposition of LazyColumn>
|${BLANK} │ ╰─SaveableStateProvider { test-tag:"child:1" }
|${BLANK} ├─<subcomposition of LazyColumn>
Expand Down
4 changes: 2 additions & 2 deletions compose-unsupported-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
<manifest package="com.squareup.radiography.test.compose.unsupported" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.squareup.radiography.test.compose.unsupported">

<application>
<activity android:name="androidx.activity.ComponentActivity" />
</application>
</manifest>

12 changes: 7 additions & 5 deletions radiography/src/main/java/radiography/ViewStateRenderers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
Expand Down Expand Up @@ -215,7 +217,7 @@ public object ViewStateRenderers {
?.filterIsInstance<SemanticsModifier>()
?: return@ViewStateRenderer

semantics.mapNotNull { it.semanticsConfiguration.getOrNull(Text)?.text }
semantics.mapNotNull { it.semanticsConfiguration.getOrNull(Text)?.joinToString() }
.takeUnless { it.isEmpty() }
?.joinToString(separator = " ")
?.also {
Expand Down
2 changes: 1 addition & 1 deletion sample-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion sample-compose/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
<manifest package="com.squareup.radiography.sample.compose.test" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.squareup.radiography.sample.compose.test">

<application>
<activity android:name="androidx.activity.ComponentActivity" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit dcf358a

Please sign in to comment.