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

Takahirom/add is pseudo locales enabled/2024 06 07 #401

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions sample-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ android {
}

buildTypes {
debug {
pseudoLocalesEnabled true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
Expand Down
4 changes: 4 additions & 0 deletions sample-android/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="rtl_text">نص عينة</string>
</resources>
1 change: 1 addition & 0 deletions sample-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<string name="second_fragment_label" translatable="false">Second Fragment</string>
<string name="next">Next</string>
<string name="previous" translatable="false">Previous</string>
<string name="rtl_text">Sample Text</string>

<string name="hello_second_fragment" translatable="false">Hello second fragment. Arg: %1$s</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.CustomAccessibilityAction
Expand Down Expand Up @@ -81,18 +82,18 @@ class ComposeTest {
composeTestRule.activity.setContent {
Column(
modifier = Modifier
.clip(shape = RoundedCornerShape(16.dp))
.background(Color.Gray)
.testTag("SettingsDialog")
.size(100.dp)
.clip(shape = RoundedCornerShape(16.dp))
.background(Color.Gray)
.testTag("Settings")
.size(100.dp)
) {
Text("Settings")
Text("Dark theme")
}
}

composeTestRule
.onNodeWithTag("SettingsDialog")
.onNodeWithTag("Settings")
.captureRoboImage(
roborazziOptions = RoborazziOptions(
recordOptions = RoborazziOptions.RecordOptions(
Expand All @@ -102,6 +103,27 @@ class ComposeTest {
)
}

@Config(qualifiers = "+ar-rXB-ldrtl")
@Test
fun rtlCompose() {
composeTestRule.activity.setContent {
Column(
modifier = Modifier
.clip(shape = RoundedCornerShape(16.dp))
.background(Color.Gray)
.testTag("Settings")
.size(100.dp)
) {
Text("Settings")
Text(LocalContext.current.getString(R.string.rtl_text))
}
}

composeTestRule
.onNodeWithTag("Settings")
.captureRoboImage()
}

@Test
@Config(
sdk = [30],
Expand Down
Loading