Merge pull request #3030 from PhilipDukhov/master
SDAnimatedImagePlayer seek returning nil image fix
This commit is contained in:
commit
121a18568d
|
@ -209,6 +209,7 @@
|
||||||
}
|
}
|
||||||
self.currentFrameIndex = index;
|
self.currentFrameIndex = index;
|
||||||
self.currentLoopCount = loopCount;
|
self.currentLoopCount = loopCount;
|
||||||
|
self.currentFrame = [self.animatedProvider animatedImageFrameAtIndex:index];
|
||||||
[self handleFrameChange];
|
[self handleFrameChange];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -523,6 +523,39 @@ static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop coun
|
||||||
[self waitForExpectationsWithCommonTimeout];
|
[self waitForExpectationsWithCommonTimeout];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)test29AnimatedImageSeekFrame {
|
||||||
|
XCTestExpectation *expectation = [self expectationWithDescription:@"test SDAnimatedImageView stopAnimating normal behavior"];
|
||||||
|
|
||||||
|
SDAnimatedImageView *imageView = [SDAnimatedImageView new];
|
||||||
|
|
||||||
|
#if SD_UIKIT
|
||||||
|
[self.window addSubview:imageView];
|
||||||
|
#else
|
||||||
|
[self.window.contentView addSubview:imageView];
|
||||||
|
#endif
|
||||||
|
// seeking through local image should return non-null images
|
||||||
|
SDAnimatedImage *image = [SDAnimatedImage imageWithData:[self testAPNGPData]];
|
||||||
|
imageView.autoPlayAnimatedImage = NO;
|
||||||
|
imageView.image = image;
|
||||||
|
|
||||||
|
__weak SDAnimatedImagePlayer *player = imageView.player;
|
||||||
|
|
||||||
|
__block NSUInteger i = 0;
|
||||||
|
[player setAnimationFrameHandler:^(NSUInteger index, UIImage * _Nonnull frame) {
|
||||||
|
expect(index).equal(i);
|
||||||
|
expect(frame).notTo.beNil();
|
||||||
|
i++;
|
||||||
|
if (i < player.totalFrameCount) {
|
||||||
|
[player seekToFrameAtIndex:i loopCount:0];
|
||||||
|
} else {
|
||||||
|
[expectation fulfill];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
[player seekToFrameAtIndex:i loopCount:0];
|
||||||
|
|
||||||
|
[self waitForExpectationsWithCommonTimeout];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Helper
|
#pragma mark - Helper
|
||||||
- (UIWindow *)window {
|
- (UIWindow *)window {
|
||||||
if (!_window) {
|
if (!_window) {
|
||||||
|
|
Loading…
Reference in New Issue