pull/1094/head
lihenggui 1 year ago
parent ff599eac37
commit fb5bd225be

@ -35,6 +35,8 @@ abstract class AnalyticsModule {
companion object { companion object {
@Provides @Provides
@Singleton @Singleton
fun provideFirebaseAnalytics(): FirebaseAnalytics { return Firebase.analytics } fun provideFirebaseAnalytics(): FirebaseAnalytics {
return Firebase.analytics
}
} }
} }

@ -25,7 +25,7 @@ import kotlin.test.assertEquals
class ResultKtTest { class ResultKtTest {
@Test @Test
fun Result_catches_errors() = runTest { fun result_catches_errors() = runTest {
flow { flow {
emit(1) emit(1)
throw Exception("Test Done") throw Exception("Test Done")

@ -27,7 +27,7 @@ import kotlin.test.assertTrue
class IntToStringIdsMigrationTest { class IntToStringIdsMigrationTest {
@Test @Test
fun IntToStringIdsMigration_should_migrate_topic_ids() = runTest { fun intToStringIdsMigration_should_migrate_topic_ids() = runTest {
// Set up existing preferences with topic int ids // Set up existing preferences with topic int ids
val preMigrationUserPreferences = userPreferences { val preMigrationUserPreferences = userPreferences {
deprecatedIntFollowedTopicIds.addAll(listOf(1, 2, 3)) deprecatedIntFollowedTopicIds.addAll(listOf(1, 2, 3))
@ -56,7 +56,7 @@ class IntToStringIdsMigrationTest {
} }
@Test @Test
fun IntToStringIdsMigration_should_migrate_author_ids() = runTest { fun intToStringIdsMigration_should_migrate_author_ids() = runTest {
// Set up existing preferences with author int ids // Set up existing preferences with author int ids
val preMigrationUserPreferences = userPreferences { val preMigrationUserPreferences = userPreferences {
deprecatedIntFollowedAuthorIds.addAll(listOf(4, 5, 6)) deprecatedIntFollowedAuthorIds.addAll(listOf(4, 5, 6))

@ -24,7 +24,7 @@ import kotlin.test.assertTrue
class ListToMapMigrationTest { class ListToMapMigrationTest {
@Test @Test
fun ListToMapMigration_should_migrate_topic_ids() = runTest { fun listToMapMigration_should_migrate_topic_ids() = runTest {
// Set up existing preferences with topic ids // Set up existing preferences with topic ids
val preMigrationUserPreferences = userPreferences { val preMigrationUserPreferences = userPreferences {
deprecatedFollowedTopicIds.addAll(listOf("1", "2", "3")) deprecatedFollowedTopicIds.addAll(listOf("1", "2", "3"))
@ -50,7 +50,7 @@ class ListToMapMigrationTest {
} }
@Test @Test
fun ListToMapMigration_should_migrate_author_ids() = runTest { fun listToMapMigration_should_migrate_author_ids() = runTest {
// Set up existing preferences with author ids // Set up existing preferences with author ids
val preMigrationUserPreferences = userPreferences { val preMigrationUserPreferences = userPreferences {
deprecatedFollowedAuthorIds.addAll(listOf("4", "5", "6")) deprecatedFollowedAuthorIds.addAll(listOf("4", "5", "6"))
@ -76,7 +76,7 @@ class ListToMapMigrationTest {
} }
@Test @Test
fun ListToMapMigration_should_migrate_bookmarks() = runTest { fun listToMapMigration_should_migrate_bookmarks() = runTest {
// Set up existing preferences with bookmarks // Set up existing preferences with bookmarks
val preMigrationUserPreferences = userPreferences { val preMigrationUserPreferences = userPreferences {
deprecatedBookmarkedNewsResourceIds.addAll(listOf("7", "8", "9")) deprecatedBookmarkedNewsResourceIds.addAll(listOf("7", "8", "9"))

@ -278,7 +278,7 @@ fun NiaButtonPreview() {
@ThemePreviews @ThemePreviews
@Composable @Composable
fun NiaOutlinedButtonPreview() { fun NiaOutlinedButtonPreview() {
NiaTheme() { NiaTheme {
NiaBackground(modifier = Modifier.size(150.dp, 50.dp)) { NiaBackground(modifier = Modifier.size(150.dp, 50.dp)) {
NiaOutlinedButton(onClick = {}, text = { Text("Test button") }) NiaOutlinedButton(onClick = {}, text = { Text("Test button") })
} }

@ -251,5 +251,7 @@ private fun scrollbarThumbColor(
} }
private enum class ThumbState { private enum class ThumbState {
Active, Inactive, Dormant Active,
Inactive,
Dormant,
} }

@ -66,7 +66,7 @@ class LoadingWheelScreenshotTests() {
fun loadingWheelAnimation() { fun loadingWheelAnimation() {
composeTestRule.mainClock.autoAdvance = false composeTestRule.mainClock.autoAdvance = false
composeTestRule.setContent { composeTestRule.setContent {
NiaTheme() { NiaTheme {
NiaLoadingWheel(contentDesc = "") NiaLoadingWheel(contentDesc = "")
} }
} }

@ -47,7 +47,7 @@ class TagScreenshotTests() {
val composeTestRule = createAndroidComposeRule<ComponentActivity>() val composeTestRule = createAndroidComposeRule<ComponentActivity>()
@Test @Test
fun Tag_multipleThemes() { fun tag_multipleThemes() {
composeTestRule.captureMultiTheme("Tag") { composeTestRule.captureMultiTheme("Tag") {
NiaTopicTag(followed = true, onClick = {}) { NiaTopicTag(followed = true, onClick = {}) {
Text("TOPIC") Text("TOPIC")

@ -17,5 +17,7 @@
package com.google.samples.apps.nowinandroid.core.model.data package com.google.samples.apps.nowinandroid.core.model.data
enum class DarkThemeConfig { enum class DarkThemeConfig {
FOLLOW_SYSTEM, LIGHT, DARK FOLLOW_SYSTEM,
LIGHT,
DARK,
} }

@ -17,5 +17,6 @@
package com.google.samples.apps.nowinandroid.core.model.data package com.google.samples.apps.nowinandroid.core.model.data
enum class ThemeBrand { enum class ThemeBrand {
DEFAULT, ANDROID DEFAULT,
ANDROID,
} }

@ -45,9 +45,10 @@ class FakeNiaNetworkDataSourceTest {
} }
@Test @Test
fun testDeserializationOfTopics() = runTest(testDispatcher) { fun testDeserializationOfTopics() =
@Suppress("ktlint:standard:max-line-length")
runTest(testDispatcher) {
assertEquals( assertEquals(
/* ktlint-disable max-line-length */
NetworkTopic( NetworkTopic(
id = "1", id = "1",
name = "Headlines", name = "Headlines",
@ -56,15 +57,15 @@ class FakeNiaNetworkDataSourceTest {
url = "", url = "",
imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Headlines.svg?alt=media&token=506faab0-617a-4668-9e63-4a2fb996603f", imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Headlines.svg?alt=media&token=506faab0-617a-4668-9e63-4a2fb996603f",
), ),
/* ktlint-enable max-line-length */
subject.getTopics().first(), subject.getTopics().first(),
) )
} }
@Test @Test
fun testDeserializationOfNewsResources() = runTest(testDispatcher) { fun testDeserializationOfNewsResources() =
@Suppress("ktlint:standard:max-line-length")
runTest(testDispatcher) {
assertEquals( assertEquals(
/* ktlint-disable max-line-length */
NetworkNewsResource( NetworkNewsResource(
id = "125", id = "125",
title = "Android Basics with Compose", title = "Android Basics with Compose",
@ -83,7 +84,6 @@ class FakeNiaNetworkDataSourceTest {
type = "Codelab", type = "Codelab",
topics = listOf("2", "3", "10"), topics = listOf("2", "3", "10"),
), ),
/* ktlint-enable max-line-length */
subject.getNewsResources().find { it.id == "125" }, subject.getNewsResources().find { it.id == "125" },
) )
} }

@ -14,12 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
@file:Suppress("ktlint:standard:max-line-length")
package com.google.samples.apps.nowinandroid.core.testing.data package com.google.samples.apps.nowinandroid.core.testing.data
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.Topic import com.google.samples.apps.nowinandroid.core.model.data.Topic
/* ktlint-disable max-line-length */
val followableTopicTestData: List<FollowableTopic> = listOf( val followableTopicTestData: List<FollowableTopic> = listOf(
FollowableTopic( FollowableTopic(
topic = Topic( topic = Topic(

@ -14,12 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
@file:Suppress("ktlint:standard:max-line-length")
package com.google.samples.apps.nowinandroid.core.testing.data package com.google.samples.apps.nowinandroid.core.testing.data
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import kotlinx.datetime.Instant import kotlinx.datetime.Instant
/* ktlint-disable max-line-length */
val newsResourcesTestData: List<NewsResource> = listOf( val newsResourcesTestData: List<NewsResource> = listOf(
NewsResource( NewsResource(
id = "1", id = "1",

@ -14,11 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
@file:Suppress("ktlint:standard:max-line-length")
package com.google.samples.apps.nowinandroid.core.testing.data package com.google.samples.apps.nowinandroid.core.testing.data
import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.model.data.Topic
/* ktlint-disable max-line-length */
val topicsTestData: List<Topic> = listOf( val topicsTestData: List<Topic> = listOf(
Topic( Topic(
id = "2", id = "2",

@ -14,6 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
@file:Suppress("ktlint:standard:max-line-length")
package com.google.samples.apps.nowinandroid.core.testing.data package com.google.samples.apps.nowinandroid.core.testing.data
import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig
@ -26,7 +28,6 @@ import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone import kotlinx.datetime.TimeZone
import kotlinx.datetime.toInstant import kotlinx.datetime.toInstant
/* ktlint-disable max-line-length */
val userNewsResourcesTestData: List<UserNewsResource> = UserData( val userNewsResourcesTestData: List<UserNewsResource> = UserData(
bookmarkedNewsResources = setOf("1", "4"), bookmarkedNewsResources = setOf("1", "4"),
viewedNewsResources = setOf("1", "2", "4"), viewedNewsResources = setOf("1", "2", "4"),

@ -14,13 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
@file:Suppress("ktlint:standard:max-line-length")
package com.google.samples.apps.nowinandroid.core.ui package com.google.samples.apps.nowinandroid.core.ui
import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.tooling.preview.PreviewParameterProvider
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.Topic import com.google.samples.apps.nowinandroid.core.model.data.Topic
/* ktlint-disable max-line-length */
/** /**
* This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider) * This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider)
* provides list of [FollowableTopic] for Composable previews. * provides list of [FollowableTopic] for Composable previews.

@ -14,6 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
@file:Suppress("ktlint:standard:max-line-length")
package com.google.samples.apps.nowinandroid.core.ui package com.google.samples.apps.nowinandroid.core.ui
import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.tooling.preview.PreviewParameterProvider
@ -29,7 +31,6 @@ import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone import kotlinx.datetime.TimeZone
import kotlinx.datetime.toInstant import kotlinx.datetime.toInstant
/* ktlint-disable max-line-length */
/** /**
* This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider) * This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider)
* provides list of [UserNewsResource] for Composable previews. * provides list of [UserNewsResource] for Composable previews.

@ -14,6 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
@file:Suppress("ktlint:standard:max-line-length")
package com.google.samples.apps.nowinandroid.feature.search package com.google.samples.apps.nowinandroid.feature.search
import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.tooling.preview.PreviewParameterProvider
@ -21,7 +23,6 @@ import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.newsResources import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.newsResources
import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.topics import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.topics
/* ktlint-disable max-line-length */
/** /**
* This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider) * This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider)
* provides list of [SearchResultUiState] for Composable previews. * provides list of [SearchResultUiState] for Composable previews.

@ -14,6 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
@file:Suppress("ktlint:standard:max-line-length")
package com.google.samples.apps.nowinandroid.feature.settings package com.google.samples.apps.nowinandroid.feature.settings
import android.content.Intent import android.content.Intent
@ -316,7 +318,6 @@ private fun PreviewSettingsDialogLoading() {
} }
} }
/* ktlint-disable max-line-length */
private const val PRIVACY_POLICY_URL = "https://policies.google.com/privacy" private const val PRIVACY_POLICY_URL = "https://policies.google.com/privacy"
private const val BRAND_GUIDELINES_URL = "https://developer.android.com/distribute/marketing-tools/brand-guidelines" private const val BRAND_GUIDELINES_URL = "https://developer.android.com/distribute/marketing-tools/brand-guidelines"
private const val FEEDBACK_URL = "https://goo.gle/nia-app-feedback" private const val FEEDBACK_URL = "https://goo.gle/nia-app-feedback"

Loading…
Cancel
Save