Skip to content

Commit

Permalink
Add tests of crushed PNGs
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-owenthomas committed Oct 22, 2021
1 parent af8607b commit 8e9c24f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/iOSSnapshotTestCaseTests/FBSnapshotControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,37 @@ - (void)testCompareReferenceImageWithLowPixelToleranceShouldMatch
XCTAssertNil(error);
}

- (void)testCompareReferenceImageToGrayscaleCrushedImageShouldBeEqual
{
UIImage *referenceImage = [self _bundledImageNamed:@"rect" type:@"png"];
XCTAssertNotNil(referenceImage);

// rect_crushed was made by pngcrush version 1.8.13 with default options as shown below. Reduced file size by 67%
// FBSnapshotTestCaseTests$ pngcrush rect.png rect_crushed.png
UIImage *testImage = [self _bundledImageNamed:@"rect_crushed" type:@"png"];
XCTAssertNotNil(testImage);

id testClass = nil;
FBSnapshotTestController *controller = [[FBSnapshotTestController alloc] initWithTestClass:testClass];
NSError *error = nil;
XCTAssertTrue([controller compareReferenceImage:referenceImage toImage:testImage overallTolerance:0 error:&error]);
XCTAssertNil(error);
}

- (void)testCompareGrayscaleCrushedImageToReferenceImageShouldBeEqual
{
UIImage *referenceImage = [self _bundledImageNamed:@"rect_crushed" type:@"png"];
XCTAssertNotNil(referenceImage);
UIImage *testImage = [self _bundledImageNamed:@"rect" type:@"png"];
XCTAssertNotNil(testImage);

id testClass = nil;
FBSnapshotTestController *controller = [[FBSnapshotTestController alloc] initWithTestClass:testClass];
NSError *error = nil;
XCTAssertTrue([controller compareReferenceImage:referenceImage toImage:testImage overallTolerance:0 error:&error]);
XCTAssertNil(error);
}

#pragma mark - Private helper methods

- (UIImage *)_bundledImageNamed:(NSString *)name type:(NSString *)type
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8e9c24f

Please sign in to comment.