package com.cottondb.days import android.app.Application import androidx.compose.foundation.layout.Column import androidx.compose.ui.test.getBoundsInRoot import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.platform.LocalContext import com.cottondb.days.pen.DaysCardLook import com.cottondb.days.pen.penFonts import com.cottondb.shell.AboutPart import com.cottondb.shell.LocalCardLook import com.cottondb.shell.core.CottonCore import kotlinx.serialization.json.jsonObject import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config /** * About's rows in Days' pen: a long said (Database, the database's first eight and the server's host) wraps in its share of the row * and the label stays whole. On the emulator (Days, 21 Nov 2026) "Database" stood as "Da / ta / ba / se", the said * taking the whole row. The database and host here are invented. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w400dp-h800dp-mdpi", application = Application::class) class DaysAboutRowTest { @get:Rule val compose = createComposeRule() @Test fun a_long_said_never_squeezes_its_label() { val settings = CottonCore.json.parseToJsonElement( """{"about":{"title":"About","version":{"label":"Version","said":"1.0.0 (10468)"}, "facts":[{"id":"database","label":"Database","said":"f00dbabe ยท cotton-made-up-server-for-a-walk.invented-host-somewhere-far.example.workers.dev"}]}}""", ).jsonObject compose.setContent { CompositionLocalProvider(LocalCardLook provides DaysCardLook(penFonts(LocalContext.current))) { Column { AboutPart(settings) } } } val version = compose.onNodeWithTag("settings-about-version-label").getBoundsInRoot() val database = compose.onNodeWithTag("settings-about-database-label").getBoundsInRoot() // Whole: one line as tall as Version's, and at least as wide (eight letters to its seven). assertTrue("Database stands on one line: $database against $version", database.bottom - database.top == version.bottom - version.top) assertTrue("Database is whole: $database against $version", database.right - database.left >= version.right - version.left) // And what a row says stands at its right edge, a short one too. val row = compose.onNodeWithTag("settings-about-version").getBoundsInRoot() val said = compose.onNodeWithTag("settings-about-version-said").getBoundsInRoot() assertTrue("Version's said ($said) stands at the row's right ($row)", (row.right - said.right).value <= 1f) } }