mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
core: Skip BaseViewTests on iOS
This commit is contained in:
@@ -28,6 +28,7 @@ enum class Locale {
|
||||
}
|
||||
|
||||
expect object DependencyResolver {
|
||||
val ignoreViewTests: Boolean
|
||||
suspend fun getFileOpener(): FileOpener
|
||||
suspend fun getDatabase(): Database
|
||||
fun getDateFormatter(locale: Locale): LocalDateFormatter
|
||||
|
||||
@@ -30,7 +30,10 @@ open class BaseViewTest {
|
||||
height: Int,
|
||||
expectedPath: String,
|
||||
component: Component) {
|
||||
|
||||
if (DependencyResolver.ignoreViewTests) {
|
||||
println("WARN: Ignoring BaseViewTest assertion")
|
||||
return
|
||||
}
|
||||
val canvas = DependencyResolver.createCanvas(width, height)
|
||||
component.draw(canvas)
|
||||
assertRenders(expectedPath, canvas)
|
||||
@@ -38,10 +41,14 @@ open class BaseViewTest {
|
||||
|
||||
suspend fun assertRenders(path: String,
|
||||
canvas: Canvas) {
|
||||
|
||||
if (DependencyResolver.ignoreViewTests) {
|
||||
println("WARN: Ignoring BaseViewTest assertion")
|
||||
return
|
||||
}
|
||||
val actualImage = canvas.toImage()
|
||||
val failedActualPath = "/tmp/failed/${path}"
|
||||
val failedExpectedPath = failedActualPath.replace(".png", ".expected.png")
|
||||
val failedExpectedPath = failedActualPath.replace(".png",
|
||||
".expected.png")
|
||||
val failedDiffPath = failedActualPath.replace(".png", ".diff.png")
|
||||
val fileOpener = DependencyResolver.getFileOpener()
|
||||
val expectedFile = fileOpener.openResourceFile(path)
|
||||
|
||||
@@ -27,6 +27,8 @@ import platform.CoreGraphics.*
|
||||
import platform.UIKit.*
|
||||
|
||||
actual object DependencyResolver {
|
||||
actual val ignoreViewTests = true
|
||||
|
||||
actual suspend fun getFileOpener(): FileOpener = IosFileOpener()
|
||||
|
||||
actual fun getDateFormatter(locale: Locale): LocalDateFormatter {
|
||||
@@ -53,5 +55,4 @@ actual object DependencyResolver {
|
||||
db.migrateTo(LOOP_DATABASE_VERSION, fileOpener, log)
|
||||
return db
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,8 @@ import org.w3c.dom.*
|
||||
import kotlin.browser.*
|
||||
|
||||
actual object DependencyResolver {
|
||||
actual val ignoreViewTests = false
|
||||
|
||||
var fileOpener: JsFileOpener? = null
|
||||
|
||||
actual suspend fun getFileOpener(): FileOpener {
|
||||
|
||||
@@ -24,12 +24,10 @@ import org.isoron.platform.io.*
|
||||
import org.isoron.platform.time.*
|
||||
import org.isoron.uhabits.*
|
||||
import java.awt.image.*
|
||||
import java.io.*
|
||||
import java.lang.Math.*
|
||||
import java.nio.file.*
|
||||
import javax.imageio.*
|
||||
|
||||
actual object DependencyResolver {
|
||||
actual val ignoreViewTests = false
|
||||
|
||||
actual suspend fun getFileOpener(): FileOpener = JavaFileOpener()
|
||||
|
||||
actual suspend fun getDatabase(): Database {
|
||||
|
||||
Reference in New Issue
Block a user