Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / office / src / test / java / com / vayunmathur / office / Slice4Pass2MainActivityTest.kt
Slice4Pass2MainActivityTest.kt25 lines · 1.0 KiBRaw
| 1 | package com.vayunmathur.office |
| 2 | |
| 3 | import android.content.Context |
| 4 | import androidx.compose.ui.test.junit4.createAndroidComposeRule |
| 5 | import androidx.compose.ui.test.onNodeWithText |
| 6 | import androidx.test.core.app.ApplicationProvider |
| 7 | import androidx.test.ext.junit.runners.AndroidJUnit4 |
| 8 | import org.junit.Rule |
| 9 | import org.junit.Test |
| 10 | import org.junit.runner.RunWith |
| 11 | import kotlin.test.assertTrue |
| 12 | |
| 13 | /** Slice 4 pass 2: MainActivity launches into the office home (nav graph + theme). */ |
| 14 | @RunWith(AndroidJUnit4::class) |
| 15 | class Slice4Pass2MainActivityTest { |
| 16 | |
| 17 | @get:Rule val rule = createAndroidComposeRule<MainActivity>() |
| 18 | private val ctx: Context get() = ApplicationProvider.getApplicationContext() |
| 19 | |
| 20 | @Test fun mainActivityLaunchesToHome() { |
| 21 | rule.onNodeWithText(ctx.getString(R.string.open_document)).assertExists() |
| 22 | rule.onNodeWithText(ctx.getString(R.string.app_name), substring = true).assertExists() |
| 23 | assertTrue(rule.activity.intent?.action == "android.intent.action.MAIN" || rule.activity.intent != null) |
| 24 | } |
| 25 | } |