From 3ebb472f7ecb1a79a84121422c923a3ba454c581 Mon Sep 17 00:00:00 2001 From: Adrian Sergheev Date: Tue, 9 Jan 2024 11:24:40 +0100 Subject: [PATCH 1/7] fix --- Sources/DemoKitSnapshot/XCTestCase+Extensions.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift index 82b9c12..4421e02 100644 --- a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift +++ b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift @@ -149,7 +149,6 @@ extension XCTestCase { line: UInt ) { UIView.setAnimationsEnabled(false) - let subpixelThreshold: UInt8 = 5 let userInterfaceStyle: [UIUserInterfaceStyle] = [.light, .dark] userInterfaceStyle.forEach { userInterfaceStyle in @@ -165,7 +164,6 @@ extension XCTestCase { matching: viewController, as: .image( on: device.imageConfig, - subpixelThreshold: subpixelThreshold, traits: traits ), named: name, From 4292af523704ead967558f9079ec30de92fc68e8 Mon Sep 17 00:00:00 2001 From: Adrian Sergheev Date: Tue, 9 Jan 2024 12:23:13 +0100 Subject: [PATCH 2/7] re-enable perceptualPrecision --- Sources/DemoKitSnapshot/XCTestCase+Extensions.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift index 4421e02..f7f40c6 100644 --- a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift +++ b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift @@ -149,6 +149,7 @@ extension XCTestCase { line: UInt ) { UIView.setAnimationsEnabled(false) + let perceptualPrecision: Float = 5 let userInterfaceStyle: [UIUserInterfaceStyle] = [.light, .dark] userInterfaceStyle.forEach { userInterfaceStyle in @@ -164,6 +165,7 @@ extension XCTestCase { matching: viewController, as: .image( on: device.imageConfig, + perceptualPrecision: perceptualPrecision, traits: traits ), named: name, From 92c30db434ba04d04a56257e851135227af32a8c Mon Sep 17 00:00:00 2001 From: Adrian Sergheev Date: Tue, 9 Jan 2024 14:00:10 +0100 Subject: [PATCH 3/7] wip --- Sources/DemoKitSnapshot/XCTestCase+Extensions.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift index f7f40c6..2cf08cd 100644 --- a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift +++ b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift @@ -149,7 +149,7 @@ extension XCTestCase { line: UInt ) { UIView.setAnimationsEnabled(false) - let perceptualPrecision: Float = 5 + let perceptualPrecision: Float = 0.98 let userInterfaceStyle: [UIUserInterfaceStyle] = [.light, .dark] userInterfaceStyle.forEach { userInterfaceStyle in From 23566e9ad4445de75ce9cef661dc7bb54f3dfd95 Mon Sep 17 00:00:00 2001 From: Adrian Sergheev Date: Wed, 10 Jan 2024 12:46:53 +0100 Subject: [PATCH 4/7] 0.98->0.95 --- Sources/DemoKitSnapshot/XCTestCase+Extensions.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift index 2cf08cd..1f188cd 100644 --- a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift +++ b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift @@ -149,7 +149,7 @@ extension XCTestCase { line: UInt ) { UIView.setAnimationsEnabled(false) - let perceptualPrecision: Float = 0.98 + let perceptualPrecision: Float = 0.95 let userInterfaceStyle: [UIUserInterfaceStyle] = [.light, .dark] userInterfaceStyle.forEach { userInterfaceStyle in From b7dd1a073034b740b97d2b3ce4d3cafaebd6b3a5 Mon Sep 17 00:00:00 2001 From: Adrian Sergheev Date: Wed, 10 Jan 2024 14:35:01 +0100 Subject: [PATCH 5/7] precision --- Sources/DemoKitSnapshot/XCTestCase+Extensions.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift index 1f188cd..f9e8787 100644 --- a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift +++ b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift @@ -149,7 +149,8 @@ extension XCTestCase { line: UInt ) { UIView.setAnimationsEnabled(false) - let perceptualPrecision: Float = 0.95 + let precision: Float = 0.9 + let perceptualPrecision: Float = 0.98 let userInterfaceStyle: [UIUserInterfaceStyle] = [.light, .dark] userInterfaceStyle.forEach { userInterfaceStyle in @@ -165,6 +166,7 @@ extension XCTestCase { matching: viewController, as: .image( on: device.imageConfig, + precision: precision, perceptualPrecision: perceptualPrecision, traits: traits ), From 33451bdf1b9d13a8287902513a25ba03dc07046d Mon Sep 17 00:00:00 2001 From: Adrian Sergheev Date: Fri, 12 Jan 2024 13:44:49 +0100 Subject: [PATCH 6/7] try 0.98 for precision --- Sources/DemoKitSnapshot/XCTestCase+Extensions.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift index f9e8787..d0a6092 100644 --- a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift +++ b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift @@ -149,7 +149,7 @@ extension XCTestCase { line: UInt ) { UIView.setAnimationsEnabled(false) - let precision: Float = 0.9 + let precision: Float = 0.98 let perceptualPrecision: Float = 0.98 let userInterfaceStyle: [UIUserInterfaceStyle] = [.light, .dark] From 19ab879cf789a563d81a3e2cfe7aaa59f289ef6e Mon Sep 17 00:00:00 2001 From: Adrian Sergheev Date: Fri, 12 Jan 2024 16:06:06 +0100 Subject: [PATCH 7/7] pass precision, percpetualPrecision as parameters --- Sources/DemoKitSnapshot/XCTestCase+Extensions.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift index d0a6092..aa8d7b6 100644 --- a/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift +++ b/Sources/DemoKitSnapshot/XCTestCase+Extensions.swift @@ -34,6 +34,9 @@ extension XCTestCase { public func snapshotTest( demoable: any Demoable, record: Bool = false, + // https://github.com/pointfreeco/swift-snapshot-testing/pull/628#issuecomment-1256363278 + precision: Float = 0.98, + perceptualPrecision: Float = 0.98, file: StaticString = #file, line: UInt = #line ) { @@ -50,8 +53,10 @@ extension XCTestCase { performSnapshots( viewController: viewController, record: record, - testName: demoable.identifier, + testName: demoable.identifier, tweakName: tweak.testName, + precision: precision, + perceptualPrecision: perceptualPrecision, file: file, line: line ) @@ -61,6 +66,8 @@ extension XCTestCase { viewController: viewController, record: record, testName: demoable.identifier, + precision: precision, + perceptualPrecision: perceptualPrecision, file: file, line: line ) @@ -145,12 +152,12 @@ extension XCTestCase { record: Bool, testName: String, tweakName: String? = nil, + precision: Float = 0.98, + perceptualPrecision: Float = 0.98, file: StaticString, line: UInt ) { UIView.setAnimationsEnabled(false) - let precision: Float = 0.98 - let perceptualPrecision: Float = 0.98 let userInterfaceStyle: [UIUserInterfaceStyle] = [.light, .dark] userInterfaceStyle.forEach { userInterfaceStyle in