Skip to content

Commit

Permalink
[gradle] Small refactor gradle compose resources ui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
terrakok committed Aug 28, 2024
1 parent f7e5a77 commit 662f4fd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,21 @@ import kotlin.test.assertNotEquals
class CommonUiTest {

@Test
fun checkTestResources() {
runComposeUiTest {
setContent {
val mainStr = stringResource(Res.string.app_name)
val testStr = stringResource(Res.string.test_string)
assertEquals("Compose Resources App", mainStr)
assertEquals("Common test", testStr)
assertNotEquals("Compose Resources App", testStr)
}
fun checkTestResources() = runComposeUiTest {
setContent {
val mainStr = stringResource(Res.string.app_name)
val testStr = stringResource(Res.string.test_string)
assertEquals("Compose Resources App", mainStr)
assertEquals("Common test", testStr)
}
}

@Test
fun checkTestFileResource() {
runTest {
val commonFile = Res.readBytes("files/common.txt").decodeToString()
assertEquals("common 777", commonFile)
val testFile = Res.readBytes("files/data.txt").decodeToString()
assertEquals("1234567890", testFile)
}
fun checkTestFileResource() = runTest {
val commonFile = Res.readBytes("files/common.txt").decodeToString()
assertEquals("common 777", commonFile)
val testFile = Res.readBytes("files/data.txt").decodeToString()
assertEquals("1234567890", testFile)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ import kotlin.test.assertEquals
class DesktopUiTest {

@Test
fun checkTestResources() {
runComposeUiTest {
setContent {
val mainStr = stringResource(Res.string.app_name)
val testStr = stringResource(Res.string.test_string)
val desktopMainStr = stringResource(Res.string.desktop_str)
val desktopTestStr = stringResource(Res.string.desktop_test_str)
assertEquals("Compose Resources App", mainStr)
assertEquals("Common test", testStr)
assertEquals("Desktop string", desktopMainStr)
assertEquals("Desktop test string", desktopTestStr)
}
fun checkTestResources() = runComposeUiTest {
setContent {
val mainStr = stringResource(Res.string.app_name)
val testStr = stringResource(Res.string.test_string)
val desktopMainStr = stringResource(Res.string.desktop_str)
val desktopTestStr = stringResource(Res.string.desktop_test_str)
assertEquals("Compose Resources App", mainStr)
assertEquals("Common test", testStr)
assertEquals("Desktop string", desktopMainStr)
assertEquals("Desktop test string", desktopTestStr)
}
}

Expand Down

0 comments on commit 662f4fd

Please sign in to comment.