Cotton code
52 lines · 2.3 KB · KotlinRaw
package com.cottondb.notesimport androidx.activity.ComponentActivityimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.test.junit4.createAndroidComposeRuleimport androidx.core.view.WindowCompatimport com.cottondb.shell.FaceBarsimport org.junit.Assert.assertEqualsimport 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/** * Words at night (the launch walk, 22 Nov 2026, emulator-5554, night mode): the list, a note and the side page stood * on the dark theme's ground with the status bar's clock, signal and battery drawn dark on it, unreadable. Words' surface * now sets the bars by its theme's ground: light icons on a dark ground, dark on Linen. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], application = android.app.Application::class)class NotesBarsTest {    @get:Rule val compose = createAndroidComposeRule<ComponentActivity>()    private fun bars() = compose.activity.window.let { WindowCompat.getInsetsController(it, it.decorView) }    /** RULE: a dark theme's ground takes light icons; Linen's warm off-white takes dark ones. */    @Test fun the_theme_ground_decides_the_icons() {        assertTrue(barsDark(Color(0xFF1F2125)))        assertTrue(barsDark(Color(0xFF000000)))        assertFalse(barsDark(Color(0xFFF7F5F0)))    }    @Test fun a_dark_ground_draws_light_icons() {        compose.setContent {            androidx.compose.runtime.CompositionLocalProvider(com.cottondb.shell.LocalGround provides com.cottondb.shell.Ground.terrazzo) {                FaceBars(dark = barsDark(Color(0xFF1F2125)))            }        }        compose.waitForIdle()        assertFalse("the clock stayed dark on the dark ground", bars().isAppearanceLightStatusBars)    }    /** RULE: Words' surface sets the bars from its theme's ground. */    @Test fun the_surface_sets_the_bars_by_its_theme() {        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/notes/kotlin/com/cottondb/notes/NotesSurface.kt").readText()        assertEquals(true, surface.contains("FaceBars(dark = barsDark(theme.ground))"))    }}