Skip to content

Commit

Permalink
Remove JUnit usages from files in main source set (#1437)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrodbx committed May 22, 2024
1 parent 08f8825 commit 1c1f074
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
20 changes: 11 additions & 9 deletions paparazzi/src/main/java/app/cash/paparazzi/internal/ImageUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

package app.cash.paparazzi.internal

import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import java.awt.AlphaComposite
import java.awt.Color
import java.awt.Graphics2D
Expand Down Expand Up @@ -68,7 +65,7 @@ internal object ImageUtils {
var message = "Unable to load golden thumbnail: $relativePath\n"
message = saveImageAndAppendMessage(thumbnail, message, relativePath, failureDir)
if (FAIL_ON_MISSING_THUMBNAIL) {
fail(message)
throw IllegalStateException(message)
} else {
println(message)
}
Expand Down Expand Up @@ -116,13 +113,15 @@ internal object ImageUtils {
val output = File(failureDir, "delta-$imageName")
if (output.exists()) {
val deleted = output.delete()
assertTrue(deleted)
if (!deleted) {
throw IllegalStateException("Unable to delete $output")
}
}
ImageIO.write(deltaImage, "PNG", output)
error += " - see details in file://" + output.path + "\n"
error = saveImageAndAppendMessage(image, error, relativePath, failureDir)
println(error)
fail(error)
throw AssertionError(error)
}
}

Expand All @@ -142,8 +141,9 @@ internal object ImageUtils {
temp.graphics.drawImage(goldenImage, 0, 0, null)
goldenImage = temp
}
assertEquals(TYPE_INT_ARGB.toLong(), goldenImage.type.toLong())

if (TYPE_INT_ARGB != goldenImage.type) {
throw IllegalStateException("expected:<$TYPE_INT_ARGB> but was:<${goldenImage.type}>")
}
val goldenImageWidth = goldenImage.width
val goldenImageHeight = goldenImage.height

Expand Down Expand Up @@ -398,7 +398,9 @@ internal object ImageUtils {
val output = File(outputDir, getName(relativePath))
if (output.exists()) {
val deleted = output.delete()
assertTrue(deleted)
if (!deleted) {
throw IllegalStateException("Unable to delete $output")
}
}
ImageIO.write(image, "PNG", output)
initialMessage += "Thumbnail for current rendering stored at file://" + output.path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import app.cash.paparazzi.internal.ImageUtils
import app.cash.paparazzi.internal.ImageUtils.resize
import okio.FileSystem
import okio.Path
import org.junit.Assert.fail
import java.awt.image.BufferedImage
import java.io.Closeable
import kotlin.math.max
Expand Down Expand Up @@ -122,7 +121,7 @@ internal class ApngVerifier(
}

if (error.isNotEmpty()) {
fail(error)
throw AssertionError(error)
}
}

Expand Down

0 comments on commit 1c1f074

Please sign in to comment.