Fix get button background image operation key bug
This commit is contained in:
parent
124509e9b6
commit
2396c2e7c0
|
@ -189,7 +189,7 @@ static inline NSString * backgroundImageOperationKeyForState(UIControlState stat
|
|||
} else {
|
||||
mutableContext = [NSMutableDictionary dictionary];
|
||||
}
|
||||
mutableContext[SDWebImageContextSetImageOperationKey] = imageOperationKeyForState(state);
|
||||
mutableContext[SDWebImageContextSetImageOperationKey] = backgroundImageOperationKeyForState(state);
|
||||
@weakify(self);
|
||||
[self sd_internalSetImageWithURL:url
|
||||
placeholderImage:placeholder
|
||||
|
|
|
@ -171,10 +171,9 @@
|
|||
SDImageTintTransformer *transformer6 = [SDImageTintTransformer transformerWithColor:tintColor];
|
||||
SDImageBlurTransformer *transformer7 = [SDImageBlurTransformer transformerWithRadius:blurRadius];
|
||||
|
||||
#if SD_UIKIT || SD_MAC
|
||||
CIFilter *filter = [CIFilter filterWithName:@"CIColorInvert"];
|
||||
SDImageFilterTransformer *transformer8 = [SDImageFilterTransformer transformerWithFilter:filter];
|
||||
#endif
|
||||
|
||||
// Chain all built-in transformers for test case
|
||||
SDImagePipelineTransformer *pipelineTransformer = [SDImagePipelineTransformer transformerWithTransformers:@[
|
||||
transformer1,
|
||||
|
@ -184,9 +183,7 @@
|
|||
transformer5,
|
||||
transformer6,
|
||||
transformer7,
|
||||
#if SD_UIKIT || SD_MAC
|
||||
transformer8,
|
||||
#endif
|
||||
transformer8
|
||||
]];
|
||||
NSArray *transformerKeys = @[
|
||||
@"SDImageResizingTransformer({100.000000,100.000000},2)",
|
||||
|
@ -196,9 +193,7 @@
|
|||
@"SDImageCroppingTransformer({0.000000,0.000000,50.000000,50.000000})",
|
||||
@"SDImageTintTransformer(#00000000)",
|
||||
@"SDImageBlurTransformer(5.000000)",
|
||||
#if SD_UIKIT || SD_MAC
|
||||
@"SDImageFilterTransformer(CIColorInvert)",
|
||||
#endif
|
||||
@"SDImageFilterTransformer(CIColorInvert)"
|
||||
];
|
||||
NSString *transformerKey = [transformerKeys componentsJoinedByString:@"-"]; // SDImageTransformerKeySeparator
|
||||
expect([pipelineTransformer.transformerKey isEqualToString:transformerKey]).beTruthy();
|
||||
|
|
|
@ -120,6 +120,16 @@
|
|||
}];
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testUIButtonBackgroundImageCancelCurrentImageLoad {
|
||||
UIButton *button = [[UIButton alloc] init];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:kTestJPEGURL];
|
||||
[button sd_setBackgroundImageWithURL:originalImageURL forState:UIControlStateNormal];
|
||||
[button sd_cancelBackgroundImageLoadForState:UIControlStateNormal];
|
||||
NSString *backgroundImageOperationKey = [self testBackgroundImageOperationKeyForState:UIControlStateNormal];
|
||||
expect([button sd_imageLoadOperationForKey:backgroundImageOperationKey]).beNil();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if SD_MAC
|
||||
|
@ -339,4 +349,8 @@
|
|||
return [testBundle pathForResource:@"TestImage" ofType:@"jpg"];
|
||||
}
|
||||
|
||||
- (NSString *)testBackgroundImageOperationKeyForState:(UIControlState)state {
|
||||
return [NSString stringWithFormat:@"UIButtonBackgroundImageOperation%lu", (unsigned long)state];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue