|
|
|
|
@ -34,6 +34,7 @@ import androidx.compose.ui.test.performScrollToNode
|
|
|
|
|
import androidx.test.espresso.Espresso
|
|
|
|
|
import androidx.test.espresso.NoActivityResumedException
|
|
|
|
|
import com.google.samples.apps.nowinandroid.MainActivity
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.data.repository.NewsRepository
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.model.data.Topic
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.rules.GrantPostNotificationsPermissionRule
|
|
|
|
|
@ -50,7 +51,8 @@ import nowinandroid.shared.generated.resources.Res
|
|
|
|
|
import nowinandroid.shared.generated.resources.app_name
|
|
|
|
|
import org.junit.Rule
|
|
|
|
|
import org.junit.Test
|
|
|
|
|
import javax.inject.Inject
|
|
|
|
|
import org.koin.test.KoinTest
|
|
|
|
|
import org.koin.test.inject
|
|
|
|
|
import nowinandroid.feature.bookmarks.generated.resources.Res as BookmarksR
|
|
|
|
|
import nowinandroid.feature.foryou.generated.resources.Res as FeatureForyouR
|
|
|
|
|
import nowinandroid.feature.search.generated.resources.Res as FeatureSearchR
|
|
|
|
|
@ -58,13 +60,7 @@ import nowinandroid.feature.settings.generated.resources.Res as SettingsR
|
|
|
|
|
/**
|
|
|
|
|
* Tests all the navigation flows that are handled by the navigation library.
|
|
|
|
|
*/
|
|
|
|
|
class NavigationTest {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Manages the components' state and is used to perform injection on your test
|
|
|
|
|
*/
|
|
|
|
|
// @get:Rule(order = 0)
|
|
|
|
|
// val hiltRule = HiltAndroidRule(this)
|
|
|
|
|
class NavigationTest : KoinTest {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Grant [android.Manifest.permission.POST_NOTIFICATIONS] permission.
|
|
|
|
|
@ -78,11 +74,8 @@ class NavigationTest {
|
|
|
|
|
@get:Rule(order = 2)
|
|
|
|
|
val composeTestRule = createAndroidComposeRule<MainActivity>()
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
|
lateinit var topicsRepository: TopicsRepository
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
|
lateinit var newsRepository: NewsRepository
|
|
|
|
|
private val topicsRepository: TopicsRepository by inject()
|
|
|
|
|
private val newsRepository: NewsRepository by inject()
|
|
|
|
|
|
|
|
|
|
// The strings used for matching in these tests
|
|
|
|
|
private val navigateUp by composeTestRule.stringResource(FeatureForyouR.string.feature_foryou_navigate_up)
|
|
|
|
|
@ -95,9 +88,6 @@ class NavigationTest {
|
|
|
|
|
private val brand by composeTestRule.stringResource(SettingsR.string.feature_settings_brand_android)
|
|
|
|
|
private val ok by composeTestRule.stringResource(SettingsR.string.feature_settings_dismiss_dialog_button_text)
|
|
|
|
|
|
|
|
|
|
// @Before
|
|
|
|
|
// fun setup() = hiltRule.inject()
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun firstScreen_isForYou() {
|
|
|
|
|
composeTestRule.apply {
|
|
|
|
|
|