Skip to content

Commit b2d6372

Browse files
committed
Fix the unit test on macOS
1 parent 78fe228 commit b2d6372

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

SDWebImage/Core/SDImageCoderHelper.m

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,22 +290,23 @@ + (UIImage *)animatedImageWithFrames:(NSArray<SDImageFrame *> *)frames {
290290
}
291291

292292
+ (CGColorSpaceRef)colorSpaceGetDeviceRGB {
293+
#if SD_MAC
294+
NSScreen *mainScreen = nil;
295+
if (@available(macOS 10.12, *)) {
296+
mainScreen = [NSScreen mainScreen];
297+
} else {
298+
mainScreen = [NSScreen screens].firstObject;
299+
}
300+
CGColorSpaceRef colorSpace = mainScreen.colorSpace.CGColorSpace;
301+
return colorSpace;
302+
#else
293303
static CGColorSpaceRef colorSpace;
294304
static dispatch_once_t onceToken;
295305
dispatch_once(&onceToken, ^{
296-
#if SD_MAC
297-
NSScreen *mainScreen = nil;
298-
if (@available(macOS 10.12, *)) {
299-
mainScreen = [NSScreen mainScreen];
300-
} else {
301-
mainScreen = [NSScreen screens].firstObject;
302-
}
303-
colorSpace = mainScreen.colorSpace.CGColorSpace;
304-
#else
305306
colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
306-
#endif
307307
});
308308
return colorSpace;
309+
#endif
309310
}
310311

311312
+ (SDImagePixelFormat)preferredPixelFormat:(BOOL)containsAlpha {

Tests/Tests/SDImageCoderTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ - (void)test13ThatHEICWorks {
217217
- (void)test14ThatHEIFWorks {
218218
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
219219
NSURL *heifURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heif"];
220-
BOOL supportsEncoding = !SDTestCase.isCI; // GitHub Action Mac env currently does not support HEIC encoding
220+
BOOL supportsEncoding = NO; // public.heif UTI alwsays return false, use public.heic
221221
[self verifyCoder:[SDImageIOCoder sharedCoder]
222222
withLocalImageURL:heifURL
223223
supportsEncoding:supportsEncoding

0 commit comments

Comments
 (0)