diff --git a/core-database/src/androidTest/java/com/google/samples/apps/nowinandroid/core/database/dao/NewsResourceDaoTest.kt b/core-database/src/androidTest/java/com/google/samples/apps/nowinandroid/core/database/dao/NewsResourceDaoTest.kt index 287aaeb47..362a10075 100644 --- a/core-database/src/androidTest/java/com/google/samples/apps/nowinandroid/core/database/dao/NewsResourceDaoTest.kt +++ b/core-database/src/androidTest/java/com/google/samples/apps/nowinandroid/core/database/dao/NewsResourceDaoTest.kt @@ -166,7 +166,10 @@ private fun testTopicEntity( ) = TopicEntity( id = id, name = name, - description = "", + shortDescription = "", + longDescription = "", + url = "", + imageUrl = "" ) private fun testNewsResource( diff --git a/feature-foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt b/feature-foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt index b4213c847..f8325966a 100644 --- a/feature-foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt +++ b/feature-foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt @@ -61,7 +61,10 @@ class ForYouScreenTest { topic = Topic( id = 0, name = "Headlines", - shortDescription = "" + shortDescription = "", + longDescription = "", + imageUrl = "", + url = "" ), isFollowed = false ), @@ -69,7 +72,10 @@ class ForYouScreenTest { topic = Topic( id = 1, name = "UI", - shortDescription = "" + shortDescription = "", + longDescription = "", + imageUrl = "", + url = "" ), isFollowed = false ), @@ -78,6 +84,9 @@ class ForYouScreenTest { id = 2, name = "Tools", shortDescription = "", + longDescription = "", + imageUrl = "", + url = "" ), isFollowed = false ), @@ -122,7 +131,10 @@ class ForYouScreenTest { topic = Topic( id = 0, name = "Headlines", - shortDescription = "" + shortDescription = "", + longDescription = "", + imageUrl = "", + url = "" ), isFollowed = false ), @@ -130,7 +142,10 @@ class ForYouScreenTest { topic = Topic( id = 1, name = "UI", - shortDescription = "" + shortDescription = "", + longDescription = "", + imageUrl = "", + url = "" ), isFollowed = true ), @@ -139,6 +154,9 @@ class ForYouScreenTest { id = 2, name = "Tools", shortDescription = "", + longDescription = "", + imageUrl = "", + url = "" ), isFollowed = false ), diff --git a/feature-topic/src/androidTest/java/com/google/samples/apps/nowinandroid/following/TopicScreenTest.kt b/feature-topic/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreenTest.kt similarity index 78% rename from feature-topic/src/androidTest/java/com/google/samples/apps/nowinandroid/following/TopicScreenTest.kt rename to feature-topic/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreenTest.kt index e6b0d5b24..5151c972c 100644 --- a/feature-topic/src/androidTest/java/com/google/samples/apps/nowinandroid/following/TopicScreenTest.kt +++ b/feature-topic/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreenTest.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.following +package com.google.samples.apps.nowinandroid.feature.topic import androidx.activity.ComponentActivity import androidx.compose.ui.test.junit4.createAndroidComposeRule @@ -24,11 +24,6 @@ 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.Topic -import com.google.samples.apps.nowinandroid.feature.topic.NewsUiState -import com.google.samples.apps.nowinandroid.feature.topic.R -import com.google.samples.apps.nowinandroid.feature.topic.TopicScreen -import com.google.samples.apps.nowinandroid.feature.topic.TopicScreenUiState -import com.google.samples.apps.nowinandroid.feature.topic.TopicUiState import kotlinx.datetime.Instant import org.junit.Before import org.junit.Rule @@ -57,10 +52,8 @@ class TopicScreenTest { fun niaLoadingIndicator_whenScreenIsLoading_showLoading() { composeTestRule.setContent { TopicScreen( - uiState = TopicScreenUiState( - topicState = TopicUiState.Loading, - newsState = NewsUiState.Loading - ), + topicState = TopicUiState.Loading, + newsState = NewsUiState.Loading, onBackClick = { }, onFollowClick = { } ) @@ -76,10 +69,8 @@ class TopicScreenTest { val testTopic = testTopics.first() composeTestRule.setContent { TopicScreen( - uiState = TopicScreenUiState( - topicState = TopicUiState.Success(testTopic), - newsState = NewsUiState.Loading - ), + topicState = TopicUiState.Success(testTopic), + newsState = NewsUiState.Loading, onBackClick = { }, onFollowClick = { } ) @@ -92,7 +83,7 @@ class TopicScreenTest { // Description is shown composeTestRule - .onNodeWithText(testTopic.topic.description) + .onNodeWithText(testTopic.topic.longDescription) .assertExists() } @@ -101,10 +92,8 @@ class TopicScreenTest { val testTopic = testTopics.first() composeTestRule.setContent { TopicScreen( - uiState = TopicScreenUiState( - topicState = TopicUiState.Loading, - newsState = NewsUiState.Success(sampleNewsResources) - ), + topicState = TopicUiState.Loading, + newsState = NewsUiState.Success(sampleNewsResources), onBackClick = { }, onFollowClick = { } ) @@ -120,10 +109,8 @@ class TopicScreenTest { val testTopic = testTopics.first() composeTestRule.setContent { TopicScreen( - uiState = TopicScreenUiState( - topicState = TopicUiState.Success(testTopic), - newsState = NewsUiState.Success(sampleNewsResources) - ), + topicState = TopicUiState.Success(testTopic), + newsState = NewsUiState.Success(sampleNewsResources), onBackClick = { }, onFollowClick = { } ) @@ -146,7 +133,10 @@ private val testTopics = listOf( Topic( id = 0, name = TOPIC_1_NAME, - description = TOPIC_DESC, + longDescription = TOPIC_DESC, + shortDescription = "", + imageUrl = "", + url = "" ), isFollowed = true ), @@ -154,7 +144,10 @@ private val testTopics = listOf( Topic( id = 1, name = TOPIC_2_NAME, - description = TOPIC_DESC + longDescription = TOPIC_DESC, + shortDescription = "", + imageUrl = "", + url = "" ), isFollowed = false ), @@ -162,7 +155,10 @@ private val testTopics = listOf( Topic( id = 2, name = TOPIC_3_NAME, - description = TOPIC_DESC + longDescription = TOPIC_DESC, + shortDescription = "", + imageUrl = "", + url = "" ), isFollowed = false ) @@ -187,7 +183,10 @@ private val sampleNewsResources = listOf( Topic( id = 0, name = "Headlines", - description = "" + shortDescription = "", + longDescription = "", + imageUrl = "", + url = "" ) ), authors = emptyList() diff --git a/feature-topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt b/feature-topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt index 9c8f08fca..96c201d5d 100644 --- a/feature-topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt +++ b/feature-topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt @@ -16,6 +16,7 @@ package com.google.samples.apps.nowinandroid.feature.topic +import androidx.annotation.VisibleForTesting import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -67,8 +68,9 @@ fun TopicRoute( ) } +@VisibleForTesting @Composable -private fun TopicScreen( +fun TopicScreen( topicState: TopicUiState, newsState: NewsUiState, onBackClick: () -> Unit, diff --git a/feature-topic/src/test/java/com/google/samples/apps/nowinandroid/following/TopicViewModelTest.kt b/feature-topic/src/test/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt similarity index 96% rename from feature-topic/src/test/java/com/google/samples/apps/nowinandroid/following/TopicViewModelTest.kt rename to feature-topic/src/test/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt index 0c87161f4..b9fec8ef2 100644 --- a/feature-topic/src/test/java/com/google/samples/apps/nowinandroid/following/TopicViewModelTest.kt +++ b/feature-topic/src/test/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.following +package com.google.samples.apps.nowinandroid.feature.topic import androidx.lifecycle.SavedStateHandle import app.cash.turbine.test @@ -25,10 +25,7 @@ import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.util.TestDispatcherRule -import com.google.samples.apps.nowinandroid.feature.topic.NewsUiState import com.google.samples.apps.nowinandroid.feature.topic.TopicDestinationsArgs.TOPIC_ID_ARG -import com.google.samples.apps.nowinandroid.feature.topic.TopicUiState -import com.google.samples.apps.nowinandroid.feature.topic.TopicViewModel import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant import org.junit.Assert.assertEquals diff --git a/sync/build.gradle b/sync/build.gradle index 4840816d1..f9ac28dab 100644 --- a/sync/build.gradle +++ b/sync/build.gradle @@ -55,4 +55,11 @@ dependencies { kapt libs.hilt.ext.compiler androidTestImplementation libs.androidx.work.testing + + configurations.configureEach { + resolutionStrategy { + // Temporary workaround for https://issuetracker.google.com/174733673 + force 'org.objenesis:objenesis:2.6' + } + } }