package com.cottondb.sitesimport kotlinx.serialization.json.Jsonimport kotlinx.serialization.json.jsonObjectimport org.junit.Assert.assertFalseimport org.junit.Assert.assertTrueimport org.junit.Testimport java.io.File/** sites-design 51b0c496ce (CONTRACT "The list"): no screen lock, Arrange's moves, Fill a login, an old web view. */classSitesNoLockTest {privateval repo = generateSequence(File("").absoluteFile) { it.parentFile }.first { File(it, "apps/registry.json").isFile }privatefun src(name: String) = File(repo, "apps/android/app/src/sites/kotlin/com/cottondb/sites/$name").readText()privateval words by lazy { Json.parseToJsonElement(File(repo, "crates/cotton-core/kits/shell/lines/sites.json").readText()).jsonObject } @Testfun the_words_are_the_cores() { listOf("hidden" to "no_lock", "hidden" to "set_lock", "arrange" to "up", "arrange" to "down", "failed" to "old_title","failed" to "old_line", "failed" to "old_update", "login" to "other").forEach { (set, key) -> assertTrue("$set.$key", words[set]!!.jsonObject.containsKey(key)) } }/** A phone with no screen lock says so: sites.home gets no_lock, the list shows why and how to set one, no Hide. */ @Testfun a_phone_with_no_lock_shows_hidden_sites_and_says_why() {val state = src("SitesState.kt") assertTrue(state.contains("isDeviceSecure")) assertTrue(state.contains("if (noLock) put(\"no_lock\", true)"))val list = src("ListScreen.kt") assertTrue(list.contains("hidden.str(\"no_lock\")") && list.contains("hidden.str(\"set_lock\")")) assertTrue(list.contains("if (noLock == null) HideButton(")) }/** Arrange's TalkBack moves, the Fill line's key mark, and the old web view in the core's words. */ @Testfun arrange_fill_and_the_old_web_view_say_the_cores_words() {val edit = src("Edit.kt") assertTrue(edit.contains("state.w(\"arrange.up\"") && edit.contains("state.w(\"arrange.down\"")) assertFalse(edit.contains("table.move_up")) assertTrue(src("Fill.kt").contains("control(state.w(\"login.other\"))"))val state = src("SitesState.kt") assertFalse(state.contains("web view without profiles\"); return@go")) assertTrue(state.split("sheet = Sheet.OldWebView").size == 3)val sheets = src("Sheets.kt") assertTrue(sheets.contains("failed.old_title") && sheets.contains("failed.old_update") && sheets.contains("com.google.android.webview")) }}