Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e4e52b4
add assets
IvanNextToJunior Oct 19, 2022
f78394c
replace images
IvanNextToJunior Oct 20, 2022
63d4d7b
add images for testing
IvanNextToJunior Oct 22, 2022
3683456
add tools version; change comparison method
IvanNextToJunior Oct 23, 2022
aab9426
Update Package.swift
IvanNextToJunior Oct 23, 2022
1228c4e
revert
IvanNextToJunior Oct 23, 2022
17ded2a
Update Package.swift
IvanNextToJunior Oct 23, 2022
cd7d960
rewrite testStrictComparison to use input images;
schmidt9 Oct 23, 2022
99548e3
rename & update images for strict test
schmidt9 Oct 24, 2022
c66ce43
modify tests; add images
IvanNextToJunior Oct 24, 2022
3435948
Update CompareImagesTests.swift
IvanNextToJunior Oct 25, 2022
8597e74
add .swiftpm to .gitignore
schmidt9 Oct 26, 2022
60beb6b
refactor
IvanNextToJunior Oct 26, 2022
2ca954c
fix formatting
schmidt9 Oct 26, 2022
23731de
fix formatting
schmidt9 Oct 26, 2022
eac0923
add images; modify tests
IvanNextToJunior Oct 28, 2022
de5ca2e
add saving difference images option
schmidt9 Oct 28, 2022
f9809fe
add difference testing to GetImagePathsTests
schmidt9 Oct 28, 2022
90f24c3
update strict test images
schmidt9 Oct 29, 2022
5816d3c
rename strict asset images;
schmidt9 Oct 29, 2022
e524b19
add grayscale test images
schmidt9 Oct 29, 2022
7c537e7
update average color test images
schmidt9 Oct 29, 2022
a47862c
add difference image saving note
schmidt9 Oct 29, 2022
2604e71
update dna test images;
schmidt9 Oct 29, 2022
dbdd914
rewrite tests using asset images
schmidt9 Oct 29, 2022
327a912
clean spaces
schmidt9 Oct 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/Packages
/*.xcodeproj
xcuserdata/
.swiftpm
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.1
// swift-tools-version:5.3

/*
SUITCase
Expand Down
6 changes: 6 additions & 0 deletions Sources/SUITCase/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "de_iPhone_X_dna_unexpected.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dna_difference.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_average_difference.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_average_reference.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_average_unexpected.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_dna_reference.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_greyscale_difference.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_greyscale_reference.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_greyscale_unexpected.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_strict_difference.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_strict_reference.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_strict_unexpected.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_tolerance_difference.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_tolerance_reference.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "en_iPhone_X_tolerance_unexpected.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions Sources/SUITCase/SUITCase+getImagePaths.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension SUITCase {

// swiftlint:disable large_tuple
func getImagePaths(withLabel customLabel: String?,
imageSize: CGSize) throws -> (reference: String, suggested: String, unexpected: String) {
imageSize: CGSize) throws -> (reference: String, suggested: String, unexpected: String, difference: String) {
guard let imagesFolder = SUITCase.screenshotComparisonImagesFolder,
let testClassName = testClassName,
var testName = testName,
Expand All @@ -50,11 +50,11 @@ extension SUITCase {
}

var imagePaths: [String] = []
for subfolder in ["Reference", "Suggested", "Unexpected"] {
for subfolder in ["Reference", "Suggested", "Unexpected", "Difference"] {
let fullPath = [imagesFolder, subfolder, filePath].joined(separator: "/")
imagePaths.append(fullPath)
}

return (imagePaths[0], imagePaths[1], imagePaths[2])
return (imagePaths[0], imagePaths[1], imagePaths[2], imagePaths[3])
}
}
9 changes: 8 additions & 1 deletion Sources/SUITCase/SUITCase+verifyScreenshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,16 @@ extension SUITCase {
addNote("Collected and reference screenshots are similar")
} else {
addImage(referenceImage, name: "Reference image")
addImage(difference.image.uiImage, name: "Difference image")
let differenceImage = difference.image.uiImage
addImage(differenceImage, name: "Difference image")
if difference.value > threshold {
try actualImage.writePNG(filePath: filePaths.unexpected)

if savesDifferenceImages {
try differenceImage.writePNG(filePath: filePaths.difference)
addNote("Difference image saving is enabled. Saved difference image")
}

throw VerifyScreenshotError.noMatch
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/SUITCase/SUITCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ open class SUITCase: XCTestCase {
public var screenshotComparisonGlobalThreshold = 0.01
/// Changes current reference images naming strategy.
public var screenshotComparisonNamingStrategy = ScreenshotComparisonNamingStrategies.imageSize
/// Indicates weather difference images should be saved along with collected (unexpected) images
public var savesDifferenceImages = false
}
Loading