Merge pull request #3283 from kinarobin/fix-test-error-for-macos

Fix test error
This commit is contained in:
Kinarobin 2021-10-08 10:51:44 +08:00 committed by GitHub
commit 900d15a5f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 4 deletions

View File

@ -14,6 +14,7 @@ def all_test_pods
pod 'SDWebImage/MapKit', :path => './' pod 'SDWebImage/MapKit', :path => './'
pod 'Expecta' pod 'Expecta'
pod 'KVOController' pod 'KVOController'
pod 'SDWebImageWebPCoder', :git => 'https://github.com/SDWebImage/SDWebImageWebPCoder.git', :branch => 'master'
end end
example_project_path = 'Examples/SDWebImage Demo' example_project_path = 'Examples/SDWebImage Demo'

View File

@ -105,6 +105,8 @@
43828A451DA67F9900000E62 /* TestImageLarge.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 43828A441DA67F9900000E62 /* TestImageLarge.jpg */; }; 43828A451DA67F9900000E62 /* TestImageLarge.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 43828A441DA67F9900000E62 /* TestImageLarge.jpg */; };
5F7F38AD1AE2A77A00B0E330 /* TestImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 5F7F38AC1AE2A77A00B0E330 /* TestImage.jpg */; }; 5F7F38AD1AE2A77A00B0E330 /* TestImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 5F7F38AC1AE2A77A00B0E330 /* TestImage.jpg */; };
6B181A1B265757ED00BD06B3 /* TestAnimatedImageMemory.webp in Resources */ = {isa = PBXBuildFile; fileRef = 6B181A1A265757ED00BD06B3 /* TestAnimatedImageMemory.webp */; }; 6B181A1B265757ED00BD06B3 /* TestAnimatedImageMemory.webp in Resources */ = {isa = PBXBuildFile; fileRef = 6B181A1A265757ED00BD06B3 /* TestAnimatedImageMemory.webp */; };
6BC1C20F270F0193003FFAB1 /* TestAnimatedImageMemory.webp in Resources */ = {isa = PBXBuildFile; fileRef = 6B181A1A265757ED00BD06B3 /* TestAnimatedImageMemory.webp */; };
6BC1C210270F073A003FFAB1 /* TestAnimatedImageMemory.webp in Resources */ = {isa = PBXBuildFile; fileRef = 6B181A1A265757ED00BD06B3 /* TestAnimatedImageMemory.webp */; };
770D3B9C7914D53EBA0524DB /* Pods_Tests_TV.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B73996BC299E8E0174661628 /* Pods_Tests_TV.framework */; }; 770D3B9C7914D53EBA0524DB /* Pods_Tests_TV.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B73996BC299E8E0174661628 /* Pods_Tests_TV.framework */; };
AFDBD4044E95252B70FB85CE /* Pods_Tests_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD1BD830DA7388EB6C110B3B /* Pods_Tests_iOS.framework */; }; AFDBD4044E95252B70FB85CE /* Pods_Tests_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD1BD830DA7388EB6C110B3B /* Pods_Tests_iOS.framework */; };
DA248D57195472AA00390AB0 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA248D56195472AA00390AB0 /* XCTest.framework */; }; DA248D57195472AA00390AB0 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA248D56195472AA00390AB0 /* XCTest.framework */; };
@ -467,6 +469,7 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
6BC1C210270F073A003FFAB1 /* TestAnimatedImageMemory.webp in Resources */,
3299228D2365DC6C00EAFD97 /* TestImageAnimated.apng in Resources */, 3299228D2365DC6C00EAFD97 /* TestImageAnimated.apng in Resources */,
3299228B2365DC6C00EAFD97 /* TestImage.heic in Resources */, 3299228B2365DC6C00EAFD97 /* TestImage.heic in Resources */,
329922872365DC6C00EAFD97 /* TestLoopCount.gif in Resources */, 329922872365DC6C00EAFD97 /* TestLoopCount.gif in Resources */,
@ -490,6 +493,7 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
6BC1C20F270F0193003FFAB1 /* TestAnimatedImageMemory.webp in Resources */,
327054E3206CEFF3006EA328 /* TestImageAnimated.apng in Resources */, 327054E3206CEFF3006EA328 /* TestImageAnimated.apng in Resources */,
32B99EA3203B31360017FD66 /* TestImage.gif in Resources */, 32B99EA3203B31360017FD66 /* TestImage.gif in Resources */,
324047452271956F007C53E1 /* TestEXIF.png in Resources */, 324047452271956F007C53E1 /* TestEXIF.png in Resources */,
@ -562,12 +566,16 @@
inputPaths = ( inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Tests TV/Pods-Tests TV-frameworks.sh", "${PODS_ROOT}/Target Support Files/Pods-Tests TV/Pods-Tests TV-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/SDWebImage-Core-MapKit-tvOS/SDWebImage.framework", "${BUILT_PRODUCTS_DIR}/SDWebImage-Core-MapKit-tvOS/SDWebImage.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder-tvOS/SDWebImageWebPCoder.framework",
"${BUILT_PRODUCTS_DIR}/libwebp-tvOS/libwebp.framework",
"${BUILT_PRODUCTS_DIR}/Expecta-tvOS/Expecta.framework", "${BUILT_PRODUCTS_DIR}/Expecta-tvOS/Expecta.framework",
"${BUILT_PRODUCTS_DIR}/KVOController-tvOS/KVOController.framework", "${BUILT_PRODUCTS_DIR}/KVOController-tvOS/KVOController.framework",
); );
name = "[CP] Embed Pods Frameworks"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KVOController.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KVOController.framework",
); );
@ -602,12 +610,16 @@
inputPaths = ( inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Tests Mac/Pods-Tests Mac-frameworks.sh", "${PODS_ROOT}/Target Support Files/Pods-Tests Mac/Pods-Tests Mac-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/SDWebImage-Core-MapKit-macOS/SDWebImage.framework", "${BUILT_PRODUCTS_DIR}/SDWebImage-Core-MapKit-macOS/SDWebImage.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder-macOS/SDWebImageWebPCoder.framework",
"${BUILT_PRODUCTS_DIR}/libwebp-macOS/libwebp.framework",
"${BUILT_PRODUCTS_DIR}/Expecta-macOS/Expecta.framework", "${BUILT_PRODUCTS_DIR}/Expecta-macOS/Expecta.framework",
"${BUILT_PRODUCTS_DIR}/KVOController-macOS/KVOController.framework", "${BUILT_PRODUCTS_DIR}/KVOController-macOS/KVOController.framework",
); );
name = "[CP] Embed Pods Frameworks"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KVOController.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KVOController.framework",
); );
@ -624,12 +636,16 @@
inputPaths = ( inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Tests iOS/Pods-Tests iOS-frameworks.sh", "${PODS_ROOT}/Target Support Files/Pods-Tests iOS/Pods-Tests iOS-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/SDWebImage-Core-MapKit-iOS/SDWebImage.framework", "${BUILT_PRODUCTS_DIR}/SDWebImage-Core-MapKit-iOS/SDWebImage.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder-iOS/SDWebImageWebPCoder.framework",
"${BUILT_PRODUCTS_DIR}/libwebp-iOS/libwebp.framework",
"${BUILT_PRODUCTS_DIR}/Expecta-iOS/Expecta.framework", "${BUILT_PRODUCTS_DIR}/Expecta-iOS/Expecta.framework",
"${BUILT_PRODUCTS_DIR}/KVOController-iOS/KVOController.framework", "${BUILT_PRODUCTS_DIR}/KVOController-iOS/KVOController.framework",
); );
name = "[CP] Embed Pods Frameworks"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KVOController.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KVOController.framework",
); );

View File

@ -10,6 +10,7 @@
#import "SDTestCase.h" #import "SDTestCase.h"
#import "SDInternalMacros.h" #import "SDInternalMacros.h"
#import <KVOController/KVOController.h> #import <KVOController/KVOController.h>
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop count static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop count
@ -347,7 +348,7 @@ static BOOL _isCalled;
expect(cacheType).equal(SDImageCacheTypeNone); expect(cacheType).equal(SDImageCacheTypeNone);
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithCommonTimeout]; [self waitForExpectationsWithTimeout:kAsyncTestTimeout * 2 handler:nil];
} }
- (void)test24AnimatedImageViewCategoryDiskCache { - (void)test24AnimatedImageViewCategoryDiskCache {
@ -767,7 +768,12 @@ static BOOL _isCalled;
- (void)test36AnimatedImageMemoryCost { - (void)test36AnimatedImageMemoryCost {
if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) { if (@available(iOS 14, tvOS 14, macOS 11, watchOS 7, *)) {
#if SD_TV
/// TV OS does not support ImageIO's webp.
[[SDImageCodersManager sharedManager] addCoder:[SDImageWebPCoder sharedCoder]];
#else
[[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]]; [[SDImageCodersManager sharedManager] addCoder:[SDImageAWebPCoder sharedCoder]];
#endif
UIImage *image = [UIImage sd_imageWithData:[NSData dataWithContentsOfFile:[self testMemotyCostImagePath]]]; UIImage *image = [UIImage sd_imageWithData:[NSData dataWithContentsOfFile:[self testMemotyCostImagePath]]];
NSUInteger cost = [image sd_memoryCost]; NSUInteger cost = [image sd_memoryCost];
#if SD_UIKIT #if SD_UIKIT
@ -775,7 +781,12 @@ static BOOL _isCalled;
#endif #endif
expect(image.sd_imageFrameCount).equal(16); expect(image.sd_imageFrameCount).equal(16);
expect(image.scale).equal(1); expect(image.scale).equal(1);
#if SD_MAC
/// Frame count is 1 in mac.
expect(cost).equal(image.size.width * image.size.height * 4);
#else
expect(cost).equal(16 * image.size.width * image.size.height * 4); expect(cost).equal(16 * image.size.width * image.size.height * 4);
#endif
[[SDImageCodersManager sharedManager] removeCoder:[SDImageAWebPCoder sharedCoder]]; [[SDImageCodersManager sharedManager] removeCoder:[SDImageAWebPCoder sharedCoder]];
} }
} }

View File

@ -9,6 +9,7 @@
#import "SDTestCase.h" #import "SDTestCase.h"
#import "UIColor+SDHexString.h" #import "UIColor+SDHexString.h"
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
@interface SDWebImageDecoderTests : SDTestCase @interface SDWebImageDecoderTests : SDTestCase
@ -246,7 +247,12 @@
- (void)test18ThatStaticWebPWorks { - (void)test18ThatStaticWebPWorks {
if (@available(iOS 14, tvOS 14, macOS 11, *)) { if (@available(iOS 14, tvOS 14, macOS 11, *)) {
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageStatic" withExtension:@"webp"]; NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageStatic" withExtension:@"webp"];
#if SD_TV
/// TV OS does not support ImageIO's webp.
[self verifyCoder:[SDImageWebPCoder sharedCoder]
#else
[self verifyCoder:[SDImageAWebPCoder sharedCoder] [self verifyCoder:[SDImageAWebPCoder sharedCoder]
#endif
withLocalImageURL:staticWebPURL withLocalImageURL:staticWebPURL
supportsEncoding:NO // Currently (iOS 14.0) seems no encoding support supportsEncoding:NO // Currently (iOS 14.0) seems no encoding support
encodingFormat:SDImageFormatWebP encodingFormat:SDImageFormatWebP
@ -258,7 +264,12 @@
- (void)test19ThatAnimatedWebPWorks { - (void)test19ThatAnimatedWebPWorks {
if (@available(iOS 14, tvOS 14, macOS 11, *)) { if (@available(iOS 14, tvOS 14, macOS 11, *)) {
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"webp"]; NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"webp"];
#if SD_TV
/// TV OS does not support ImageIO's webp.
[self verifyCoder:[SDImageWebPCoder sharedCoder]
#else
[self verifyCoder:[SDImageAWebPCoder sharedCoder] [self verifyCoder:[SDImageAWebPCoder sharedCoder]
#endif
withLocalImageURL:staticWebPURL withLocalImageURL:staticWebPURL
supportsEncoding:NO // Currently (iOS 14.0) seems no encoding support supportsEncoding:NO // Currently (iOS 14.0) seems no encoding support
encodingFormat:SDImageFormatWebP encodingFormat:SDImageFormatWebP

View File

@ -757,7 +757,7 @@
token2 = [downloader2 downloadImageWithURL:[NSURL URLWithString:kTestJPEGURL] completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) { token2 = [downloader2 downloadImageWithURL:[NSURL URLWithString:kTestJPEGURL] completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
expect(error).notTo.beNil(); expect(error).notTo.beNil();
expect(error.code).equal(SDWebImageErrorInvalidDownloadContentType); expect(error.code).equal(SDWebImageErrorInvalidDownloadContentType);
NSString *contentType = ((NSHTTPURLResponse *)token1.response).MIMEType; NSString *contentType = ((NSHTTPURLResponse *)token2.response).MIMEType;
expect(contentType).equal(@"image/jpeg"); expect(contentType).equal(@"image/jpeg");
[expectation2 fulfill]; [expectation2 fulfill];
}]; }];

View File

@ -40,7 +40,7 @@
}]; }];
expect([[SDWebImageManager sharedManager] isRunning]).to.equal(YES); expect([[SDWebImageManager sharedManager] isRunning]).to.equal(YES);
[self waitForExpectationsWithCommonTimeout]; [self waitForExpectationsWithTimeout:kAsyncTestTimeout * 2 handler:nil];
} }
- (void)test03ThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync { - (void)test03ThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync {
@ -82,7 +82,7 @@
[expectation fulfill]; [expectation fulfill];
}); });
[self waitForExpectationsWithCommonTimeout]; [self waitForExpectationsWithTimeout:kAsyncTestTimeout * 2 handler:nil];
} }
- (void)test07ThatLoadImageWithSDWebImageRefreshCachedWorks { - (void)test07ThatLoadImageWithSDWebImageRefreshCachedWorks {