Skip to content

Commit 1d56cb7

Browse files
committed
Add tests for os(macOS)
1 parent 95f5512 commit 1d56cb7

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

Tests/SnapshotTestingHEICTests/SnapshotTestingHEICTests.swift

+27-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
#if os(iOS) || os(tvOS)
21
import XCTest
32
import SnapshotTesting
43
@testable import SnapshotTestingHEIC
54

65
final class SnapshotTestingHEICTests: XCTestCase {
76

7+
#if os(iOS) || os(tvOS)
88
var sut: TestViewController!
99

1010
override func setUp() {
1111
super.setUp()
1212
sut = TestViewController()
13-
// isRecording = true
13+
// isRecording = true
1414
}
1515

1616
override func tearDown() {
17+
sut = nil
1718
super.tearDown()
1819
}
1920

@@ -40,6 +41,29 @@ final class SnapshotTestingHEICTests: XCTestCase {
4041
assertSnapshot(matching: sut, as: .imageHEIC(on: .iPadPro12_9,
4142
compressionQuality: 0.75))
4243
}
44+
#endif
4345

44-
}
46+
47+
#if os(macOS)
48+
func test_HEIC_NSView() {
49+
// given
50+
let view = NSView()
51+
let button = NSButton()
52+
// when
53+
view.frame = CGRect(origin: .zero, size: CGSize(width: 400, height: 400))
54+
view.wantsLayer = true
55+
view.layer?.backgroundColor = NSColor.blue.cgColor
56+
view.addSubview(button)
57+
button.frame.origin = CGPoint(x: view.frame.origin.x + view.frame.size.width / 2.0,
58+
y: view.frame.origin.y + view.frame.size.height / 2.0)
59+
button.bezelStyle = .rounded
60+
button.title = "Push Me"
61+
button.wantsLayer = true
62+
button.layer?.backgroundColor = NSColor.red.cgColor
63+
button.sizeToFit()
64+
// then
65+
assertSnapshot(matching: view, as: .imageHEIC)
66+
}
4567
#endif
68+
69+
}

0 commit comments

Comments
 (0)