|
|
|
@ -17,14 +17,19 @@
|
|
|
|
|
package com.google.samples.apps.nowinandroid.feature.foryou
|
|
|
|
|
|
|
|
|
|
import androidx.activity.ComponentActivity
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaBackground
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.testing.util.DefaultTestDevices
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.testing.util.captureForDevice
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.testing.util.captureMultiDevice
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Success
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.UserNewsResourcePreviewParameterProvider
|
|
|
|
|
import com.google.samples.apps.nowinandroid.feature.foryou.OnboardingUiState.Loading
|
|
|
|
|
import com.google.samples.apps.nowinandroid.feature.foryou.OnboardingUiState.NotShown
|
|
|
|
|
import com.google.samples.apps.nowinandroid.feature.foryou.OnboardingUiState.Shown
|
|
|
|
|
import dagger.hilt.android.testing.HiltTestApplication
|
|
|
|
|
import org.junit.Before
|
|
|
|
|
import org.junit.Rule
|
|
|
|
@ -60,7 +65,7 @@ class ForYouScreenScreenshotTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun testForYouScreenPopulatedFeed() {
|
|
|
|
|
fun forYouScreenPopulatedFeed() {
|
|
|
|
|
composeTestRule.captureMultiDevice("ForYouScreenPopulatedFeed") {
|
|
|
|
|
NiaTheme {
|
|
|
|
|
ForYouScreen(
|
|
|
|
@ -82,7 +87,7 @@ class ForYouScreenScreenshotTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun testForYouScreenLoading() {
|
|
|
|
|
fun forYouScreenLoading() {
|
|
|
|
|
composeTestRule.captureMultiDevice("ForYouScreenLoading") {
|
|
|
|
|
NiaTheme {
|
|
|
|
|
ForYouScreen(
|
|
|
|
@ -102,16 +107,54 @@ class ForYouScreenScreenshotTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun testForYouScreenTopicSelection() {
|
|
|
|
|
fun forYouScreenTopicSelection() {
|
|
|
|
|
composeTestRule.captureMultiDevice("ForYouScreenTopicSelection") {
|
|
|
|
|
ForYouScreenTopicSelection()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun forYouScreenTopicSelection_dark() {
|
|
|
|
|
composeTestRule.captureForDevice(
|
|
|
|
|
deviceName = "phone_dark",
|
|
|
|
|
deviceSpec = DefaultTestDevices.PHONE.spec,
|
|
|
|
|
screenshotName = "ForYouScreenTopicSelection",
|
|
|
|
|
darkMode = true,
|
|
|
|
|
) {
|
|
|
|
|
ForYouScreenTopicSelection()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun forYouScreenPopulatedAndLoading() {
|
|
|
|
|
composeTestRule.captureMultiDevice("ForYouScreenPopulatedAndLoading") {
|
|
|
|
|
ForYouScreenPopulatedAndLoading()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun forYouScreenPopulatedAndLoading_dark() {
|
|
|
|
|
composeTestRule.captureForDevice(
|
|
|
|
|
deviceName = "phone_dark",
|
|
|
|
|
deviceSpec = DefaultTestDevices.PHONE.spec,
|
|
|
|
|
screenshotName = "ForYouScreenPopulatedAndLoading",
|
|
|
|
|
darkMode = true,
|
|
|
|
|
) {
|
|
|
|
|
ForYouScreenPopulatedAndLoading()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
private fun ForYouScreenTopicSelection() {
|
|
|
|
|
NiaTheme {
|
|
|
|
|
NiaBackground {
|
|
|
|
|
ForYouScreen(
|
|
|
|
|
isSyncing = false,
|
|
|
|
|
onboardingUiState = OnboardingUiState.Shown(
|
|
|
|
|
onboardingUiState = Shown(
|
|
|
|
|
topics = userNewsResources.flatMap { news -> news.followableTopics }
|
|
|
|
|
.distinctBy { it.topic.id },
|
|
|
|
|
),
|
|
|
|
|
feedState = NewsFeedUiState.Success(
|
|
|
|
|
feedState = Success(
|
|
|
|
|
feed = userNewsResources,
|
|
|
|
|
),
|
|
|
|
|
onTopicCheckedChanged = { _, _ -> },
|
|
|
|
@ -126,14 +169,15 @@ class ForYouScreenScreenshotTests {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun testForYouScreenPopulatedAndLoading() {
|
|
|
|
|
composeTestRule.captureMultiDevice("ForYouScreenPopulatedAndLoading") {
|
|
|
|
|
@Composable
|
|
|
|
|
private fun ForYouScreenPopulatedAndLoading() {
|
|
|
|
|
NiaTheme {
|
|
|
|
|
NiaBackground {
|
|
|
|
|
NiaTheme {
|
|
|
|
|
ForYouScreen(
|
|
|
|
|
isSyncing = true,
|
|
|
|
|
onboardingUiState = OnboardingUiState.Loading,
|
|
|
|
|
feedState = NewsFeedUiState.Success(
|
|
|
|
|
onboardingUiState = Loading,
|
|
|
|
|
feedState = Success(
|
|
|
|
|
feed = userNewsResources,
|
|
|
|
|
),
|
|
|
|
|
onTopicCheckedChanged = { _, _ -> },
|
|
|
|
@ -148,3 +192,4 @@ class ForYouScreenScreenshotTests {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|