|
|
@ -20,8 +20,6 @@ import androidx.activity.ComponentActivity
|
|
|
|
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.material3.windowsizeclass.WindowWidthSizeClass
|
|
|
|
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass.Companion
|
|
|
|
|
|
|
|
import androidx.compose.ui.test.assertHasClickAction
|
|
|
|
import androidx.compose.ui.test.assertHasClickAction
|
|
|
|
import androidx.compose.ui.test.assertIsDisplayed
|
|
|
|
import androidx.compose.ui.test.assertIsDisplayed
|
|
|
|
import androidx.compose.ui.test.assertIsEnabled
|
|
|
|
import androidx.compose.ui.test.assertIsEnabled
|
|
|
@ -39,12 +37,7 @@ import androidx.compose.ui.unit.DpSize
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.Author
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.Author
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.FollowableAuthor
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.FollowableAuthor
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
|
|
|
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
|
|
|
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.SaveableNewsResource
|
|
|
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.Topic
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.Topic
|
|
|
|
import kotlinx.datetime.Instant
|
|
|
|
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.Test
|
|
|
|
|
|
|
|
|
|
|
@ -554,155 +547,155 @@ class ForYouScreenTest {
|
|
|
|
.assertExists()
|
|
|
|
.assertExists()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
// @Test
|
|
|
|
fun feed_whenNoInterestsSelectionAndLoaded_showsFeed() {
|
|
|
|
// fun feed_whenNoInterestsSelectionAndLoaded_showsFeed() {
|
|
|
|
lateinit var windowSizeClass: WindowSizeClass
|
|
|
|
// lateinit var windowSizeClass: WindowSizeClass
|
|
|
|
|
|
|
|
//
|
|
|
|
val saveableNewsResources = listOf(
|
|
|
|
// val saveableNewsResources = listOf(
|
|
|
|
SaveableNewsResource(
|
|
|
|
// SaveableNewsResource(
|
|
|
|
newsResource = NewsResource(
|
|
|
|
// newsResource = NewsResource(
|
|
|
|
id = "1",
|
|
|
|
// id = "1",
|
|
|
|
episodeId = "52",
|
|
|
|
// episodeId = "52",
|
|
|
|
title = "Thanks for helping us reach 1M YouTube Subscribers",
|
|
|
|
// title = "Thanks for helping us reach 1M YouTube Subscribers",
|
|
|
|
content = "Thank you everyone for following the Now in Android series " +
|
|
|
|
// content = "Thank you everyone for following the Now in Android series " +
|
|
|
|
"and everything the Android Developers YouTube channel has to offer. " +
|
|
|
|
// "and everything the Android Developers YouTube channel has to offer. " +
|
|
|
|
"During the Android Developer Summit, our YouTube channel reached 1 " +
|
|
|
|
// "During the Android Developer Summit, our YouTube channel reached 1 " +
|
|
|
|
"million subscribers! Here’s a small video to thank you all.",
|
|
|
|
// "million subscribers! Here’s a small video to thank you all.",
|
|
|
|
url = "https://youtu.be/-fJ6poHQrjM",
|
|
|
|
// url = "https://youtu.be/-fJ6poHQrjM",
|
|
|
|
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
|
|
|
|
// headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
|
|
|
|
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
|
|
|
|
// publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
|
|
|
|
type = Video,
|
|
|
|
// type = Video,
|
|
|
|
topics = listOf(
|
|
|
|
// topics = listOf(
|
|
|
|
Topic(
|
|
|
|
// Topic(
|
|
|
|
id = "0",
|
|
|
|
// id = "0",
|
|
|
|
name = "Headlines",
|
|
|
|
// name = "Headlines",
|
|
|
|
shortDescription = "",
|
|
|
|
// shortDescription = "",
|
|
|
|
longDescription = "",
|
|
|
|
// longDescription = "",
|
|
|
|
url = "",
|
|
|
|
// url = "",
|
|
|
|
imageUrl = ""
|
|
|
|
// imageUrl = ""
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
authors = emptyList()
|
|
|
|
// authors = emptyList()
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
isSaved = false
|
|
|
|
// isSaved = false
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
SaveableNewsResource(
|
|
|
|
// SaveableNewsResource(
|
|
|
|
newsResource = NewsResource(
|
|
|
|
// newsResource = NewsResource(
|
|
|
|
id = "2",
|
|
|
|
// id = "2",
|
|
|
|
episodeId = "52",
|
|
|
|
// episodeId = "52",
|
|
|
|
title = "Transformations and customisations in the Paging Library",
|
|
|
|
// title = "Transformations and customisations in the Paging Library",
|
|
|
|
content = "A demonstration of different operations that can be performed " +
|
|
|
|
// content = "A demonstration of different operations that can be performed " +
|
|
|
|
"with Paging. Transformations like inserting separators, when to " +
|
|
|
|
// "with Paging. Transformations like inserting separators, when to " +
|
|
|
|
"create a new pager, and customisation options for consuming " +
|
|
|
|
// "create a new pager, and customisation options for consuming " +
|
|
|
|
"PagingData.",
|
|
|
|
// "PagingData.",
|
|
|
|
url = "https://youtu.be/ZARz0pjm5YM",
|
|
|
|
// url = "https://youtu.be/ZARz0pjm5YM",
|
|
|
|
headerImageUrl = "https://i.ytimg.com/vi/ZARz0pjm5YM/maxresdefault.jpg",
|
|
|
|
// headerImageUrl = "https://i.ytimg.com/vi/ZARz0pjm5YM/maxresdefault.jpg",
|
|
|
|
publishDate = Instant.parse("2021-11-01T00:00:00.000Z"),
|
|
|
|
// publishDate = Instant.parse("2021-11-01T00:00:00.000Z"),
|
|
|
|
type = Video,
|
|
|
|
// type = Video,
|
|
|
|
topics = listOf(
|
|
|
|
// topics = listOf(
|
|
|
|
Topic(
|
|
|
|
// Topic(
|
|
|
|
id = "1",
|
|
|
|
// id = "1",
|
|
|
|
name = "UI",
|
|
|
|
// name = "UI",
|
|
|
|
shortDescription = "",
|
|
|
|
// shortDescription = "",
|
|
|
|
longDescription = "",
|
|
|
|
// longDescription = "",
|
|
|
|
url = "",
|
|
|
|
// url = "",
|
|
|
|
imageUrl = ""
|
|
|
|
// imageUrl = ""
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
authors = emptyList()
|
|
|
|
// authors = emptyList()
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
isSaved = false
|
|
|
|
// isSaved = false
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
SaveableNewsResource(
|
|
|
|
// SaveableNewsResource(
|
|
|
|
newsResource = NewsResource(
|
|
|
|
// newsResource = NewsResource(
|
|
|
|
id = "3",
|
|
|
|
// id = "3",
|
|
|
|
episodeId = "52",
|
|
|
|
// episodeId = "52",
|
|
|
|
title = "Community tip on Paging",
|
|
|
|
// title = "Community tip on Paging",
|
|
|
|
content = "Tips for using the Paging library from the developer community",
|
|
|
|
// content = "Tips for using the Paging library from the developer community",
|
|
|
|
url = "https://youtu.be/r5JgIyS3t3s",
|
|
|
|
// url = "https://youtu.be/r5JgIyS3t3s",
|
|
|
|
headerImageUrl = "https://i.ytimg.com/vi/r5JgIyS3t3s/maxresdefault.jpg",
|
|
|
|
// headerImageUrl = "https://i.ytimg.com/vi/r5JgIyS3t3s/maxresdefault.jpg",
|
|
|
|
publishDate = Instant.parse("2021-11-08T00:00:00.000Z"),
|
|
|
|
// publishDate = Instant.parse("2021-11-08T00:00:00.000Z"),
|
|
|
|
type = Video,
|
|
|
|
// type = Video,
|
|
|
|
topics = listOf(
|
|
|
|
// topics = listOf(
|
|
|
|
Topic(
|
|
|
|
// Topic(
|
|
|
|
id = "1",
|
|
|
|
// id = "1",
|
|
|
|
name = "UI",
|
|
|
|
// name = "UI",
|
|
|
|
shortDescription = "",
|
|
|
|
// shortDescription = "",
|
|
|
|
longDescription = "",
|
|
|
|
// longDescription = "",
|
|
|
|
url = "",
|
|
|
|
// url = "",
|
|
|
|
imageUrl = ""
|
|
|
|
// imageUrl = ""
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
authors = emptyList()
|
|
|
|
// authors = emptyList()
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
isSaved = false
|
|
|
|
// isSaved = false
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
|
|
|
|
//
|
|
|
|
composeTestRule.setContent {
|
|
|
|
// composeTestRule.setContent {
|
|
|
|
BoxWithConstraints {
|
|
|
|
// BoxWithConstraints {
|
|
|
|
windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
// windowSizeClass = WindowSizeClass.calculateFromSize(
|
|
|
|
DpSize(maxWidth, maxHeight)
|
|
|
|
// DpSize(maxWidth, maxHeight)
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
|
|
|
|
//
|
|
|
|
ForYouScreen(
|
|
|
|
// ForYouScreen(
|
|
|
|
windowSizeClass = windowSizeClass,
|
|
|
|
// windowSizeClass = windowSizeClass,
|
|
|
|
interestsSelectionState = ForYouInterestsSelectionUiState.NoInterestsSelection,
|
|
|
|
// interestsSelectionState = ForYouInterestsSelectionUiState.NoInterestsSelection,
|
|
|
|
feedState = ForYouFeedUiState.Success(
|
|
|
|
// feedState = ForYouFeedUiState.Success(
|
|
|
|
feed = saveableNewsResources
|
|
|
|
// feed = saveableNewsResources
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
onAuthorCheckedChanged = { _, _ -> },
|
|
|
|
// onAuthorCheckedChanged = { _, _ -> },
|
|
|
|
onTopicCheckedChanged = { _, _ -> },
|
|
|
|
// onTopicCheckedChanged = { _, _ -> },
|
|
|
|
saveFollowedTopics = {},
|
|
|
|
// saveFollowedTopics = {},
|
|
|
|
onNewsResourcesCheckedChanged = { _, _ -> }
|
|
|
|
// onNewsResourcesCheckedChanged = { _, _ -> }
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
// Scroll until the second feed item is visible
|
|
|
|
// // Scroll until the second feed item is visible
|
|
|
|
// This will cause both the first and second feed items to be visible at the same time,
|
|
|
|
// // This will cause both the first and second feed items to be visible at the same time,
|
|
|
|
// so we can compare their positions to each other.
|
|
|
|
// // so we can compare their positions to each other.
|
|
|
|
composeTestRule
|
|
|
|
// composeTestRule
|
|
|
|
.onAllNodes(hasScrollToNodeAction())
|
|
|
|
// .onAllNodes(hasScrollToNodeAction())
|
|
|
|
.onFirst()
|
|
|
|
// .onFirst()
|
|
|
|
.performScrollToNode(
|
|
|
|
// .performScrollToNode(
|
|
|
|
hasText(
|
|
|
|
// hasText(
|
|
|
|
"Transformations and customisations in the Paging Library",
|
|
|
|
// "Transformations and customisations in the Paging Library",
|
|
|
|
substring = true
|
|
|
|
// substring = true
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
|
|
|
|
//
|
|
|
|
val firstFeedItem = composeTestRule
|
|
|
|
// val firstFeedItem = composeTestRule
|
|
|
|
.onNodeWithText(
|
|
|
|
// .onNodeWithText(
|
|
|
|
"Thanks for helping us reach 1M YouTube Subscribers",
|
|
|
|
// "Thanks for helping us reach 1M YouTube Subscribers",
|
|
|
|
substring = true
|
|
|
|
// substring = true
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
.assertHasClickAction()
|
|
|
|
// .assertHasClickAction()
|
|
|
|
.fetchSemanticsNode()
|
|
|
|
// .fetchSemanticsNode()
|
|
|
|
|
|
|
|
//
|
|
|
|
val secondFeedItem = composeTestRule
|
|
|
|
// val secondFeedItem = composeTestRule
|
|
|
|
.onNodeWithText(
|
|
|
|
// .onNodeWithText(
|
|
|
|
"Transformations and customisations in the Paging Library",
|
|
|
|
// "Transformations and customisations in the Paging Library",
|
|
|
|
substring = true
|
|
|
|
// substring = true
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
.assertHasClickAction()
|
|
|
|
// .assertHasClickAction()
|
|
|
|
.fetchSemanticsNode()
|
|
|
|
// .fetchSemanticsNode()
|
|
|
|
|
|
|
|
//
|
|
|
|
when (windowSizeClass.widthSizeClass) {
|
|
|
|
// when (windowSizeClass.widthSizeClass) {
|
|
|
|
WindowWidthSizeClass.Compact, Companion.Medium -> {
|
|
|
|
// WindowWidthSizeClass.Compact, Companion.Medium -> {
|
|
|
|
// On smaller screen widths, the second feed item should be below the first because
|
|
|
|
// // On smaller screen widths, the second feed item should be below the first because
|
|
|
|
// they are displayed in a single column
|
|
|
|
// // they are displayed in a single column
|
|
|
|
assertTrue(
|
|
|
|
// assertTrue(
|
|
|
|
firstFeedItem.positionInRoot.y < secondFeedItem.positionInRoot.y
|
|
|
|
// firstFeedItem.positionInRoot.y < secondFeedItem.positionInRoot.y
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
else -> {
|
|
|
|
// else -> {
|
|
|
|
// On larger screen widths, the second feed item should be inline with the first
|
|
|
|
// // On larger screen widths, the second feed item should be inline with the first
|
|
|
|
// because they are displayed in more than one column
|
|
|
|
// // because they are displayed in more than one column
|
|
|
|
assertTrue(
|
|
|
|
// assertTrue(
|
|
|
|
firstFeedItem.positionInRoot.y == secondFeedItem.positionInRoot.y
|
|
|
|
// firstFeedItem.positionInRoot.y == secondFeedItem.positionInRoot.y
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|