fix spotless errors with line length

pull/402/head
JanFidor 3 years ago
parent 749feb714e
commit 3264bb50fc

@ -1,17 +1,17 @@
/* /*
* Copyright 2022 The Android Open Source Project * Copyright 2022 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.samples.apps.nowinandroid.feature.author package com.google.samples.apps.nowinandroid.feature.author
@ -25,7 +25,8 @@ import com.google.samples.apps.nowinandroid.core.domain.model.FollowableAuthor
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
internal class AuthorRobot( internal class AuthorRobot(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity> private val composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>
) { ) {
fun setContent(authorUiState: AuthorUiState, newsUiState: NewsUiState) { fun setContent(authorUiState: AuthorUiState, newsUiState: NewsUiState) {
composeTestRule.setContent { composeTestRule.setContent {
@ -62,4 +63,4 @@ internal class AuthorRobot(
.onNodeWithText(newsResource.title) .onNodeWithText(newsResource.title)
.assertExists() .assertExists()
} }
} }

@ -101,7 +101,8 @@ class AuthorScreenTest {
} }
private fun launchAuthorRobot( private fun launchAuthorRobot(
composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity>, composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>,
authorUiState: AuthorUiState, authorUiState: AuthorUiState,
newsUiState: NewsUiState, newsUiState: NewsUiState,
func: AuthorRobot.() -> Unit func: AuthorRobot.() -> Unit

@ -1,17 +1,17 @@
/* /*
* Copyright 2022 The Android Open Source Project * Copyright 2022 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.samples.apps.nowinandroid.feature.bookmarks package com.google.samples.apps.nowinandroid.feature.bookmarks
@ -35,68 +35,53 @@ import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
internal class BookmarksRobot( internal class BookmarksRobot(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity> private val composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>
) { ) {
private val removedBookmarks = mutableSetOf<String>() private val removedBookmarks = mutableSetOf<String>()
fun setContent(newsFeedUiState: NewsFeedUiState) { fun setContent(newsFeedUiState: NewsFeedUiState) {
composeTestRule.setContent { composeTestRule.setContent {
BookmarksScreen( BookmarksScreen(feedState = newsFeedUiState, removeFromBookmarks = {
feedState = newsFeedUiState, removedBookmarks.add(it)
removeFromBookmarks = { })
removedBookmarks.add(it)
}
)
} }
} }
fun loadingIndicatorShown() { fun loadingIndicatorShown() {
composeTestRule composeTestRule.onNodeWithContentDescription(
.onNodeWithContentDescription( composeTestRule.activity.resources.getString(R.string.saved_loading)
composeTestRule.activity.resources.getString(R.string.saved_loading) ).assertExists()
)
.assertExists()
} }
fun clickableNewsResourceExists(newsResource: NewsResource) { fun clickableNewsResourceExists(newsResource: NewsResource) {
composeTestRule composeTestRule.onNodeWithText(
.onNodeWithText( newsResource.title, substring = true
newsResource.title, ).assertExists().assertHasClickAction()
substring = true
)
.assertExists()
.assertHasClickAction()
} }
fun scrollToNewsResource(newsResource: NewsResource) { fun scrollToNewsResource(newsResource: NewsResource) {
composeTestRule.onNode(hasScrollToNodeAction()) composeTestRule.onNode(hasScrollToNodeAction()).performScrollToNode(
.performScrollToNode( hasText(
hasText( newsResource.title, substring = true
newsResource.title,
substring = true
)
) )
)
} }
fun clickNewsResourceBookmark(newsResource: NewsResource) { fun clickNewsResourceBookmark(newsResource: NewsResource) {
composeTestRule composeTestRule.onAllNodesWithContentDescription(
.onAllNodesWithContentDescription( composeTestRule.activity.getString(
composeTestRule.activity.getString( com.google.samples.apps.nowinandroid.core.ui.R.string.unbookmark
com.google.samples.apps.nowinandroid.core.ui.R.string.unbookmark )
) ).filter(
).filter( hasAnyAncestor(
hasAnyAncestor( hasText(
hasText( newsResource.title, substring = true
newsResource.title,
substring = true
)
) )
) )
.assertCountEquals(1) ).assertCountEquals(1).onFirst().performClick()
.onFirst()
.performClick()
} }
fun removedNewsResourceBookmark(newsResource: NewsResource) = fun removedNewsResourceBookmark(newsResource: NewsResource) =
removedBookmarks.contains(newsResource.id) removedBookmarks.contains(newsResource.id)
} }

@ -75,7 +75,8 @@ class BookmarksScreenTest {
} }
private fun launchBookmarksRobot( private fun launchBookmarksRobot(
composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity>, composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>,
newsFeedUiState: NewsFeedUiState, newsFeedUiState: NewsFeedUiState,
func: BookmarksRobot.() -> Unit func: BookmarksRobot.() -> Unit
) = BookmarksRobot(composeTestRule).apply { ) = BookmarksRobot(composeTestRule).apply {

@ -1,17 +1,17 @@
/* /*
* Copyright 2022 The Android Open Source Project * Copyright 2022 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.samples.apps.nowinandroid.feature.foryou package com.google.samples.apps.nowinandroid.feature.foryou
@ -36,7 +36,8 @@ import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
import com.google.samples.apps.nowinandroid.feature.foryou.R.string import com.google.samples.apps.nowinandroid.feature.foryou.R.string
internal class ForYouRobot( internal class ForYouRobot(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity> private val composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>
) { ) {
private val doneButtonMatcher by lazy { private val doneButtonMatcher by lazy {
hasText(composeTestRule.activity.resources.getString(string.done)) hasText(composeTestRule.activity.resources.getString(string.done))
@ -120,4 +121,4 @@ internal class ForYouRobot(
) )
) )
} }
} }

@ -185,7 +185,8 @@ class ForYouScreenTest {
} }
private fun launchForYouRobot( private fun launchForYouRobot(
composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity>, composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>,
isSyncing: Boolean, isSyncing: Boolean,
onboardingState: OnboardingUiState, onboardingState: OnboardingUiState,
feedState: NewsFeedUiState, feedState: NewsFeedUiState,

@ -1,17 +1,17 @@
/* /*
* Copyright 2022 The Android Open Source Project * Copyright 2022 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.samples.apps.nowinandroid.interests package com.google.samples.apps.nowinandroid.interests
@ -32,7 +32,8 @@ import com.google.samples.apps.nowinandroid.feature.interests.InterestsUiState
import com.google.samples.apps.nowinandroid.feature.interests.R.string import com.google.samples.apps.nowinandroid.feature.interests.R.string
internal class InterestsRobot( internal class InterestsRobot(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity> private val composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>
) { ) {
private val interestsLoading = getString(string.interests_loading) private val interestsLoading = getString(string.interests_loading)
private val interestsEmptyHeader = getString(string.interests_empty_header) private val interestsEmptyHeader = getString(string.interests_empty_header)
@ -98,4 +99,4 @@ internal class InterestsRobot(
private fun getString(@StringRes stringId: Int) = private fun getString(@StringRes stringId: Int) =
composeTestRule.activity.resources.getString(stringId) composeTestRule.activity.resources.getString(stringId)
} }

@ -75,7 +75,6 @@ class InterestsScreenTest {
interestsTopicCardFollowButtonCountEquals(numberOfUnfollowedTopics) interestsTopicCardFollowButtonCountEquals(numberOfUnfollowedTopics)
interestsTopicCardUnfollowButtonCountEquals(numberOfFollowedTopics) interestsTopicCardUnfollowButtonCountEquals(numberOfFollowedTopics)
} }
} }
@ -119,7 +118,8 @@ class InterestsScreenTest {
} }
private fun launchBookmarksRobot( private fun launchBookmarksRobot(
composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity>, composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>,
uiState: InterestsUiState, uiState: InterestsUiState,
tabIndex: Int, tabIndex: Int,
func: InterestsRobot.() -> Unit func: InterestsRobot.() -> Unit

@ -1,17 +1,17 @@
/* /*
* Copyright 2022 The Android Open Source Project * Copyright 2022 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.samples.apps.nowinandroid.feature.settings package com.google.samples.apps.nowinandroid.feature.settings
@ -24,7 +24,8 @@ import androidx.compose.ui.test.onNodeWithText
import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.rules.ActivityScenarioRule
internal class SettingsDialogRobot( internal class SettingsDialogRobot(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity> private val composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>
) { ) {
fun setContent(settingsUiState: SettingsUiState) { fun setContent(settingsUiState: SettingsUiState) {
composeTestRule.setContent { composeTestRule.setContent {
@ -57,4 +58,4 @@ internal class SettingsDialogRobot(
fun getString(@StringRes stringId: Int) = fun getString(@StringRes stringId: Int) =
composeTestRule.activity.resources.getString(stringId) composeTestRule.activity.resources.getString(stringId)
} }

@ -82,7 +82,8 @@ class SettingsDialogTest {
} }
private fun launchSettingsDialogRobot( private fun launchSettingsDialogRobot(
composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity>, composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>,
settingsUiState: SettingsUiState, settingsUiState: SettingsUiState,
func: SettingsDialogRobot.() -> Unit func: SettingsDialogRobot.() -> Unit
) = SettingsDialogRobot(composeTestRule).apply { ) = SettingsDialogRobot(composeTestRule).apply {

@ -1,17 +1,17 @@
/* /*
* Copyright 2022 The Android Open Source Project * Copyright 2022 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.samples.apps.nowinandroid.feature.topic package com.google.samples.apps.nowinandroid.feature.topic
@ -29,7 +29,8 @@ import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
internal class TopicRobot( internal class TopicRobot(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity> private val composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>
) { ) {
private val topicLoading = composeTestRule.activity.resources.getString(R.string.topic_loading) private val topicLoading = composeTestRule.activity.resources.getString(R.string.topic_loading)
@ -67,4 +68,4 @@ internal class TopicRobot(
.onFirst() .onFirst()
.performScrollToNode(hasText(newsResource.title)) .performScrollToNode(hasText(newsResource.title))
} }
} }

@ -103,7 +103,8 @@ class TopicScreenTest {
} }
private fun launchTopicRobot( private fun launchTopicRobot(
composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<ComponentActivity>, ComponentActivity>, composeTestRule: AndroidComposeTestRule<
ActivityScenarioRule<ComponentActivity>, ComponentActivity>,
topicUiState: TopicUiState, topicUiState: TopicUiState,
newsUiState: NewsUiState, newsUiState: NewsUiState,
func: TopicRobot.() -> Unit func: TopicRobot.() -> Unit

Loading…
Cancel
Save