Skip to content

Commit 59dc71c

Browse files
authored
Merge pull request #29 from android/test-refactoring
Minor refactoring of testing code
2 parents 1c9ac80 + 064dd30 commit 59dc71c

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed
Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.example.cahier
22

3+
import androidx.compose.runtime.Composable
34
import androidx.compose.ui.test.DeviceConfigurationOverride
45
import androidx.compose.ui.test.ForcedSize
56
import androidx.compose.ui.test.junit4.createComposeRule
@@ -25,19 +26,9 @@ class CahierListDetailTest {
2526
fun homeScreen_showListOnly() {
2627
composeTestRule.setContent {
2728
DeviceConfigurationOverride(
28-
DeviceConfigurationOverride.ForcedSize(
29-
DpSize(
30-
width = 400.dp,
31-
height = 900.dp
32-
)
33-
)
29+
DeviceConfigurationOverride.ForcedSize(compatWidthWindow)
3430
) {
35-
HomePane(
36-
navigateToCanvas = { _ -> },
37-
navigateToDrawingCanvas = { _ -> },
38-
navigateUp = {},
39-
homeScreenViewModel = fakeViewModel
40-
)
31+
HomeContent()
4132
}
4233
}
4334

@@ -49,23 +40,34 @@ class CahierListDetailTest {
4940
fun homeScreen_showListAndDetail() {
5041
composeTestRule.setContent {
5142
DeviceConfigurationOverride(
52-
DeviceConfigurationOverride.ForcedSize(
53-
DpSize(
54-
width = 1200.dp,
55-
height = 900.dp
56-
)
57-
)
43+
DeviceConfigurationOverride.ForcedSize(mediumWidthWindow)
5844
) {
59-
HomePane(
60-
navigateToCanvas = { _ -> },
61-
navigateToDrawingCanvas = { _ -> },
62-
navigateUp = {},
63-
homeScreenViewModel = fakeViewModel
64-
)
45+
HomeContent()
6546
}
6647
}
6748

6849
composeTestRule.onNodeWithTag("List").assertExists()
6950
composeTestRule.onNodeWithTag("Detail").assertExists()
7051
}
52+
53+
54+
private val mediumWidthWindow = DpSize(
55+
width = 1200.dp,
56+
height = 900.dp
57+
)
58+
59+
private val compatWidthWindow = DpSize(
60+
width = 400.dp,
61+
height = 900.dp
62+
)
63+
64+
@Composable
65+
private fun HomeContent() {
66+
HomePane(
67+
navigateToCanvas = { _ -> },
68+
navigateToDrawingCanvas = { _ -> },
69+
navigateUp = {},
70+
homeScreenViewModel = fakeViewModel
71+
)
72+
}
7173
}

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ agp = "8.13.0"
33
appcompatV7 = "1.7.1"
44
coilCompose = "3.3.0"
55
foundation = "1.9.2"
6-
gson = "2.13.2"
76
hiltAndroid = "2.57.1"
87
hiltNavigationCompose = "1.3.0"
98
ink = "1.0.0-beta01"
@@ -54,7 +53,6 @@ appcompat-v7 = { module = "androidx.appcompat:appcompat", version.ref = "appcomp
5453
appcompat-v7-resources = { module = "androidx.appcompat:appcompat-resources", version.ref = "appcompatV7" }
5554
coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coilCompose" }
5655
coil-network-okhttp = { module = "io.coil-kt.coil3:coil-network-okhttp", version.ref = "coilCompose" }
57-
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
5856
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hiltAndroid" }
5957
hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hiltAndroid" }
6058
junit = { group = "junit", name = "junit", version.ref = "junit" }

0 commit comments

Comments
 (0)