Add app/src/test/java/space/bloggin/mercies
This commit is contained in:
@@ -0,0 +1,66 @@
|
|||||||
|
package space.bloggin.mercies
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
||||||
|
import androidx.compose.ui.test.onRoot
|
||||||
|
import com.github.takahirom.roborazzi.captureRoboImage
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.robolectric.RobolectricTestRunner
|
||||||
|
import org.robolectric.annotation.Config
|
||||||
|
import org.robolectric.annotation.GraphicsMode
|
||||||
|
import java.io.File
|
||||||
|
import java.time.LocalDate
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner::class)
|
||||||
|
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||||
|
@Config(sdk = [34], qualifiers = "w411dp-h891dp-xxhdpi")
|
||||||
|
class ShotsTest {
|
||||||
|
@get:Rule val rule = createAndroidComposeRule<MainActivity>()
|
||||||
|
private val out = File("build/shots").apply { mkdirs() }
|
||||||
|
private fun shot(n: String) { rule.waitForIdle(); rule.mainClock.advanceTimeBy(1500); rule.waitForIdle(); rule.onRoot().captureRoboImage(File(out, "$n.png").path) }
|
||||||
|
private fun ui(b: AppState.() -> Unit) { rule.runOnUiThread { rule.activity.state.b() }; rule.waitForIdle() }
|
||||||
|
|
||||||
|
@Test fun all() {
|
||||||
|
shot("01_empty")
|
||||||
|
ui {
|
||||||
|
val today = LocalDate.now()
|
||||||
|
val samples = listOf("Coffee on the porch before anyone woke up.", "The grandkids called just to say hi.", "Riverbend's water main held through the freeze.",
|
||||||
|
"A stranger paid for my lunch.", "First snow, and the dog lost her mind with joy.", "She laughed at my dumb joke.", "Got the truck fixed for less than I feared.",
|
||||||
|
"Sunset over the cornfield on the drive home.", "Church potluck: three kinds of pie.", "Finished the Bible app. She loves it.")
|
||||||
|
for (i in 0 until 46) store.addNote(samples[i % samples.size], today.minusDays((46 - i).toLong() * 2))
|
||||||
|
store.addNote("She was hope-scrolling in the other room.")
|
||||||
|
store.savePrayer(null, "Mom", "Lord, give her strength for the surgery on Thursday, steady hands for the doctors, and peace for all of us waiting.")
|
||||||
|
store.savePrayer(null, "the Miller family", "Comfort them in their loss, and surround them with people who will carry meals and sit with them.")
|
||||||
|
store.savePrayer(null, "", "Help me to be patient at work this week, and kind when I don't feel like it.")
|
||||||
|
store.savePrayer(null, "Jake", "Safe travels on the drive back to base.")
|
||||||
|
store.setAnswered(store.prayers(false).first { it.forWho == "Jake" }.id, true, "Made it home safe Sunday night")
|
||||||
|
}
|
||||||
|
shot("02_jar")
|
||||||
|
rule.runOnUiThread { rule.activity.state.store.markKind(1) }
|
||||||
|
ui { tab = 1 }
|
||||||
|
shot("03_kindness")
|
||||||
|
ui { tab = 2 }
|
||||||
|
shot("04_prayers")
|
||||||
|
ui { open(Over.EditPrayer(null)) }
|
||||||
|
shot("05_new_prayer")
|
||||||
|
ui { back(); open(Over.ShareCard(Card("A prayer for Mom", store.prayers(false).first { it.forWho == "Mom" }.text, "Simple Mercies"), "")) }
|
||||||
|
shot("06_share")
|
||||||
|
ui { back(); tab = 0; browsing = true }
|
||||||
|
shot("07_browse")
|
||||||
|
ui { browsing = false; prefs.night = true }
|
||||||
|
shot("08_night")
|
||||||
|
ui { prefs.night = false; prefs.look = 1; open(Over.Settings) }
|
||||||
|
shot("09_settings")
|
||||||
|
ui { back(); prefs.look = 2; tab = 2 }
|
||||||
|
shot("10_sage_prayers")
|
||||||
|
ui { prefs.look = 0 }
|
||||||
|
|
||||||
|
val ctx = rule.activity
|
||||||
|
Shape.entries.forEachIndexed { i, s ->
|
||||||
|
val b = ShareKit.render(ctx, Card("A prayer for Mom", "Lord, give her strength for the surgery on Thursday, steady hands for the doctors, and peace for all of us waiting.", "Simple Mercies"), Looks.all[i], s)
|
||||||
|
File(out, "img_${s.name.lowercase()}.png").outputStream().use { b.compress(Bitmap.CompressFormat.PNG, 100, it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user