animated image seek frame test added

This commit is contained in:
Philip Dukhov 2020-06-11 12:35:36 +07:00
parent 7435113072
commit 30053c2ac3
1 changed files with 33 additions and 0 deletions

View File

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