-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consider pixel order when comparing images (#227)
* Consider pixel order when comparing images * Fix typo on README
- Loading branch information
1 parent
deb900d
commit 1394350
Showing
5 changed files
with
49 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
core/src/test/scala/com/karumi/shot/screenshots/ScreenshotsComparatorTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.karumi.shot.screenshots | ||
|
||
import com.karumi.shot.Resources | ||
import com.karumi.shot.domain.{Dimension, Screenshot} | ||
import com.karumi.shot.domain.model.ScreenshotsSuite | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should | ||
|
||
class ScreenshotsComparatorTest extends AnyFlatSpec with should.Matchers with Resources { | ||
|
||
private val sampleImage = getClass.getClassLoader.getResource("images/sample.png").getPath | ||
private val sampleImageScrambled = | ||
getClass.getClassLoader.getResource("images/sample-scrambled.png").getPath | ||
|
||
it should "not match image with same pixels but different order" in { | ||
val comparator = new ScreenshotsComparator() | ||
val screenshot = Screenshot("test", | ||
sampleImage, | ||
sampleImageScrambled, | ||
"SomeClass", | ||
"ShoudFail", | ||
Dimension(768, 1280), | ||
null, | ||
null, | ||
null, | ||
List(sampleImageScrambled), | ||
Dimension(768, 1280)) | ||
val suite: ScreenshotsSuite = List(screenshot) | ||
|
||
val result = comparator.compare(suite, 0.01) | ||
|
||
result.hasErrors shouldBe true | ||
} | ||
} |