Move the test case `testWebPDecodeDoesNotTriggerCACopyImage` into the WebP repo
Also, fix the min deployment target
This commit is contained in:
parent
8a33fb3ca7
commit
2097f9bcdf
26
Podfile
26
Podfile
|
@ -1,6 +1,5 @@
|
||||||
install! "cocoapods",
|
install! "cocoapods",
|
||||||
:generate_multiple_pod_projects => true,
|
:generate_multiple_pod_projects => true
|
||||||
:incremental_installation => true
|
|
||||||
|
|
||||||
use_frameworks!
|
use_frameworks!
|
||||||
|
|
||||||
|
@ -33,3 +32,26 @@ target 'SDWebImageWebPCoderTests-macOS' do
|
||||||
pod 'Expecta'
|
pod 'Expecta'
|
||||||
pod 'SDWebImageWebPCoder', :path => './'
|
pod 'SDWebImageWebPCoder', :path => './'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# Inject macro during SDWebImage Demo and Tests
|
||||||
|
post_install do |installer_representation|
|
||||||
|
installer_representation.generated_projects.each do |project|
|
||||||
|
project.targets.each do |target|
|
||||||
|
if target.product_name == 'SDWebImageWebPCoder'
|
||||||
|
target.build_configurations.each do |config|
|
||||||
|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) SD_CHECK_CGIMAGE_RETAIN_SOURCE=1'
|
||||||
|
end
|
||||||
|
else
|
||||||
|
target.build_configurations.each do |config|
|
||||||
|
# Override the min deployment target for some test specs to workaround `libarclite.a` missing issue
|
||||||
|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
|
||||||
|
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.11'
|
||||||
|
config.build_settings['TVOS_DEPLOYMENT_TARGET'] = '9.0'
|
||||||
|
config.build_settings['WATCHOS_DEPLOYMENT_TARGET'] = '2.0'
|
||||||
|
config.build_settings['XROS_DEPLOYMENT_TARGET'] = '1.0'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -233,6 +233,21 @@ const int64_t kAsyncTestTimeout = 5;
|
||||||
XCTAssert(data);
|
XCTAssert(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)test22ThatForceDecodePolicyAlways {
|
||||||
|
XCTestExpectation *expectation = [self expectationWithDescription:@"Always policy with WebP image (libwebp) should force-decode"];
|
||||||
|
NSURL *url = [NSURL URLWithString:@"https://www.gstatic.com/webp/gallery/4.webp"];
|
||||||
|
[SDWebImageManager.sharedManager loadImageWithURL:url options:SDWebImageFromLoaderOnly context:@{SDWebImageContextImageCoder : SDImageWebPCoder.sharedCoder, SDWebImageContextImageForceDecodePolicy : @(SDImageForceDecodePolicyAlways)} progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||||
|
expect(image).notTo.beNil();
|
||||||
|
expect(image.sd_isDecoded).beTruthy();
|
||||||
|
CGImageRef cgImage = image.CGImage;
|
||||||
|
CGColorSpaceRef colorspace = CGImageGetColorSpace(cgImage);
|
||||||
|
expect(colorspace).equal([SDImageCoderHelper colorSpaceGetDeviceRGB]);
|
||||||
|
|
||||||
|
[expectation fulfill];
|
||||||
|
}];
|
||||||
|
[self waitForExpectationsWithTimeout:5 handler:nil];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)testWebPDecodeDoesNotTriggerCACopyImage {
|
- (void)testWebPDecodeDoesNotTriggerCACopyImage {
|
||||||
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestColorspaceStatic" withExtension:@"webp"];
|
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestColorspaceStatic" withExtension:@"webp"];
|
||||||
NSData *data = [NSData dataWithContentsOfURL:staticWebPURL];
|
NSData *data = [NSData dataWithContentsOfURL:staticWebPURL];
|
||||||
|
@ -241,11 +256,15 @@ const int64_t kAsyncTestTimeout = 5;
|
||||||
size_t bytesPerRow = CGImageGetBytesPerRow(cgImage);
|
size_t bytesPerRow = CGImageGetBytesPerRow(cgImage);
|
||||||
XCTAssertEqual(bytesPerRow, 4096);
|
XCTAssertEqual(bytesPerRow, 4096);
|
||||||
CGColorSpaceRef colorspace = CGImageGetColorSpace(cgImage);
|
CGColorSpaceRef colorspace = CGImageGetColorSpace(cgImage);
|
||||||
|
if (@available(iOS 10.0, macOS 10.6, *)) {
|
||||||
NSString *colorspaceName = (__bridge_transfer NSString *)CGColorSpaceCopyName(colorspace);
|
NSString *colorspaceName = (__bridge_transfer NSString *)CGColorSpaceCopyName(colorspace);
|
||||||
#if SD_MAC
|
#if SD_MAC
|
||||||
XCTAssertEqual(colorspace, NSScreen.mainScreen.colorSpace.CGColorSpace, @"Color space is not screen");
|
XCTAssertEqual(colorspace, NSScreen.mainScreen.colorSpace.CGColorSpace, @"Color space is not screen");
|
||||||
#else
|
#else
|
||||||
XCTAssertEqual(colorspaceName, (__bridge NSString *)kCGColorSpaceSRGB, @"Color space is not sRGB");
|
XCTAssertEqual(colorspaceName, (__bridge NSString *)kCGColorSpaceSRGB, @"Color space is not sRGB");
|
||||||
|
} else {
|
||||||
|
// Fallback on earlier versions
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue