Cotton code
47 lines · 2.1 KB · KotlinRaw
package com.cottondb.storyimport androidx.activity.ComponentActivityimport androidx.compose.ui.test.junit4.createAndroidComposeRuleimport androidx.core.view.WindowCompatimport com.cottondb.shell.FaceBarsimport org.junit.Assert.assertFalseimport org.junit.Assert.assertTrueimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * Story's status bar (the old-look pass, 22 Nov 2026, emulator-5554, by day and at night): Story keeps its one light * Ink look, but the clock, signal and battery were drawn white on its pale sheet, hardly readable (the app stands on the * shell's blank ground, which set light icons). Story's surface now sets the bars by its own sheet: dark icons, day or * night, as Days' does (DaysBarsTest). */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], application = android.app.Application::class, qualifiers = "night")class StoryBarsTest {    @get:Rule val compose = createAndroidComposeRule<ComponentActivity>()    private fun bars() = compose.activity.window.let { WindowCompat.getInsetsController(it, it.decorView) }    /** RULE: Story's pale sheet takes dark icons. */    @Test fun the_sheet_takes_dark_icons() = assertFalse(barsDark())    @Test fun at_night_the_bars_stay_dark_on_the_sheet() {        compose.setContent {            androidx.compose.runtime.CompositionLocalProvider(com.cottondb.shell.LocalGround provides com.cottondb.shell.Ground.terrazzo) {                FaceBars(dark = barsDark())            }        }        compose.waitForIdle()        assertTrue("the clock went white on Story's pale sheet at night", bars().isAppearanceLightStatusBars)    }    /** RULE: Story's surface sets the bars from its sheet. */    @Test fun the_surface_sets_the_bars() {        val repo = generateSequence(java.io.File("").absoluteFile) { it.parentFile }.first { java.io.File(it, "apps/registry.json").isFile }        val surface = java.io.File(repo, "apps/android/app/src/story/kotlin/com/cottondb/story/StorySurface.kt").readText()        assertTrue(surface.contains("FaceBars(dark = barsDark())"))    }}