-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from alexey1312/feature/addHEICformat
Add HEIC format
- Loading branch information
Showing
12 changed files
with
226 additions
and
42 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
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,7 @@ | ||
import Foundation | ||
import SnapshotTestingHEIC | ||
|
||
public enum ImageFormat { | ||
case png | ||
case heic(_ compression: CompressionQuality = .lossless) | ||
} |
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
130 changes: 130 additions & 0 deletions
130
Tests/SnapshotTestingStitchTests/SnapshotTestingStitchHEIC.swift
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,130 @@ | ||
import XCTest | ||
import SnapshotTesting | ||
import SnapshotTestingHEIC | ||
@testable import SnapshotTestingStitch | ||
|
||
final class SnapshotTestingStitchHEICTests: XCTestCase { | ||
|
||
let isRecording: Bool = false | ||
|
||
func test_withTitles() { | ||
assertSnapshot( | ||
matching: createTestViewController(), | ||
as: .stitch( | ||
strategies: [ | ||
("iPhone 8", .image(on: .iPhone8)), | ||
("iPhone 8 Plus", .image(on: .iPhone8Plus)), | ||
], | ||
format: .heic() | ||
), | ||
record: isRecording | ||
) | ||
} | ||
|
||
func test_withoutTitles() { | ||
assertSnapshot( | ||
matching: createTestViewController(), | ||
as: .stitch( | ||
strategies: [ | ||
.image(on: .iPhone8), | ||
.image(on: .iPhone8Plus), | ||
], | ||
format: .heic() | ||
), | ||
record: isRecording | ||
) | ||
} | ||
|
||
func test_withoutBorder() { | ||
assertSnapshot( | ||
matching: createTestViewController(), | ||
as: .stitch( | ||
strategies: [ | ||
("iPhone 8", .image(on: .iPhone8)), | ||
("iPhone 8 Plus", .image(on: .iPhone8Plus)), | ||
], | ||
style: .init(borderWidth: 0), | ||
format: .heic() | ||
), | ||
record: isRecording | ||
) | ||
} | ||
|
||
func test_withManyDevices() { | ||
assertSnapshot( | ||
matching: createTestViewController(), | ||
as: .stitch( | ||
strategies: [ | ||
("iPhone 8", .image(on: .iPhone8)), | ||
("iPhone 8 Plus", .image(on: .iPhone8Plus)), | ||
("iPhone X", .image(on: .iPhoneX)), | ||
("iPhone SE", .image(on: .iPhoneSe)), | ||
("iPhone Xr", .image(on: .iPhoneXr)), | ||
("iPhone Xs Max", .image(on: .iPhoneXsMax)), | ||
("iPhone Xs Max (Landscape)", .image(on: .iPhoneXsMax(.landscape))), | ||
], | ||
format: .heic() | ||
), | ||
record: isRecording | ||
) | ||
} | ||
|
||
func test_withView() { | ||
assertSnapshot( | ||
matching: createTestView(), | ||
as: .stitch( | ||
strategies: [ | ||
("100x", .image(size: CGSize(width: 100, height: 100))), | ||
("250x", .image(size: CGSize(width: 250, height: 250))), | ||
], | ||
format: .heic() | ||
), | ||
record: isRecording | ||
) | ||
} | ||
|
||
func test_withNoStrategies() { | ||
// You actually get a compiler warning for ambiguity by default, so you have to go through some loops to pass | ||
// literally nothing through. | ||
let tasks: [Snapshotting<UIView, UIImage>] = [] | ||
|
||
assertSnapshot( | ||
matching: createTestView(), | ||
as: .stitch(strategies: tasks, format: .heic()), | ||
record: isRecording | ||
) | ||
} | ||
|
||
func test_withConfigure() { | ||
assertSnapshot( | ||
matching: createTestViewController(), | ||
as: .stitch(strategies: [ | ||
.init(name: "Green", strategy: .image, configure: { $0.view.backgroundColor = .green }), | ||
.init(name: "Pink", strategy: .image, configure: { $0.view.backgroundColor = .systemPink }), | ||
// The input value is being manipulated, which means if you don't reconfigure it then it will be the | ||
// same as the previous test. | ||
.init(name: "Pink (No Configure)", strategy: .image, configure: nil), | ||
], | ||
format: .heic() | ||
), | ||
record: isRecording | ||
) | ||
} | ||
|
||
// MARK: - Helpers | ||
|
||
func createTestViewController() -> UIViewController { | ||
let viewController = UIViewController() | ||
viewController.view.backgroundColor = .blue | ||
|
||
return viewController | ||
} | ||
|
||
func createTestView() -> UIView { | ||
let view = UIView(frame: .zero) | ||
view.backgroundColor = .green | ||
|
||
return view | ||
} | ||
|
||
} |
Binary file added
BIN
+14.8 KB
...pshotTestingStitchTests/__Snapshots__/SnapshotTestingStitchHEIC/test_withConfigure.1.heic
Binary file not shown.
Binary file added
BIN
+42.9 KB
...hotTestingStitchTests/__Snapshots__/SnapshotTestingStitchHEIC/test_withManyDevices.1.heic
Binary file not shown.
Binary file added
BIN
+29.7 KB
...otTestingStitchTests/__Snapshots__/SnapshotTestingStitchHEIC/test_withNoStrategies.1.heic
Binary file not shown.
Binary file added
BIN
+11.3 KB
...SnapshotTestingStitchTests/__Snapshots__/SnapshotTestingStitchHEIC/test_withTitles.1.heic
Binary file not shown.
Binary file added
BIN
+3.92 KB
...s/SnapshotTestingStitchTests/__Snapshots__/SnapshotTestingStitchHEIC/test_withView.1.heic
Binary file not shown.
Binary file added
BIN
+9.85 KB
...pshotTestingStitchTests/__Snapshots__/SnapshotTestingStitchHEIC/test_withoutBorder.1.heic
Binary file not shown.
Binary file added
BIN
+6.51 KB
...pshotTestingStitchTests/__Snapshots__/SnapshotTestingStitchHEIC/test_withoutTitles.1.heic
Binary file not shown.