From c99b60eed08835c40b012a1d8ebf44af942c796f Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Fri, 23 Feb 2024 16:43:16 +0800 Subject: [PATCH] Fix the unit test compile issue Fix the webp unit test for visionOS --- Tests/Tests/SDImageCoderTests.m | 4 ++++ Tests/Tests/SDTestCase.m | 4 +++- Tests/Tests/SDWebImageManagerTests.m | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Tests/Tests/SDImageCoderTests.m b/Tests/Tests/SDImageCoderTests.m index c5a5cc5e..cf749b3a 100644 --- a/Tests/Tests/SDImageCoderTests.m +++ b/Tests/Tests/SDImageCoderTests.m @@ -9,8 +9,12 @@ #import "SDTestCase.h" #import "UIColor+SDHexString.h" +#if !SD_VISION #if __has_include() #import +#else +@import SDWebImageWebPCoder; +#endif #endif @interface SDWebImageDecoderTests : SDTestCase diff --git a/Tests/Tests/SDTestCase.m b/Tests/Tests/SDTestCase.m index 64ebd2fb..06a085ec 100644 --- a/Tests/Tests/SDTestCase.m +++ b/Tests/Tests/SDTestCase.m @@ -39,7 +39,9 @@ NSString *const kTestAPNGPURL = @"https://upload.wikimedia.org/wikipedia/commons CGRect screenFrame = mainScreen.bounds; #endif _window = [[UIWindow alloc] initWithFrame:screenFrame]; -#else +#endif // UIKit +#if SD_MAC + UIScreen *mainScreen = [UIScreen mainScreen]; _window = [[NSWindow alloc] initWithContentRect:mainScreen.frame styleMask:0 backing:NSBackingStoreBuffered defer:NO screen:mainScreen]; #endif } diff --git a/Tests/Tests/SDWebImageManagerTests.m b/Tests/Tests/SDWebImageManagerTests.m index 205a4167..5dd48a2a 100644 --- a/Tests/Tests/SDWebImageManagerTests.m +++ b/Tests/Tests/SDWebImageManagerTests.m @@ -10,8 +10,12 @@ #import "SDWebImageTestTransformer.h" #import "SDWebImageTestCache.h" #import "SDWebImageTestLoader.h" +#if !SD_VISION #if __has_include() #import +#else +@import SDWebImageWebPCoder; +#endif #endif // Keep strong references for object @@ -646,7 +650,7 @@ [self waitForExpectationsWithCommonTimeout]; } -#if __has_include() +#if !SD_VISION - (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"];