FIX Fixed AutoPlayAnimatedImage test case

This commit is contained in:
liulichao 2020-05-09 12:21:10 +08:00
parent 20d2369304
commit bfc827c804
2 changed files with 29 additions and 7 deletions

View File

@ -183,8 +183,11 @@
// Ensure disabled highlighting; it's not supported (see `-setHighlighted:`). // Ensure disabled highlighting; it's not supported (see `-setHighlighted:`).
super.highlighted = NO; super.highlighted = NO;
#if SD_UIKIT
[self stopAnimating]; [self stopAnimating];
#else
[self setAnimates:NO];
#endif
[self checkPlay]; [self checkPlay];
[self.imageViewLayer setNeedsDisplay]; [self.imageViewLayer setNeedsDisplay];
@ -389,11 +392,19 @@
{ {
if (self.autoPlayAnimatedImage) { if (self.autoPlayAnimatedImage) {
[self updateShouldAnimate]; [self updateShouldAnimate];
#if SD_UIKIT
if (self.shouldAnimate) { if (self.shouldAnimate) {
[self startAnimating]; [self startAnimating];
} else { } else {
[self stopAnimating]; [self stopAnimating];
} }
#else
if (self.shouldAnimate) {
[self setAnimates:YES];
} else {
[self setAnimates:NO];
}
#endif
} }
} }

View File

@ -483,28 +483,39 @@ static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop coun
SDAnimatedImage *image = [SDAnimatedImage imageWithData:[self testAPNGPData]]; SDAnimatedImage *image = [SDAnimatedImage imageWithData:[self testAPNGPData]];
imageView.image = image; imageView.image = image;
expect(imageView.animating).equal(0); #if SD_UIKIT
expect(imageView.animating).equal(0);
#else
expect(imageView.animates).equal(0);
#endif
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(imageView.animating).equal(0); #if SD_UIKIT
expect(imageView.animating).equal(0);
#else
expect(imageView.animates).equal(0);
#endif
#if SD_UIKIT #if SD_UIKIT
[imageView startAnimating]; [imageView startAnimating];
#else #else
imageView.animates = YES; imageView.animates = YES;
#endif #endif
expect(imageView.animating).equal(1);
}); });
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(imageView.animating).equal(1); #if SD_UIKIT
expect(imageView.animating).equal(1);
#else
expect(imageView.animates).equal(1);
#endif
#if SD_UIKIT #if SD_UIKIT
[imageView stopAnimating]; [imageView stopAnimating];
#else #else
imageView.animates = NO; imageView.animates = NO;
#endif #endif
[imageView removeFromSuperview]; [imageView removeFromSuperview];
[expectation fulfill]; [expectation fulfill];
}); });