package com.cottondb.notesimport android.app.Applicationimport androidx.test.core.app.ApplicationProviderimport com.cottondb.shell.look.LookFacesimport kotlinx.serialization.json.Jsonimport kotlinx.serialization.json.JsonArrayimport kotlinx.serialization.json.JsonObjectimport kotlinx.serialization.json.jsonArrayimport kotlinx.serialization.json.jsonObjectimport kotlinx.serialization.json.jsonPrimitiveimport org.junit.Assert.assertEqualsimport org.junit.Assert.assertNotEqualsimport org.junit.Assert.assertNotNullimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * A face chosen in Look reaches the note's words in Words (owner, 23 Nov 2026: on his iPhone a font changed nothing * while size, papers and inks did). Each of Look's faces, as the kit names them, stands in `notes.settings`' answer in * turn (`face`, and the `font` builds before Look read); the writing type every note is drawn in then carries that * face's family, built from the files this build carries, and never Figtree. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], application = Application::class)classNotesLookFaceTest {privateval kit: JsonObjectby lazy {var dir = java.io.File("").absoluteFilewhile (!java.io.File(dir, "crates/cotton-core/kits/look/look.json").isFile) dir = dir.parentFileJson.parseToJsonElement(java.io.File(dir, "crates/cotton-core/kits/look/look.json").readText()).jsonObject }privatefun look(face: String): JsonObject {val faces = kit["faces"]!!.jsonArray.filter { it.jsonObject["id"]!!.jsonPrimitive.content in LOOK_FACES }returnJson.parseToJsonElement("""{"app":"notes","face":"$face"}""").jsonObject.let { JsonObject(it + ("faces" to JsonArray(faces))) } }privatefun settings(face: String) = Json.parseToJsonElement("""{"face":"$face","font":"$face","font_size":17,"line_height":1.5,"line_width":0}""").jsonObject @Test fun every_chosen_face_reaches_the_writing_type() {val assets = ApplicationProvider.getApplicationContext<Application>().assetsval model = NotesModel()val figtree = NotesLook.faces(assets).first model.settings = settings("own"); model.look = look("own") assertEquals("Words' own face is Figtree", figtree, model.type(assets)!!.face) LOOK_FACES.forEach { face -> model.look = look(face); model.settings = settings(face)val family = LookFaces.chosen(assets, model.look) assertNotNull("this build carries no file of $face", family) assertEquals("a note's words in $face", family, model.type(assets)!!.face) assertNotEquals("$face is drawn as Figtree", figtree, model.type(assets)!!.face) } }privatecompanionobject { val LOOK_FACES = listOf("serif", "typewriter", "hyperlegible", "dyslexic") }}