|
|
@ -19,14 +19,17 @@ package com.google.samples.apps.nowinandroid.ui
|
|
|
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
|
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
|
|
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
|
|
|
|
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowSizeClass
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowSizeClass
|
|
|
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.ui.test.assertIsDisplayed
|
|
|
|
import androidx.compose.ui.test.assertIsDisplayed
|
|
|
|
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
|
|
|
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
|
|
|
import androidx.compose.ui.test.onNodeWithTag
|
|
|
|
import androidx.compose.ui.test.onNodeWithTag
|
|
|
|
|
|
|
|
import androidx.compose.ui.unit.Dp
|
|
|
|
import androidx.compose.ui.unit.DpSize
|
|
|
|
import androidx.compose.ui.unit.DpSize
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import com.google.accompanist.testharness.TestHarness
|
|
|
|
import com.google.accompanist.testharness.TestHarness
|
|
|
|
import com.google.samples.apps.nowinandroid.core.data.repository.CompositeUserNewsResourceRepository
|
|
|
|
import com.google.samples.apps.nowinandroid.core.data.repository.CompositeUserNewsResourceRepository
|
|
|
|
import com.google.samples.apps.nowinandroid.core.data.util.NetworkMonitor
|
|
|
|
import com.google.samples.apps.nowinandroid.core.data.util.NetworkMonitor
|
|
|
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.data.util.TimeZoneMonitor
|
|
|
|
import com.google.samples.apps.nowinandroid.core.rules.GrantPostNotificationsPermissionRule
|
|
|
|
import com.google.samples.apps.nowinandroid.core.rules.GrantPostNotificationsPermissionRule
|
|
|
|
import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository
|
|
|
|
import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository
|
|
|
|
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
|
|
|
|
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
|
|
|
@ -81,6 +84,9 @@ class NavigationUiTest {
|
|
|
|
@Inject
|
|
|
|
@Inject
|
|
|
|
lateinit var networkMonitor: NetworkMonitor
|
|
|
|
lateinit var networkMonitor: NetworkMonitor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
|
|
|
|
lateinit var timeZoneMonitor: TimeZoneMonitor
|
|
|
|
|
|
|
|
|
|
|
|
@Before
|
|
|
|
@Before
|
|
|
|
fun setup() {
|
|
|
|
fun setup() {
|
|
|
|
hiltRule.inject()
|
|
|
|
hiltRule.inject()
|
|
|
@ -91,13 +97,7 @@ class NavigationUiTest {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(400.dp, 400.dp)) {
|
|
|
|
TestHarness(size = DpSize(400.dp, 400.dp)) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
|
|
|
|
DpSize(maxWidth, maxHeight),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
networkMonitor = networkMonitor,
|
|
|
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -111,13 +111,7 @@ class NavigationUiTest {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(610.dp, 400.dp)) {
|
|
|
|
TestHarness(size = DpSize(610.dp, 400.dp)) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
|
|
|
|
DpSize(maxWidth, maxHeight),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
networkMonitor = networkMonitor,
|
|
|
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -131,13 +125,7 @@ class NavigationUiTest {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(900.dp, 400.dp)) {
|
|
|
|
TestHarness(size = DpSize(900.dp, 400.dp)) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
|
|
|
|
DpSize(maxWidth, maxHeight),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
networkMonitor = networkMonitor,
|
|
|
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -151,13 +139,7 @@ class NavigationUiTest {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(400.dp, 500.dp)) {
|
|
|
|
TestHarness(size = DpSize(400.dp, 500.dp)) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
|
|
|
|
DpSize(maxWidth, maxHeight),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
networkMonitor = networkMonitor,
|
|
|
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -171,13 +153,7 @@ class NavigationUiTest {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(610.dp, 500.dp)) {
|
|
|
|
TestHarness(size = DpSize(610.dp, 500.dp)) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
|
|
|
|
DpSize(maxWidth, maxHeight),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
networkMonitor = networkMonitor,
|
|
|
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -191,13 +167,7 @@ class NavigationUiTest {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(900.dp, 500.dp)) {
|
|
|
|
TestHarness(size = DpSize(900.dp, 500.dp)) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
|
|
|
|
DpSize(maxWidth, maxHeight),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
networkMonitor = networkMonitor,
|
|
|
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -211,13 +181,7 @@ class NavigationUiTest {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(400.dp, 1000.dp)) {
|
|
|
|
TestHarness(size = DpSize(400.dp, 1000.dp)) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
|
|
|
|
DpSize(maxWidth, maxHeight),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
networkMonitor = networkMonitor,
|
|
|
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -231,13 +195,7 @@ class NavigationUiTest {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(610.dp, 1000.dp)) {
|
|
|
|
TestHarness(size = DpSize(610.dp, 1000.dp)) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
|
|
|
|
DpSize(maxWidth, maxHeight),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
networkMonitor = networkMonitor,
|
|
|
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -251,13 +209,7 @@ class NavigationUiTest {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(900.dp, 1000.dp)) {
|
|
|
|
TestHarness(size = DpSize(900.dp, 1000.dp)) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
|
|
|
|
DpSize(maxWidth, maxHeight),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
networkMonitor = networkMonitor,
|
|
|
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -265,4 +217,12 @@ class NavigationUiTest {
|
|
|
|
composeTestRule.onNodeWithTag("NiaNavRail").assertIsDisplayed()
|
|
|
|
composeTestRule.onNodeWithTag("NiaNavRail").assertIsDisplayed()
|
|
|
|
composeTestRule.onNodeWithTag("NiaBottomBar").assertDoesNotExist()
|
|
|
|
composeTestRule.onNodeWithTag("NiaBottomBar").assertDoesNotExist()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
|
|
|
private fun fakeAppState(maxWidth: Dp, maxHeight: Dp) = rememberNiaAppState(
|
|
|
|
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(DpSize(maxWidth, maxHeight)),
|
|
|
|
|
|
|
|
networkMonitor = networkMonitor,
|
|
|
|
|
|
|
|
userNewsResourceRepository = userNewsResourceRepository,
|
|
|
|
|
|
|
|
timeZoneMonitor = timeZoneMonitor,
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|