|
|
@ -19,12 +19,13 @@ 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.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.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.rules.GrantPostNotificationsPermissionRule
|
|
|
|
import com.google.samples.apps.nowinandroid.core.rules.GrantPostNotificationsPermissionRule
|
|
|
@ -89,7 +90,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(
|
|
|
|
NiaApp(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
@ -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(
|
|
|
|
NiaApp(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
@ -129,7 +134,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(
|
|
|
|
NiaApp(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
@ -149,7 +156,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(
|
|
|
|
NiaApp(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
@ -169,7 +178,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(
|
|
|
|
NiaApp(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
@ -189,7 +200,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(
|
|
|
|
NiaApp(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
@ -209,7 +222,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(
|
|
|
|
NiaApp(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
@ -229,7 +244,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(
|
|
|
|
NiaApp(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
@ -249,7 +266,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(
|
|
|
|
NiaApp(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|