package com.cottondb.days import android.app.Application import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.test.getBoundsInRoot import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import com.cottondb.days.pen.DaysCardLook import com.cottondb.days.pen.penFonts import com.cottondb.shell.LocalCardLook import com.cottondb.shell.ReportSheet 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 /** * Share a report's preview in Days' pen: the report is read in Days' small words. On the emulator (21 Nov 2026) it was * drawn in the look's Code style, a code's 34 sp figures, four words a line, the report a long scroll of a few words. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w411dp-h914dp-xhdpi", application = Application::class) class DaysReportPreviewTest { @get:Rule val compose = createComposeRule() @Test fun the_report_reads_in_days_small_words() { val share = CottonCore.json.parseToJsonElement( """{"preview_title":"This is the whole report","preview_share":"Share","preview_close":"Close"}""", ).jsonObject // Eight short invented lines, none wrapping at Days' small words. val text = (1..8).joinToString("\n") { "Line $it: 0 MB" } compose.setContent { CompositionLocalProvider(LocalCardLook provides DaysCardLook(penFonts(LocalContext.current))) { ReportSheet(share, text, onClose = {}, onShare = {}) } } val words = compose.onNodeWithTag("settings-report-text").getBoundsInRoot() assertTrue("eight lines stand ${words.bottom - words.top} tall", (words.bottom - words.top).value <= 8 * 24f) } }