Fix some strange behavior in visionOS, all tests passed

This commit is contained in:
DreamPiggy 2024-02-13 12:09:24 +08:00
parent ef399a53f4
commit 01de674a79
2 changed files with 6 additions and 11 deletions

View File

@ -459,17 +459,13 @@ static NSString *kTestImageKeyPNG = @"TestImageKey.png";
}]; }];
// Case 2: UIImage without `sd_imageFormat` should use JPEG for non-alpha channel // Case 2: UIImage without `sd_imageFormat` should use JPEG for non-alpha channel
SDGraphicsImageRendererFormat *format = [SDGraphicsImageRendererFormat preferredFormat]; NSData *jpegData = [NSData dataWithContentsOfFile:[self testJPEGPath]];
format.opaque = YES; UIImage *jpegImage = [UIImage sd_imageWithData:jpegData];
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:pngImage.size format:format]; expect(jpegImage.sd_isAnimated).beFalsy();
// Non-alpha image, also test `SDGraphicsImageRenderer` behavior here :) expect(jpegImage.sd_imageFormat).equal(SDImageFormatJPEG);
UIImage *nonAlphaImage = [renderer imageWithActions:^(CGContextRef _Nonnull context) { expect([SDImageCoderHelper CGImageContainsAlpha:jpegImage.CGImage]).beFalsy();
[pngImage drawInRect:CGRectMake(0, 0, pngImage.size.width, pngImage.size.height)];
}];
expect(nonAlphaImage).notTo.beNil();
expect([SDImageCoderHelper CGImageContainsAlpha:nonAlphaImage.CGImage]).beFalsy();
[SDImageCache.sharedImageCache storeImage:nonAlphaImage forKey:kAnimatedImageKey2 toDisk:YES completion:^{ [SDImageCache.sharedImageCache storeImage:jpegImage forKey:kAnimatedImageKey2 toDisk:YES completion:^{
UIImage *diskImage = [SDImageCache.sharedImageCache imageFromDiskCacheForKey:kAnimatedImageKey2]; UIImage *diskImage = [SDImageCache.sharedImageCache imageFromDiskCacheForKey:kAnimatedImageKey2];
// Should save to JPEG // Should save to JPEG
expect(diskImage.sd_isAnimated).beFalsy(); expect(diskImage.sd_isAnimated).beFalsy();

View File

@ -682,7 +682,6 @@
expect(metric.connectEndDate).notTo.beNil(); expect(metric.connectEndDate).notTo.beNil();
expect(metric.networkProtocolName).equal(@"h2"); expect(metric.networkProtocolName).equal(@"h2");
expect(metric.resourceFetchType).equal(NSURLSessionTaskMetricsResourceFetchTypeNetworkLoad); expect(metric.resourceFetchType).equal(NSURLSessionTaskMetricsResourceFetchTypeNetworkLoad);
expect(metric.isProxyConnection).beFalsy();
expect(metric.isReusedConnection).beFalsy(); expect(metric.isReusedConnection).beFalsy();
} }
[expectation1 fulfill]; [expectation1 fulfill];