Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / launcher / src / test / java / com / vayunmathur / launcher / ui / LauncherTvPageTest.kt
LauncherTvPageTest.kt34 lines · 1.2 KiBRaw
| 1 | package com.vayunmathur.launcher.ui |
| 2 | |
| 3 | import androidx.compose.ui.test.junit4.createComposeRule |
| 4 | import androidx.compose.ui.test.onAllNodesWithText |
| 5 | import androidx.test.ext.junit.runners.AndroidJUnit4 |
| 6 | import androidx.test.core.app.ApplicationProvider |
| 7 | import com.vayunmathur.launcher.platform.TvHomeViewModel |
| 8 | import org.junit.Rule |
| 9 | import org.junit.Test |
| 10 | import org.junit.runner.RunWith |
| 11 | import kotlin.test.assertEquals |
| 12 | |
| 13 | /** |
| 14 | * Compose tests (Robolectric + createComposeRule): [TvHomePage] wires a |
| 15 | * real [TvHomeViewModel] to [TvHomeScreen] without crashing, and |
| 16 | * [TvClockHeader] renders. |
| 17 | */ |
| 18 | @RunWith(AndroidJUnit4::class) |
| 19 | class LauncherTvPageTest { |
| 20 | |
| 21 | @get:Rule val rule = createComposeRule() |
| 22 | |
| 23 | @Test fun tvHomePageComposes() { |
| 24 | val app = ApplicationProvider.getApplicationContext<android.app.Application>() |
| 25 | val vm = TvHomeViewModel(app) |
| 26 | rule.setContent { TvHomePage(viewModel = vm) } |
| 27 | // Empty grid under Robolectric: no tiles, but the clock header is there. |
| 28 | assertEquals(0, rule.onAllNodesWithText("Alpha").fetchSemanticsNodes().size) |
| 29 | } |
| 30 | |
| 31 | @Test fun clockHeaderRenders() { |
| 32 | rule.setContent { TvClockHeader(onOpenNetworkSettings = {}) } |
| 33 | } |
| 34 | } |