Authored by DreamPiggy

Add test for animated WebP image array

The image array used for +[UIImage animatedImageWithImages:] should share the same size.
@@ -22,12 +22,41 @@ @@ -22,12 +22,41 @@
22 22
23 @implementation UIImageMultiFormatTests 23 @implementation UIImageMultiFormatTests
24 24
25 -- (void)testImageOrientationFromImageDataWithInvalidData { 25 +- (void)test01ImageOrientationFromImageDataWithInvalidData {
26 // sync download image 26 // sync download image
  27 +#pragma clang diagnostic push
  28 +#pragma clang diagnostic ignored "-Wundeclared-selector"
27 SEL selector = @selector(sd_imageOrientationFromImageData:); 29 SEL selector = @selector(sd_imageOrientationFromImageData:);
  30 +#pragma clang diagnostic pop
28 31
29 - UIImageOrientation orientation = [[UIImage class] performSelector:selector withObject:nil]; 32 +#pragma clang diagnostic push
  33 +#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
  34 + UIImageOrientation orientation = (UIImageOrientation)[[UIImage class] performSelector:selector withObject:nil];
  35 +#pragma clang diagnostic pop
30 expect(orientation).to.equal(UIImageOrientationUp); 36 expect(orientation).to.equal(UIImageOrientationUp);
31 } 37 }
32 38
  39 +- (void)test02AnimatedWebPImageArrayWithEqualSizeAndScale {
  40 + NSURL *webpURL = [NSURL URLWithString:@"https://isparta.github.io/compare-webp/image/gif_webp/webp/2.webp"];
  41 + NSData *data = [NSData dataWithContentsOfURL:webpURL];
  42 +#pragma clang diagnostic push
  43 +#pragma clang diagnostic ignored "-Wundeclared-selector"
  44 + SEL selector = @selector(sd_imageWithWebPData:);
  45 +#pragma clang diagnostic pop
  46 +
  47 +#pragma clang diagnostic push
  48 +#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
  49 + UIImage *animatedImage = [[UIImage class] performSelector:selector withObject:data];
  50 +#pragma clang diagnostic pop
  51 + CGSize imageSize = animatedImage.size;
  52 + CGFloat imageScale = animatedImage.scale;
  53 + [animatedImage.images enumerateObjectsUsingBlock:^(UIImage * _Nonnull image, NSUInteger idx, BOOL * _Nonnull stop) {
  54 + CGSize size = image.size;
  55 + CGFloat scale = image.scale;
  56 + expect(imageSize.width).to.equal(size.width);
  57 + expect(imageSize.height).to.equal(size.height);
  58 + expect(imageScale).to.equal(scale);
  59 + }];
  60 +}
  61 +
33 @end 62 @end