diff --git a/Sources/SnapshotTesting/Snapshotting/CALayer.swift b/Sources/SnapshotTesting/Snapshotting/CALayer.swift index 237a5910f..365e0ffb2 100644 --- a/Sources/SnapshotTesting/Snapshotting/CALayer.swift +++ b/Sources/SnapshotTesting/Snapshotting/CALayer.swift @@ -1,5 +1,7 @@ #if os(macOS) +import AppKit import Cocoa +import QuartzCore extension Snapshotting where Value == CALayer, Format == NSImage { /// A snapshot strategy for comparing layers based on pixel equality. diff --git a/Sources/SnapshotTesting/Snapshotting/CGPath.swift b/Sources/SnapshotTesting/Snapshotting/CGPath.swift index 8e96568ec..5c32f0606 100644 --- a/Sources/SnapshotTesting/Snapshotting/CGPath.swift +++ b/Sources/SnapshotTesting/Snapshotting/CGPath.swift @@ -1,5 +1,7 @@ #if os(macOS) +import AppKit import Cocoa +import CoreGraphics extension Snapshotting where Value == CGPath, Format == NSImage { /// A snapshot strategy for comparing bezier paths based on pixel equality. diff --git a/Sources/SnapshotTesting/Snapshotting/NSBezierPath.swift b/Sources/SnapshotTesting/Snapshotting/NSBezierPath.swift index b76bf57dc..f06d31f6e 100644 --- a/Sources/SnapshotTesting/Snapshotting/NSBezierPath.swift +++ b/Sources/SnapshotTesting/Snapshotting/NSBezierPath.swift @@ -1,4 +1,5 @@ #if os(macOS) +import AppKit import Cocoa extension Snapshotting where Value == NSBezierPath, Format == NSImage { @@ -30,6 +31,7 @@ extension Snapshotting where Value == NSBezierPath, Format == NSImage { extension Snapshotting where Value == NSBezierPath, Format == String { /// A snapshot strategy for comparing bezier paths based on pixel equality. + @available(macOS 11.0, *) @available(iOS 11.0, *) public static var elementsDescription: Snapshotting { return .elementsDescription(numberFormatter: defaultNumberFormatter) @@ -38,6 +40,7 @@ extension Snapshotting where Value == NSBezierPath, Format == String { /// A snapshot strategy for comparing bezier paths based on pixel equality. /// /// - Parameter numberFormatter: The number formatter used for formatting points. + @available(macOS 11.0, *) @available(iOS 11.0, *) public static func elementsDescription(numberFormatter: NumberFormatter) -> Snapshotting { let namesByType: [NSBezierPath.ElementType: String] = [ diff --git a/Sources/SnapshotTesting/Snapshotting/NSView.swift b/Sources/SnapshotTesting/Snapshotting/NSView.swift index b0402f923..2ff70bc65 100644 --- a/Sources/SnapshotTesting/Snapshotting/NSView.swift +++ b/Sources/SnapshotTesting/Snapshotting/NSView.swift @@ -1,4 +1,5 @@ #if os(macOS) +import AppKit import Cocoa extension Snapshotting where Value == NSView, Format == NSImage { diff --git a/Sources/SnapshotTesting/Snapshotting/NSViewController.swift b/Sources/SnapshotTesting/Snapshotting/NSViewController.swift index 6f316e8a2..6976a94ef 100644 --- a/Sources/SnapshotTesting/Snapshotting/NSViewController.swift +++ b/Sources/SnapshotTesting/Snapshotting/NSViewController.swift @@ -1,4 +1,5 @@ #if os(macOS) +import AppKit import Cocoa extension Snapshotting where Value == NSViewController, Format == NSImage { diff --git a/Tests/SnapshotTestingTests/SnapshotTestingTests.swift b/Tests/SnapshotTestingTests/SnapshotTestingTests.swift index 570f24240..1de4623a6 100644 --- a/Tests/SnapshotTestingTests/SnapshotTestingTests.swift +++ b/Tests/SnapshotTestingTests/SnapshotTestingTests.swift @@ -1127,24 +1127,6 @@ final class SnapshotTestingTests: XCTestCase { _ = manipulatingWKWebViewNavigationDelegate } - #if os(iOS) || os(macOS) - func testWebViewWithRealUrl() throws { - let manipulatingWKWebViewNavigationDelegate = ManipulatingWKWebViewNavigationDelegate() - let webView = WKWebView() - webView.navigationDelegate = manipulatingWKWebViewNavigationDelegate - - webView.load(URLRequest(url: URL(string: "https://www.pointfree.co")!)) - if !ProcessInfo.processInfo.environment.keys.contains("GITHUB_WORKFLOW") { - assertSnapshot( - matching: webView, - as: .image(size: .init(width: 800, height: 600)), - named: platform - ) - } - _ = manipulatingWKWebViewNavigationDelegate - } - #endif - final class CancellingWKWebViewNavigationDelegate: NSObject, WKNavigationDelegate { func webView( _ webView: WKWebView, @@ -1154,6 +1136,7 @@ final class SnapshotTestingTests: XCTestCase { decisionHandler(.cancel) } } + func testWebViewWithCancellingNavigationDelegate() throws { let cancellingWKWebViewNavigationDelegate = CancellingWKWebViewNavigationDelegate() let webView = WKWebView() diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testCGPath.macOS.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testCGPath.macOS.png index 1ce1ab58b..e6e25b5b7 100644 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testCGPath.macOS.png and b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testCGPath.macOS.png differ diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testImagePrecision.exact.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testImagePrecision.exact.png index a62a125ad..7f3ac46bf 100644 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testImagePrecision.exact.png and b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testImagePrecision.exact.png differ diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testImagePrecision.perceptual.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testImagePrecision.perceptual.png index fb72d3c9d..7f3ac46bf 100644 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testImagePrecision.perceptual.png and b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testImagePrecision.perceptual.png differ diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSBezierPath.macOS.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSBezierPath.macOS.png index 5fa6516ca..cd649f4e7 100644 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSBezierPath.macOS.png and b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSBezierPath.macOS.png differ diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSView.1.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSView.1.png index f32c79f02..2c9a5ce57 100644 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSView.1.png and b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSView.1.png differ diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSView.2.txt b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSView.2.txt index c3f9c34a6..a9694f789 100644 --- a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSView.2.txt +++ b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSView.2.txt @@ -1,4 +1,4 @@ -[ AF ! U ] h=--- v=--- NSButton "Push Me" f=(0,0,83,32) b=(-) - [ A ! U ] h=--- v=--- NSButtonBezelView f=(0,0,83,32) b=(-) - [ AF ! U ] h=--- v=--- NSButtonTextField "Push Me" f=(11,7,61,15) b=(-) +[ AF ! wLU ] h=--- v=--- NSButton "Push Me" f=(0,0,83,32) b=(-) => <_NSViewBackingLayer> + [ A ! wLU ] h=--- v=--- NSButtonBezelView f=(0,0,83,32) b=(-) => <_NSViewBackingLayer> + [ AF ! wLU ] h=--- v=--- NSButtonTextField "Push Me" f=(11,7,61,15) b=(-) => A=autoresizesSubviews, C=canDrawConcurrently, D=needsDisplay, F=flipped, G=gstate, H=hidden (h=by ancestor), L=needsLayout (l=child needsLayout), U=needsUpdateConstraints (u=child needsUpdateConstraints), O=opaque, P=preservesContentDuringLiveResize, S=scaled/rotated, W=wantsLayer (w=ancestor wantsLayer), V=needsVibrancy (v=allowsVibrancy), #=has surface diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSViewWithLayer.1.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSViewWithLayer.1.png index 399ccf5d2..c9e6ea4a9 100644 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSViewWithLayer.1.png and b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testNSViewWithLayer.1.png differ diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testPrecision.macos.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testPrecision.macos.png index 590f58867..d0f149a54 100644 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testPrecision.macos.png and b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testPrecision.macos.png differ diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebView.macos.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebView.macos.png index 37c5832fb..f6fd0490c 100644 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebView.macos.png and b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebView.macos.png differ diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebViewWithManipulatingNavigationDelegate.macos.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebViewWithManipulatingNavigationDelegate.macos.png index ff369e916..f6fd0490c 100644 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebViewWithManipulatingNavigationDelegate.macos.png and b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebViewWithManipulatingNavigationDelegate.macos.png differ diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebViewWithRealUrl.ios.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebViewWithRealUrl.ios.png deleted file mode 100644 index 1204d4055..000000000 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebViewWithRealUrl.ios.png and /dev/null differ diff --git a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebViewWithRealUrl.macos.png b/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebViewWithRealUrl.macos.png deleted file mode 100644 index c222dbc0b..000000000 Binary files a/Tests/SnapshotTestingTests/__Snapshots__/SnapshotTestingTests/testWebViewWithRealUrl.macos.png and /dev/null differ