From bfc827c804b12ecb94eb48e355d8be7c3d996973 Mon Sep 17 00:00:00 2001 From: liulichao <1771617585@qq.com> Date: Sat, 9 May 2020 12:21:10 +0800 Subject: [PATCH] FIX Fixed AutoPlayAnimatedImage test case --- SDWebImage/Core/SDAnimatedImageView.m | 13 ++++++++++++- Tests/Tests/SDAnimatedImageTest.m | 23 +++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/SDWebImage/Core/SDAnimatedImageView.m b/SDWebImage/Core/SDAnimatedImageView.m index 5e01d997..46d98d2b 100644 --- a/SDWebImage/Core/SDAnimatedImageView.m +++ b/SDWebImage/Core/SDAnimatedImageView.m @@ -183,8 +183,11 @@ // Ensure disabled highlighting; it's not supported (see `-setHighlighted:`). super.highlighted = NO; - + #if SD_UIKIT [self stopAnimating]; + #else + [self setAnimates:NO]; + #endif [self checkPlay]; [self.imageViewLayer setNeedsDisplay]; @@ -389,11 +392,19 @@ { if (self.autoPlayAnimatedImage) { [self updateShouldAnimate]; + #if SD_UIKIT if (self.shouldAnimate) { [self startAnimating]; } else { [self stopAnimating]; } + #else + if (self.shouldAnimate) { + [self setAnimates:YES]; + } else { + [self setAnimates:NO]; + } + #endif } } diff --git a/Tests/Tests/SDAnimatedImageTest.m b/Tests/Tests/SDAnimatedImageTest.m index 9bf26411..16948261 100644 --- a/Tests/Tests/SDAnimatedImageTest.m +++ b/Tests/Tests/SDAnimatedImageTest.m @@ -483,28 +483,39 @@ static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop coun SDAnimatedImage *image = [SDAnimatedImage imageWithData:[self testAPNGPData]]; 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(), ^{ - expect(imageView.animating).equal(0); + #if SD_UIKIT + expect(imageView.animating).equal(0); + #else + expect(imageView.animates).equal(0); + #endif #if SD_UIKIT [imageView startAnimating]; #else imageView.animates = YES; #endif - - expect(imageView.animating).equal(1); }); 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 [imageView stopAnimating]; #else imageView.animates = NO; #endif + [imageView removeFromSuperview]; [expectation fulfill]; });