Added unit tests for WebP settings.
This commit is contained in:
parent
66cfc23f1c
commit
e330f22573
|
@ -7,7 +7,6 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
220A6239257EAFB300262720 /* SDWebImageWebPCoderDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 220A6237257EAFB300262720 /* SDWebImageWebPCoderDefine.m */; };
|
||||
220A623A257EAFB300262720 /* SDWebImageWebPCoderDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 220A6237257EAFB300262720 /* SDWebImageWebPCoderDefine.m */; };
|
||||
220A623B257EAFB300262720 /* SDWebImageWebPCoderDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 220A6237257EAFB300262720 /* SDWebImageWebPCoderDefine.m */; };
|
||||
220A623C257EAFB300262720 /* SDWebImageWebPCoderDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 220A6237257EAFB300262720 /* SDWebImageWebPCoderDefine.m */; };
|
||||
|
@ -15,6 +14,7 @@
|
|||
220A623E257EAFB300262720 /* SDWebImageWebPCoderDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 220A6238257EAFB300262720 /* SDWebImageWebPCoderDefine.h */; };
|
||||
220A623F257EAFB300262720 /* SDWebImageWebPCoderDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 220A6238257EAFB300262720 /* SDWebImageWebPCoderDefine.h */; };
|
||||
220A6240257EAFB300262720 /* SDWebImageWebPCoderDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 220A6238257EAFB300262720 /* SDWebImageWebPCoderDefine.h */; };
|
||||
228EA36125825A52005903D9 /* SDWebImageWebPCoderDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 220A6237257EAFB300262720 /* SDWebImageWebPCoderDefine.m */; };
|
||||
806E77B32136A2E900A316D2 /* UIImage+WebP.m in Sources */ = {isa = PBXBuildFile; fileRef = 806E77AA2136A2E900A316D2 /* UIImage+WebP.m */; };
|
||||
806E77B42136A2E900A316D2 /* SDImageWebPCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 806E77AB2136A2E900A316D2 /* SDImageWebPCoder.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
806E77B62136A2E900A316D2 /* UIImage+WebP.h in Headers */ = {isa = PBXBuildFile; fileRef = 806E77AD2136A2E900A316D2 /* UIImage+WebP.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
|
@ -432,7 +432,7 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
220A6239257EAFB300262720 /* SDWebImageWebPCoderDefine.m in Sources */,
|
||||
228EA36125825A52005903D9 /* SDWebImageWebPCoderDefine.m in Sources */,
|
||||
806E77B72136A2E900A316D2 /* SDImageWebPCoder.m in Sources */,
|
||||
806E77B32136A2E900A316D2 /* UIImage+WebP.m in Sources */,
|
||||
);
|
||||
|
|
|
@ -12,6 +12,20 @@
|
|||
@import SDWebImage;
|
||||
#endif
|
||||
|
||||
#if __has_include("webp/decode.h") && __has_include("webp/encode.h") && __has_include("webp/demux.h") && __has_include("webp/mux.h")
|
||||
#import "webp/decode.h"
|
||||
#import "webp/encode.h"
|
||||
#import "webp/demux.h"
|
||||
#import "webp/mux.h"
|
||||
#elif __has_include(<libwebp/decode.h>) && __has_include(<libwebp/encode.h>) && __has_include(<libwebp/demux.h>) && __has_include(<libwebp/mux.h>)
|
||||
#import <libwebp/decode.h>
|
||||
#import <libwebp/encode.h>
|
||||
#import <libwebp/demux.h>
|
||||
#import <libwebp/mux.h>
|
||||
#else
|
||||
@import libwebp;
|
||||
#endif
|
||||
|
||||
/**
|
||||
Built in coder that supports WebP and animated WebP
|
||||
*/
|
||||
|
@ -19,4 +33,8 @@
|
|||
|
||||
@property (nonatomic, class, readonly, nonnull) SDImageWebPCoder *sharedCoder;
|
||||
|
||||
- (void) updateWebPOptionsToConfig:(WebPConfig * _Nonnull)config
|
||||
maxFileSize:(NSUInteger)maxFileSize
|
||||
options:(nullable SDImageCoderOptions *)options;
|
||||
|
||||
@end
|
||||
|
|
|
@ -841,7 +841,7 @@ static CGSize SDCalculateThumbnailSize(CGSize fullSize, BOOL preserveAspectRatio
|
|||
return webpData;
|
||||
}
|
||||
|
||||
- (void) updateWebPOptionsToConfig:(WebPConfig*)config
|
||||
- (void) updateWebPOptionsToConfig:(WebPConfig * _Nonnull)config
|
||||
maxFileSize:(NSUInteger)maxFileSize
|
||||
options:(nullable SDImageCoderOptions *)options {
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
@import XCTest;
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoderDefine.h>
|
||||
#import <Expecta/Expecta.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
|
@ -196,6 +197,54 @@ const int64_t kAsyncTestTimeout = 5;
|
|||
XCTAssertLessThanOrEqual(dataWithLimit.length, maxFileSize);
|
||||
}
|
||||
|
||||
- (void)testEncodingSettings {
|
||||
WebPConfig config;
|
||||
WebPConfigPreset(&config, WEBP_PRESET_DEFAULT, 0.2);
|
||||
|
||||
SDImageCoderOptions *options = @{ SDImageCoderEncodeWebPMethod: @1,
|
||||
SDImageCoderEncodeWebPPass: @2,
|
||||
SDImageCoderEncodeWebPPreprocessing: @3,
|
||||
SDImageCoderEncodeWebPThreadLevel: @4,
|
||||
SDImageCoderEncodeWebPLowMemory: @5,
|
||||
SDImageCoderEncodeWebPTargetPSNR: @6,
|
||||
SDImageCoderEncodeWebPSegments: @7,
|
||||
SDImageCoderEncodeWebPSnsStrength: @8,
|
||||
SDImageCoderEncodeWebPFilterStrength: @9,
|
||||
SDImageCoderEncodeWebPFilterSharpness: @10,
|
||||
SDImageCoderEncodeWebPFilterType: @11,
|
||||
SDImageCoderEncodeWebPAutofilter: @12,
|
||||
SDImageCoderEncodeWebPAlphaCompression: @13,
|
||||
SDImageCoderEncodeWebPAlphaFiltering: @14,
|
||||
SDImageCoderEncodeWebPAlphaQuality: @15,
|
||||
SDImageCoderEncodeWebPShowCompressed: @16,
|
||||
SDImageCoderEncodeWebPPartitions: @17,
|
||||
SDImageCoderEncodeWebPPartitionLimit: @18,
|
||||
SDImageCoderEncodeWebPUseSharpYuv: @19 };
|
||||
|
||||
[SDImageWebPCoder.sharedCoder updateWebPOptionsToConfig:&config maxFileSize:1200 options:options];
|
||||
|
||||
expect(config.method).to.equal(1);
|
||||
expect(config.pass).to.equal(2);
|
||||
expect(config.preprocessing).to.equal(3);
|
||||
expect(config.thread_level).to.equal(4);
|
||||
expect(config.low_memory).to.equal(5);
|
||||
expect(config.target_PSNR).to.equal(6);
|
||||
expect(config.segments).to.equal(7);
|
||||
expect(config.sns_strength).to.equal(8);
|
||||
expect(config.filter_strength).to.equal(9);
|
||||
expect(config.filter_sharpness).to.equal(10);
|
||||
expect(config.filter_type).to.equal(11);
|
||||
expect(config.autofilter).to.equal(12);
|
||||
expect(config.alpha_compression).to.equal(13);
|
||||
expect(config.alpha_filtering).to.equal(14);
|
||||
expect(config.alpha_quality).to.equal(15);
|
||||
expect(config.show_compressed).to.equal(16);
|
||||
expect(config.partitions).to.equal(17);
|
||||
expect(config.partition_limit).to.equal(18);
|
||||
expect(config.use_sharp_yuv).to.equal(19);
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SDWebImageWebPCoderTests (Helpers)
|
||||
|
|
Loading…
Reference in New Issue