Skip to content

Commit

Permalink
Make diff percent nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirom committed Oct 12, 2024
1 parent d7cdd7c commit 2234f1c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.github.takahirom.roborazzi

import com.dropbox.differ.ImageComparator
import java.io.File
import kotlin.properties.Delegates

fun interface EmptyCanvasFactory {
operator fun invoke(
Expand Down Expand Up @@ -87,7 +86,7 @@ fun processOutputImageAndReport(
}

// Only used by CaptureResult.Changed
var diffPercentage by Delegates.notNull<Float>()
var diffPercentage: Float? = null

val changed = if (height == goldenRoboCanvas.height && width == goldenRoboCanvas.width) {
val comparisonResult: ImageComparator.ComparisonResult =
Expand All @@ -101,7 +100,6 @@ fun processOutputImageAndReport(
reportLog("${goldenFile.name} The differ result :$comparisonResult changed:$changed")
changed
} else {
diffPercentage = Float.NaN // diff. percentage is not defined if new canvas and golden canvas dimensions differ
reportLog("${goldenFile.name} The image size is changed. actual = (${goldenRoboCanvas.width}, ${goldenRoboCanvas.height}), golden = (${newRoboCanvas.croppedWidth}, ${newRoboCanvas.croppedHeight})")
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ sealed interface CaptureResult {
@SerialName("timestamp")
override val timestampNs: Long,
@SerialName("diff_percentage")
val diffPercentage: Float,
val diffPercentage: Float?,
@SerialName("context_data")
override val contextData: Map<String,@Contextual Any>
) : CaptureResult {
Expand Down

0 comments on commit 2234f1c

Please sign in to comment.