Skip to content

Commit 7278f8a

Browse files
committed
Add WebP tests
1 parent e7341f7 commit 7278f8a

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

Documentation/Guides/image-formats.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,6 @@ ImagePipeline.shared.loadImage(with: url) { [weak self] result in
396396

397397
[WebP](https://developers.google.com/speed/webp) support is provided by [Nuke WebP Plugin](https://github.com/ryokosuge/Nuke-WebP-Plugin) built by [Ryo Kosuge](https://github.com/ryokosuge). Please follow the instructions from the repo.
398398

399-
#### Native Support (macOS 11, iOS 14, watchOS 7, tvOS 14)
399+
#### Native Support (macOS 11, iOS 14, watchOS 7)
400400

401401
WebP is now supported natively. Nuke currently only supports baseline WebP (no progressive WebP support).

Nuke.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
0C91B0F42438E38B007F9100 /* CompositionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C91B0F32438E38B007F9100 /* CompositionTests.swift */; };
9696
0C91B0F62438E3CB007F9100 /* GaussianBlurTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C91B0F52438E3CB007F9100 /* GaussianBlurTests.swift */; };
9797
0C91B0F82438E84E007F9100 /* fixture-tiny.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = 0C91B0F72438E84E007F9100 /* fixture-tiny.jpeg */; };
98-
0C95FD3E25718983008D4FC2 /* baseline.webp in Resources */ = {isa = PBXBuildFile; fileRef = 0C95FD3D2571897A008D4FC2 /* baseline.webp */; };
98+
0C95FD542571B278008D4FC2 /* baseline.webp in Resources */ = {isa = PBXBuildFile; fileRef = 0C95FD532571B278008D4FC2 /* baseline.webp */; };
9999
0C973E141D9FDB9F00C00AD9 /* Nuke.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0C9174901BAE99EE004A7905 /* Nuke.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
100100
0C9B6E7620B9F3E2001924B8 /* ImagePipelineDeduplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C9B6E7520B9F3E2001924B8 /* ImagePipelineDeduplicationTests.swift */; };
101101
0CAAB0101E45D6DA00924450 /* NukeExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CAAB00F1E45D6DA00924450 /* NukeExtensions.swift */; };
@@ -229,7 +229,7 @@
229229
0C91B0F52438E3CB007F9100 /* GaussianBlurTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GaussianBlurTests.swift; sourceTree = "<group>"; };
230230
0C91B0F72438E84E007F9100 /* fixture-tiny.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "fixture-tiny.jpeg"; sourceTree = "<group>"; };
231231
0C94466D1D47EC0E006DB314 /* ImageViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageViewTests.swift; sourceTree = "<group>"; };
232-
0C95FD3D2571897A008D4FC2 /* baseline.webp */ = {isa = PBXFileReference; lastKnownFileType = file; name = baseline.webp; path = "../../../../Library/Developer/Xcode/DerivedData/NukeDemo-ccwtenmfandmacgnpytuoagmopvo/SourcePackages/checkouts/Nuke/Tests/Resources/baseline.webp"; sourceTree = "<group>"; };
232+
0C95FD532571B278008D4FC2 /* baseline.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = baseline.webp; sourceTree = "<group>"; };
233233
0C9B6E7520B9F3E2001924B8 /* ImagePipelineDeduplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePipelineDeduplicationTests.swift; sourceTree = "<group>"; };
234234
0CA82BDC237AE09F00338375 /* install_swiftlint.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = install_swiftlint.sh; path = Scripts/install_swiftlint.sh; sourceTree = "<group>"; };
235235
0CAAB00F1E45D6DA00924450 /* NukeExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NukeExtensions.swift; sourceTree = "<group>"; };
@@ -338,10 +338,10 @@
338338
children = (
339339
0C70D9702089016800A49DAC /* baseline.jpeg */,
340340
0C70D96F2089016700A49DAC /* progressive.jpeg */,
341+
0C95FD532571B278008D4FC2 /* baseline.webp */,
341342
0C09B1651FE9A65600E8FE3B /* fixture.jpeg */,
342343
0C91B0F72438E84E007F9100 /* fixture-tiny.jpeg */,
343344
0C70D97B2089042400A49DAC /* fixture.png */,
344-
0C95FD3D2571897A008D4FC2 /* baseline.webp */,
345345
0C64F73E243838BF001983C6 /* swift.png */,
346346
0C6B5BDA257010B400D763F2 /* image-p3.jpg */,
347347
0C64F73C243836B5001983C6 /* img_751.heic */,
@@ -753,10 +753,10 @@
753753
0C7CE29B2439417C0018C8C3 /* s-sepia.png in Resources */,
754754
0C91B0F82438E84E007F9100 /* fixture-tiny.jpeg in Resources */,
755755
0C70D9742089016800A49DAC /* baseline.jpeg in Resources */,
756+
0C95FD542571B278008D4FC2 /* baseline.webp in Resources */,
756757
0C7CE28B243933550018C8C3 /* s-rounded-corners.png in Resources */,
757758
0C70D9712089016800A49DAC /* progressive.jpeg in Resources */,
758759
0C7CE28D2439342C0018C8C3 /* s-rounded-corners-border.png in Resources */,
759-
0C95FD3E25718983008D4FC2 /* baseline.webp in Resources */,
760760
);
761761
runOnlyForDeploymentPostprocessing = 0;
762762
};

Tests/ImageDecoderTests.swift

+12
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ class ImageDecoderTests: XCTestCase {
133133
XCTAssertNotNil(container)
134134
XCTAssertNil(container?.data)
135135
}
136+
137+
func testDecodeBaselineWebP() {
138+
let data = Test.data(name: "baseline", extension: "webp")
139+
let container = ImageDecoders.Default().decode(data)
140+
if #available(OSX 15, iOS 14.0, watchOS 7.0, tvOS 999.0, *) {
141+
XCTAssertNotNil(container)
142+
XCTAssertNil(container?.data)
143+
} else {
144+
XCTAssertNil(container)
145+
XCTAssertNil(container?.data)
146+
}
147+
}
136148
}
137149

138150
class ImageTypeTests: XCTestCase {

Tests/Resources/baseline.webp

29.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)