Skip to content

Fix to modelphotoshoot test #1570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions test/integration/ModelPhotoShootTest.hh
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,21 @@ void testImages(const std::string &_imageFile,
EXPECT_EQ(image.Width(), testImage.Width());
EXPECT_EQ(image.Height(), testImage.Height());
EXPECT_EQ(image.PixelFormat(), testImage.PixelFormat());
unsigned int dataLength;
unsigned char *imageData = nullptr;
image.Data(&imageData, dataLength);
unsigned int testDataLenght;
unsigned char *testImageData = nullptr;
image.Data(&testImageData, testDataLenght);
ASSERT_EQ(dataLength, testDataLenght);
ASSERT_EQ(memcmp(imageData, testImageData, dataLength), 0);
// Images should be almost equal (They might have
// minimal color differences on a few pixels)
unsigned int equal_pixels = 0;
unsigned int total_pixels = testImage.Width() * testImage.Height();
for (unsigned int x = 0; x < image.Width(); x++)
{
for (unsigned int y = 0; y < image.Height(); y++)
{
if (image.Pixel(x, y) == testImage.Pixel(x, y))
{
equal_pixels++;
}
}
}
ASSERT_GT((float)equal_pixels/(float)total_pixels, 0.99);

// Deleting files so they do not affect future tests
EXPECT_EQ(remove(imageFilePath.c_str()), 0);
Expand Down