mirror of
https://github.com/izzy2lost/aab2apk.git
synced 2026-06-19 01:20:08 -07:00
Merge pull request #3 from iammohdzaki/feature/compose-update
Updated Compose Version from 1.3.0 to 1.6.0
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
name: Run Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
|
||||
- name: Set execute permissions for gradlew
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: Cache Gradle dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
|
||||
- name: Run tests
|
||||
run: ./gradlew test
|
||||
+6
-1
@@ -26,7 +26,12 @@ kotlin {
|
||||
api("com.esotericsoftware:kryo:4.0.1")
|
||||
}
|
||||
}
|
||||
val jvmTest by getting
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(compose.desktop.uiTestJUnit4)
|
||||
implementation(compose.desktop.currentOs)
|
||||
}
|
||||
}
|
||||
val resourcesDir = "src/common/resources"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
kotlin.code.style=official
|
||||
kotlin.version=1.8.0
|
||||
agp.version=7.3.0
|
||||
compose.version=1.3.0
|
||||
compose.version=1.6.0
|
||||
@@ -20,10 +20,10 @@ import androidx.compose.ui.window.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import local.FileStorageHelper
|
||||
import theme.Styles
|
||||
import theme.components.CheckboxWithText
|
||||
import theme.components.ChooseFileTextField
|
||||
import theme.components.CustomTextField
|
||||
import ui.Styles
|
||||
import ui.components.CheckboxWithText
|
||||
import ui.components.ChooseFileTextField
|
||||
import ui.components.CustomTextField
|
||||
import utils.*
|
||||
import java.awt.Desktop
|
||||
import java.awt.FileDialog
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package theme
|
||||
package ui
|
||||
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@@ -1,4 +1,4 @@
|
||||
package theme
|
||||
package ui
|
||||
|
||||
import androidx.compose.material.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
+7
-3
@@ -1,4 +1,4 @@
|
||||
package theme.components
|
||||
package ui.components
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.TooltipArea
|
||||
@@ -16,12 +16,14 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.loadSvgPainter
|
||||
import androidx.compose.ui.res.useResource
|
||||
import androidx.compose.ui.unit.DpOffset
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import theme.Styles
|
||||
import ui.Styles
|
||||
import utils.TestTags
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
@@ -32,10 +34,12 @@ fun CheckboxWithText(label: String, isChecked: Boolean, onCheckedChange: (Boolea
|
||||
modifier = Modifier.padding(end = 16.dp)
|
||||
) {
|
||||
Checkbox(
|
||||
modifier = Modifier.testTag(TestTags.CHECKBOX_TAG),
|
||||
checked = isChecked,
|
||||
onCheckedChange = { onCheckedChange.invoke(it) },
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier.testTag(TestTags.TEXT_TAG),
|
||||
text = label,
|
||||
style = Styles.TextStyleMedium(14.sp),
|
||||
)
|
||||
@@ -60,7 +64,7 @@ fun CheckboxWithText(label: String, isChecked: Boolean, onCheckedChange: (Boolea
|
||||
alignment = Alignment.BottomEnd,
|
||||
offset = DpOffset.Zero // tooltip offset
|
||||
)
|
||||
){
|
||||
) {
|
||||
Icon(
|
||||
painter = useResource("info.svg") { loadSvgPainter(it, density) },
|
||||
contentDescription = "Info",
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package theme.components
|
||||
package ui.components
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.border
|
||||
@@ -15,7 +15,7 @@ import androidx.compose.ui.res.useResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import theme.Styles
|
||||
import ui.Styles
|
||||
|
||||
@Composable
|
||||
fun ChooseFileTextField(value: String, label: String, onSelect: () -> Unit) {
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package theme.components
|
||||
package ui.components
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.border
|
||||
@@ -22,7 +22,7 @@ import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import theme.Styles
|
||||
import ui.Styles
|
||||
|
||||
@Composable
|
||||
fun CustomTextField(value: String, label: String, forPassword: Boolean = true, onValueChange: (String) -> Unit) {
|
||||
@@ -16,4 +16,5 @@ object FileDialogType{
|
||||
object SigningMode{
|
||||
const val DEBUG = 1
|
||||
const val RELEASE = 2
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package utils
|
||||
|
||||
object TestTags {
|
||||
const val CHECKBOX_TAG = "CHECKBOX_TAG"
|
||||
const val TEXT_TAG = "TEXT_TAG"
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package ui.components
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.test.*
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import utils.TestTags
|
||||
|
||||
class CheckboxWithTextTest {
|
||||
|
||||
@get:Rule
|
||||
val rule = createComposeRule()
|
||||
|
||||
@Test
|
||||
fun `check checkbox toggle and label text`() {
|
||||
rule.setContent {
|
||||
var checkedState by remember { mutableStateOf(false) }
|
||||
CheckboxWithText(
|
||||
"Checkbox Label with Text",
|
||||
checkedState,
|
||||
onCheckedChange = {
|
||||
checkedState = it
|
||||
},
|
||||
toolTipText = "Test Tooltip"
|
||||
)
|
||||
}
|
||||
|
||||
// Check For Label Text
|
||||
rule.onNodeWithTag(TestTags.TEXT_TAG).assertTextEquals("Checkbox Label with Text")
|
||||
|
||||
// Verify checkbox toggle
|
||||
rule.onNodeWithTag(TestTags.CHECKBOX_TAG).performClick()
|
||||
rule.onNodeWithTag(TestTags.CHECKBOX_TAG).assertIsOn()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `check checkbox toggle functionality`() {
|
||||
rule.setContent {
|
||||
var checkedState by remember { mutableStateOf(false) }
|
||||
CheckboxWithText(
|
||||
"Checkbox Label with Text",
|
||||
checkedState,
|
||||
onCheckedChange = {
|
||||
checkedState = it
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// Verify checkbox toggle
|
||||
val checkbox = rule.onNodeWithTag(TestTags.CHECKBOX_TAG)
|
||||
checkbox.performClick()
|
||||
checkbox.assertIsOn()
|
||||
checkbox.performClick()
|
||||
checkbox.assertIsOff()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user