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

@ -179,7 +179,7 @@ class MainActivity : ComponentActivity() {
To see quick turnaround of the ProfileVerifier, we recommend using `speed-profile`. To see quick turnaround of the ProfileVerifier, we recommend using `speed-profile`.
If you don't do either of these steps, you might only see the profile status reported as If you don't do either of these steps, you might only see the profile status reported as
"enqueued for compilation" when running the sample locally. "enqueued for compilation" when running the sample locally.
*/ */
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
val status = ProfileVerifier.getCompilationStatusAsync().await() val status = ProfileVerifier.getCompilationStatusAsync().await()
Log.d(TAG, "ProfileInstaller status code: ${status.profileInstallResultCode}") Log.d(TAG, "ProfileInstaller status code: ${status.profileInstallResultCode}")

@ -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,46 +45,46 @@ class FakeNiaNetworkDataSourceTest {
} }
@Test @Test
fun testDeserializationOfTopics() = runTest(testDispatcher) { fun testDeserializationOfTopics() =
assertEquals( @Suppress("ktlint:standard:max-line-length")
/* ktlint-disable max-line-length */ runTest(testDispatcher) {
NetworkTopic( assertEquals(
id = "1", NetworkTopic(
name = "Headlines", id = "1",
shortDescription = "News you'll definitely be interested in", name = "Headlines",
longDescription = "The latest events and announcements from the world of Android development.", shortDescription = "News you'll definitely be interested in",
url = "", longDescription = "The latest events and announcements from the world of Android development.",
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", 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",
/* ktlint-enable max-line-length */ ),
subject.getTopics().first(), subject.getTopics().first(),
) )
} }
@Test @Test
fun testDeserializationOfNewsResources() = runTest(testDispatcher) { fun testDeserializationOfNewsResources() =
assertEquals( @Suppress("ktlint:standard:max-line-length")
/* ktlint-disable max-line-length */ runTest(testDispatcher) {
NetworkNewsResource( assertEquals(
id = "125", NetworkNewsResource(
title = "Android Basics with Compose", id = "125",
content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. ", title = "Android Basics with Compose",
url = "https://android-developers.googleblog.com/2022/05/new-android-basics-with-compose-course.html", content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. ",
headerImageUrl = "https://developer.android.com/images/hero-assets/android-basics-compose.svg", url = "https://android-developers.googleblog.com/2022/05/new-android-basics-with-compose-course.html",
publishDate = LocalDateTime( headerImageUrl = "https://developer.android.com/images/hero-assets/android-basics-compose.svg",
year = 2022, publishDate = LocalDateTime(
monthNumber = 5, year = 2022,
dayOfMonth = 4, monthNumber = 5,
hour = 23, dayOfMonth = 4,
minute = 0, hour = 23,
second = 0, minute = 0,
nanosecond = 0, second = 0,
).toInstant(TimeZone.UTC), nanosecond = 0,
type = "Codelab", ).toInstant(TimeZone.UTC),
topics = listOf("2", "3", "10"), type = "Codelab",
), 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