|
|
|
@ -17,7 +17,6 @@
|
|
|
|
|
package com.google.samples.apps.nowinandroid.feature.bookmarks
|
|
|
|
|
|
|
|
|
|
import androidx.activity.ComponentActivity
|
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowSizeClass
|
|
|
|
|
import androidx.compose.ui.test.assertCountEquals
|
|
|
|
|
import androidx.compose.ui.test.assertHasClickAction
|
|
|
|
|
import androidx.compose.ui.test.filter
|
|
|
|
@ -34,10 +33,11 @@ import androidx.compose.ui.test.performScrollToNode
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
|
|
|
|
|
import kotlin.test.assertEquals
|
|
|
|
|
import kotlin.test.assertTrue
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.R.string
|
|
|
|
|
import org.junit.Rule
|
|
|
|
|
import org.junit.Test
|
|
|
|
|
import kotlin.test.assertEquals
|
|
|
|
|
import kotlin.test.assertTrue
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* UI tests for [BookmarksScreen] composable.
|
|
|
|
@ -65,8 +65,6 @@ class BookmarksScreenTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun feed_whenHasBookmarks_showsBookmarks() {
|
|
|
|
|
lateinit var windowSizeClass: WindowSizeClass
|
|
|
|
|
|
|
|
|
|
composeTestRule.setContent {
|
|
|
|
|
BookmarksScreen(
|
|
|
|
|
feedState = NewsFeedUiState.Success(
|
|
|
|
@ -120,11 +118,8 @@ class BookmarksScreenTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
composeTestRule
|
|
|
|
|
.onAllNodesWithContentDescription(
|
|
|
|
|
composeTestRule.activity.getString(
|
|
|
|
|
com.google.samples.apps.nowinandroid.core.ui.R.string.unbookmark
|
|
|
|
|
)
|
|
|
|
|
).filter(
|
|
|
|
|
.onAllNodesWithContentDescription(composeTestRule.activity.getString(string.unbookmark))
|
|
|
|
|
.filter(
|
|
|
|
|
hasAnyAncestor(
|
|
|
|
|
hasText(
|
|
|
|
|
previewNewsResources[0].title,
|
|
|
|
@ -138,4 +133,26 @@ class BookmarksScreenTest {
|
|
|
|
|
|
|
|
|
|
assertTrue(removeFromBookmarksCalled)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun feed_whenHasNoBookmarks_showsEmptyState() {
|
|
|
|
|
composeTestRule.setContent {
|
|
|
|
|
BookmarksScreen(
|
|
|
|
|
feedState = NewsFeedUiState.Success(emptyList()),
|
|
|
|
|
removeFromBookmarks = { }
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
composeTestRule
|
|
|
|
|
.onNodeWithText(
|
|
|
|
|
composeTestRule.activity.getString(R.string.bookmarks_empty_error)
|
|
|
|
|
)
|
|
|
|
|
.assertExists()
|
|
|
|
|
|
|
|
|
|
composeTestRule
|
|
|
|
|
.onNodeWithText(
|
|
|
|
|
composeTestRule.activity.getString(R.string.bookmarks_empty_description)
|
|
|
|
|
)
|
|
|
|
|
.assertExists()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|