Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the compose sample to use the latest compose version. #98

Merged
merged 1 commit into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = Versions.Compose
val sampleComposeVersion = "1.0.0-alpha03"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also extract this as "Versions.MinSupportedCompose" ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, although it would be MaxSupportedCompose. Maybe we should extract min/max versions and run both in CI?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


android {
compileSdkVersion(30)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,21 +13,21 @@ import org.junit.Test
class ComposeSampleUiTest {

@get:Rule
val activityRule = createAndroidComposeRule<MainActivity>()
val composeRule = createAndroidComposeRule<MainActivity>()

@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"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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")
Expand Down