Skip to content

Commit f1610e6

Browse files
committed
core: Skip BaseViewTests on iOS
1 parent a7a1766 commit f1610e6

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

core/src/test/common/org/isoron/DependencyResolver.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enum class Locale {
2828
}
2929

3030
expect object DependencyResolver {
31+
val ignoreViewTests: Boolean
3132
suspend fun getFileOpener(): FileOpener
3233
suspend fun getDatabase(): Database
3334
fun getDateFormatter(locale: Locale): LocalDateFormatter

core/src/test/common/org/isoron/uhabits/BaseViewTest.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,25 @@ open class BaseViewTest {
3030
height: Int,
3131
expectedPath: String,
3232
component: Component) {
33-
33+
if (DependencyResolver.ignoreViewTests) {
34+
println("WARN: Ignoring BaseViewTest assertion")
35+
return
36+
}
3437
val canvas = DependencyResolver.createCanvas(width, height)
3538
component.draw(canvas)
3639
assertRenders(expectedPath, canvas)
3740
}
3841

3942
suspend fun assertRenders(path: String,
4043
canvas: Canvas) {
41-
44+
if (DependencyResolver.ignoreViewTests) {
45+
println("WARN: Ignoring BaseViewTest assertion")
46+
return
47+
}
4248
val actualImage = canvas.toImage()
4349
val failedActualPath = "/tmp/failed/${path}"
44-
val failedExpectedPath = failedActualPath.replace(".png", ".expected.png")
50+
val failedExpectedPath = failedActualPath.replace(".png",
51+
".expected.png")
4552
val failedDiffPath = failedActualPath.replace(".png", ".diff.png")
4653
val fileOpener = DependencyResolver.getFileOpener()
4754
val expectedFile = fileOpener.openResourceFile(path)

core/src/test/ios/org/isoron/DependencyResolver.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import platform.CoreGraphics.*
2727
import platform.UIKit.*
2828

2929
actual object DependencyResolver {
30+
actual val ignoreViewTests = true
31+
3032
actual suspend fun getFileOpener(): FileOpener = IosFileOpener()
3133

3234
actual fun getDateFormatter(locale: Locale): LocalDateFormatter {
@@ -53,5 +55,4 @@ actual object DependencyResolver {
5355
db.migrateTo(LOOP_DATABASE_VERSION, fileOpener, log)
5456
return db
5557
}
56-
5758
}

core/src/test/js/org/isoron/DependencyResolver.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import org.w3c.dom.*
2727
import kotlin.browser.*
2828

2929
actual object DependencyResolver {
30+
actual val ignoreViewTests = false
31+
3032
var fileOpener: JsFileOpener? = null
3133

3234
actual suspend fun getFileOpener(): FileOpener {

core/src/test/jvm/org/isoron/DependencyResolver.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ import org.isoron.platform.io.*
2424
import org.isoron.platform.time.*
2525
import org.isoron.uhabits.*
2626
import java.awt.image.*
27-
import java.io.*
28-
import java.lang.Math.*
29-
import java.nio.file.*
30-
import javax.imageio.*
3127

3228
actual object DependencyResolver {
29+
actual val ignoreViewTests = false
30+
3331
actual suspend fun getFileOpener(): FileOpener = JavaFileOpener()
3432

3533
actual suspend fun getDatabase(): Database {

0 commit comments

Comments
 (0)