fix test error in tvos

This commit is contained in:
kinarobin 2021-10-07 19:15:19 +08:00
parent 3d108c86a1
commit 22c9a4e549
5 changed files with 34 additions and 2 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

@ -106,6 +106,7 @@
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 */; }; 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 */; };
@ -468,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 */,
@ -564,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",
); );
@ -604,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",
); );
@ -626,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
@ -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

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

@ -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 {