|
|
@ -20,13 +20,14 @@ 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.runtime.Composable
|
|
|
|
|
|
|
|
import androidx.compose.ui.test.DeviceConfigurationOverride
|
|
|
|
|
|
|
|
import androidx.compose.ui.test.ForcedSize
|
|
|
|
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.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.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.data.util.TimeZoneMonitor
|
|
|
@ -95,7 +96,9 @@ class NavigationUiTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun compactWidth_compactHeight_showsNavigationBar() {
|
|
|
|
fun compactWidth_compactHeight_showsNavigationBar() {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(400.dp, 400.dp)) {
|
|
|
|
DeviceConfigurationOverride(
|
|
|
|
|
|
|
|
DeviceConfigurationOverride.ForcedSize(DpSize(400.dp, 400.dp)),
|
|
|
|
|
|
|
|
) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -109,7 +112,9 @@ class NavigationUiTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun mediumWidth_compactHeight_showsNavigationRail() {
|
|
|
|
fun mediumWidth_compactHeight_showsNavigationRail() {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(610.dp, 400.dp)) {
|
|
|
|
DeviceConfigurationOverride(
|
|
|
|
|
|
|
|
DeviceConfigurationOverride.ForcedSize(DpSize(610.dp, 400.dp)),
|
|
|
|
|
|
|
|
) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -123,7 +128,9 @@ class NavigationUiTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun expandedWidth_compactHeight_showsNavigationRail() {
|
|
|
|
fun expandedWidth_compactHeight_showsNavigationRail() {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(900.dp, 400.dp)) {
|
|
|
|
DeviceConfigurationOverride(
|
|
|
|
|
|
|
|
DeviceConfigurationOverride.ForcedSize(DpSize(900.dp, 400.dp)),
|
|
|
|
|
|
|
|
) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -137,7 +144,9 @@ class NavigationUiTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun compactWidth_mediumHeight_showsNavigationBar() {
|
|
|
|
fun compactWidth_mediumHeight_showsNavigationBar() {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(400.dp, 500.dp)) {
|
|
|
|
DeviceConfigurationOverride(
|
|
|
|
|
|
|
|
DeviceConfigurationOverride.ForcedSize(DpSize(400.dp, 500.dp)),
|
|
|
|
|
|
|
|
) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -151,7 +160,9 @@ class NavigationUiTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun mediumWidth_mediumHeight_showsNavigationRail() {
|
|
|
|
fun mediumWidth_mediumHeight_showsNavigationRail() {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(610.dp, 500.dp)) {
|
|
|
|
DeviceConfigurationOverride(
|
|
|
|
|
|
|
|
DeviceConfigurationOverride.ForcedSize(DpSize(610.dp, 500.dp)),
|
|
|
|
|
|
|
|
) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -165,7 +176,9 @@ class NavigationUiTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun expandedWidth_mediumHeight_showsNavigationRail() {
|
|
|
|
fun expandedWidth_mediumHeight_showsNavigationRail() {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(900.dp, 500.dp)) {
|
|
|
|
DeviceConfigurationOverride(
|
|
|
|
|
|
|
|
DeviceConfigurationOverride.ForcedSize(DpSize(900.dp, 500.dp)),
|
|
|
|
|
|
|
|
) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -179,7 +192,9 @@ class NavigationUiTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun compactWidth_expandedHeight_showsNavigationBar() {
|
|
|
|
fun compactWidth_expandedHeight_showsNavigationBar() {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(400.dp, 1000.dp)) {
|
|
|
|
DeviceConfigurationOverride(
|
|
|
|
|
|
|
|
DeviceConfigurationOverride.ForcedSize(DpSize(400.dp, 1000.dp)),
|
|
|
|
|
|
|
|
) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -193,7 +208,9 @@ class NavigationUiTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun mediumWidth_expandedHeight_showsNavigationRail() {
|
|
|
|
fun mediumWidth_expandedHeight_showsNavigationRail() {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(610.dp, 1000.dp)) {
|
|
|
|
DeviceConfigurationOverride(
|
|
|
|
|
|
|
|
DeviceConfigurationOverride.ForcedSize(DpSize(610.dp, 1000.dp)),
|
|
|
|
|
|
|
|
) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -207,7 +224,9 @@ class NavigationUiTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun expandedWidth_expandedHeight_showsNavigationRail() {
|
|
|
|
fun expandedWidth_expandedHeight_showsNavigationRail() {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
composeTestRule.setContent {
|
|
|
|
TestHarness(size = DpSize(900.dp, 1000.dp)) {
|
|
|
|
DeviceConfigurationOverride(
|
|
|
|
|
|
|
|
DeviceConfigurationOverride.ForcedSize(DpSize(900.dp, 1000.dp)),
|
|
|
|
|
|
|
|
) {
|
|
|
|
BoxWithConstraints {
|
|
|
|
BoxWithConstraints {
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
NiaApp(fakeAppState(maxWidth, maxHeight))
|
|
|
|
}
|
|
|
|
}
|
|
|
|