|
|
@ -17,14 +17,19 @@
|
|
|
|
package com.google.samples.apps.nowinandroid.feature.foryou
|
|
|
|
package com.google.samples.apps.nowinandroid.feature.foryou
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.activity.ComponentActivity
|
|
|
|
import androidx.activity.ComponentActivity
|
|
|
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
|
|
|
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.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.testing.util.captureMultiDevice
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
|
|
|
|
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.NewsFeedUiState.Success
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.UserNewsResourcePreviewParameterProvider
|
|
|
|
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.Loading
|
|
|
|
import com.google.samples.apps.nowinandroid.feature.foryou.OnboardingUiState.NotShown
|
|
|
|
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 dagger.hilt.android.testing.HiltTestApplication
|
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Rule
|
|
|
@ -60,7 +65,7 @@ class ForYouScreenScreenshotTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun testForYouScreenPopulatedFeed() {
|
|
|
|
fun forYouScreenPopulatedFeed() {
|
|
|
|
composeTestRule.captureMultiDevice("ForYouScreenPopulatedFeed") {
|
|
|
|
composeTestRule.captureMultiDevice("ForYouScreenPopulatedFeed") {
|
|
|
|
NiaTheme {
|
|
|
|
NiaTheme {
|
|
|
|
ForYouScreen(
|
|
|
|
ForYouScreen(
|
|
|
@ -82,7 +87,7 @@ class ForYouScreenScreenshotTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun testForYouScreenLoading() {
|
|
|
|
fun forYouScreenLoading() {
|
|
|
|
composeTestRule.captureMultiDevice("ForYouScreenLoading") {
|
|
|
|
composeTestRule.captureMultiDevice("ForYouScreenLoading") {
|
|
|
|
NiaTheme {
|
|
|
|
NiaTheme {
|
|
|
|
ForYouScreen(
|
|
|
|
ForYouScreen(
|
|
|
@ -102,16 +107,54 @@ class ForYouScreenScreenshotTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun testForYouScreenTopicSelection() {
|
|
|
|
fun forYouScreenTopicSelection() {
|
|
|
|
composeTestRule.captureMultiDevice("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 {
|
|
|
|
NiaTheme {
|
|
|
|
|
|
|
|
NiaBackground {
|
|
|
|
ForYouScreen(
|
|
|
|
ForYouScreen(
|
|
|
|
isSyncing = false,
|
|
|
|
isSyncing = false,
|
|
|
|
onboardingUiState = OnboardingUiState.Shown(
|
|
|
|
onboardingUiState = Shown(
|
|
|
|
topics = userNewsResources.flatMap { news -> news.followableTopics }
|
|
|
|
topics = userNewsResources.flatMap { news -> news.followableTopics }
|
|
|
|
.distinctBy { it.topic.id },
|
|
|
|
.distinctBy { it.topic.id },
|
|
|
|
),
|
|
|
|
),
|
|
|
|
feedState = NewsFeedUiState.Success(
|
|
|
|
feedState = Success(
|
|
|
|
feed = userNewsResources,
|
|
|
|
feed = userNewsResources,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTopicCheckedChanged = { _, _ -> },
|
|
|
|
onTopicCheckedChanged = { _, _ -> },
|
|
|
@ -126,14 +169,15 @@ class ForYouScreenScreenshotTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Composable
|
|
|
|
fun testForYouScreenPopulatedAndLoading() {
|
|
|
|
private fun ForYouScreenPopulatedAndLoading() {
|
|
|
|
composeTestRule.captureMultiDevice("ForYouScreenPopulatedAndLoading") {
|
|
|
|
NiaTheme {
|
|
|
|
|
|
|
|
NiaBackground {
|
|
|
|
NiaTheme {
|
|
|
|
NiaTheme {
|
|
|
|
ForYouScreen(
|
|
|
|
ForYouScreen(
|
|
|
|
isSyncing = true,
|
|
|
|
isSyncing = true,
|
|
|
|
onboardingUiState = OnboardingUiState.Loading,
|
|
|
|
onboardingUiState = Loading,
|
|
|
|
feedState = NewsFeedUiState.Success(
|
|
|
|
feedState = Success(
|
|
|
|
feed = userNewsResources,
|
|
|
|
feed = userNewsResources,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTopicCheckedChanged = { _, _ -> },
|
|
|
|
onTopicCheckedChanged = { _, _ -> },
|
|
|
@ -147,4 +191,5 @@ class ForYouScreenScreenshotTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|