package com.cottondb.data import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test import java.io.File /** ANDROID READY 1: what Data's walk on emulator-5604 found in the shell. */ class DataReadyTest { private val repo = generateSequence(File("").absoluteFile) { it.parentFile }.first { File(it, "apps/registry.json").isFile } private fun src(name: String) = File(repo, "apps/android/app/src/data/kotlin/com/cottondb/data/$name").readText() /** Stopped to leave room at 20%: the core's state_line says why, beside the percent; only filling leaves it out. */ @Test fun keep_says_why_it_stopped() { val you = src("You.kt") assertTrue(you.contains("if (progress == null || a.str(\"state\") != \"filling\") a.str(\"state_line\")")) assertFalse(you.contains("if (progress == null || a.str(\"state\") == \"paused\")")) } /** At the largest text a long cost value took the whole row and left its name one letter wide. */ @Test fun a_cost_value_takes_at_most_half_the_row() { val you = src("You.kt") assertTrue(you.contains("T(row.str(\"value_line\").orEmpty(), 16.sp, weight = FontWeight.Bold, modifier = Modifier.weight(1f, fill = false))")) } /** TalkBack said "Invented Stuck B, , yesterday": a row's blank second line is left out of its name. */ @Test fun a_rows_spoken_name_skips_blank_parts() { val bits = src("Bits.kt") assertTrue(bits.contains("listOf(title, line, end).filterNot { it.isNullOrBlank() }.joinToString(\", \")")) assertFalse(bits.contains("listOfNotNull(title, line, end).joinToString(\", \")")) } }