From 7df3d7dfbd3840af5286e2db424031960ed79f3f Mon Sep 17 00:00:00 2001 From: Zach Klippenstein Date: Thu, 17 Sep 2020 09:24:26 -0700 Subject: [PATCH] Update the compose sample to use the latest compose version. Note that this does not actually change the version of compose that the library is compiled against. This ensures that the existing release still works with the newer compose version. --- sample-compose/build.gradle.kts | 2 +- .../sample/compose/ComposeSampleUiTest.kt | 12 ++++++------ .../radiography/sample/compose/ComposeSampleApp.kt | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sample-compose/build.gradle.kts b/sample-compose/build.gradle.kts index 5718985..1a23b61 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 = Versions.Compose +val sampleComposeVersion = "1.0.0-alpha03" android { compileSdkVersion(30) 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 c700a74..6d8d83b 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 @@ -1,8 +1,8 @@ package com.squareup.radiography.sample.compose -import androidx.ui.test.android.createAndroidComposeRule import androidx.ui.test.assert import androidx.ui.test.assertIsDisplayed +import androidx.ui.test.createAndroidComposeRule import androidx.ui.test.hasSubstring import androidx.ui.test.onNodeWithTag import androidx.ui.test.onNodeWithText @@ -13,21 +13,21 @@ import org.junit.Test class ComposeSampleUiTest { @get:Rule - val activityRule = createAndroidComposeRule() + val composeRule = createAndroidComposeRule() @Test fun launches() { - onNodeWithText("Remember me").assertIsDisplayed() + composeRule.onNodeWithText("Remember me").assertIsDisplayed() } @Test fun displaysHierarchyInline() { - onNodeWithTag(LIVE_HIERARCHY_TEST_TAG) + composeRule.onNodeWithTag(LIVE_HIERARCHY_TEST_TAG) .assert(hasSubstring("Remember me")) .assert(hasSubstring("Unchecked")) - onNodeWithTag(TEXT_FIELD_TEST_TAG) + composeRule.onNodeWithTag(TEXT_FIELD_TEST_TAG) .performTextReplacement("foobar") - onNodeWithTag(LIVE_HIERARCHY_TEST_TAG) + composeRule.onNodeWithTag(LIVE_HIERARCHY_TEST_TAG) .assert(hasSubstring("Remember me")) .assert(hasSubstring("foobar")) } diff --git a/sample-compose/src/main/java/com/squareup/radiography/sample/compose/ComposeSampleApp.kt b/sample-compose/src/main/java/com/squareup/radiography/sample/compose/ComposeSampleApp.kt index ce2a721..950ec1d 100644 --- a/sample-compose/src/main/java/com/squareup/radiography/sample/compose/ComposeSampleApp.kt +++ b/sample-compose/src/main/java/com/squareup/radiography/sample/compose/ComposeSampleApp.kt @@ -70,7 +70,7 @@ internal const val LIVE_HIERARCHY_TEST_TAG = "live-hierarchy" MaterialTheme { Column( modifier = Modifier.padding(16.dp), - horizontalGravity = Alignment.CenterHorizontally, + horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(16.dp) ) { RadiographyLogo(Modifier.height(128.dp)) @@ -89,7 +89,7 @@ internal const val LIVE_HIERARCHY_TEST_TAG = "live-hierarchy" backgroundColor = Color.Transparent, visualTransformation = PasswordVisualTransformation() ) - Row(verticalGravity = Alignment.CenterVertically) { + Row(verticalAlignment = Alignment.CenterVertically) { Checkbox(checked = rememberMe, onCheckedChange = { rememberMe = it }) Spacer(Modifier.width(8.dp)) Text("Remember me")