update image assert for testing
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
5ed2263fc5
commit
2e5ebb392b
@ -1,3 +1,3 @@
|
|||||||
#maven.buildNumber.plugin properties file
|
#maven.buildNumber.plugin properties file
|
||||||
#Mon Aug 19 13:16:30 EDT 2024
|
#Tue Aug 20 15:00:55 EDT 2024
|
||||||
buildNumber=280
|
buildNumber=281
|
||||||
|
|||||||
@ -16,6 +16,11 @@ import electrosphere.renderer.RenderingEngine;
|
|||||||
*/
|
*/
|
||||||
public class TestRenderingUtils {
|
public class TestRenderingUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The threshold at which we say the colors are 'close enough'
|
||||||
|
*/
|
||||||
|
static final int COLOR_COMPARE_THRESHOLD = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the most recent render matches the image stored at the provided filepath
|
* Asserts that the most recent render matches the image stored at the provided filepath
|
||||||
* @param existingRenderPath The filepath of the existing render
|
* @param existingRenderPath The filepath of the existing render
|
||||||
@ -41,10 +46,28 @@ public class TestRenderingUtils {
|
|||||||
//pixel-by-pixel check
|
//pixel-by-pixel check
|
||||||
for(int x = 0; x < testData.getWidth(); x++){
|
for(int x = 0; x < testData.getWidth(); x++){
|
||||||
for(int y = 0; y < testData.getHeight(); y++){
|
for(int y = 0; y < testData.getHeight(); y++){
|
||||||
if(testData.getRGB(x, y) != screenshot.getRGB(x, y)){
|
|
||||||
|
//get from-disk rgba
|
||||||
|
int sourceRed = testData.getRGB(x, y) & 0xff;
|
||||||
|
int sourceGreen = (testData.getRGB(x, y) & 0xff00) >> 8;
|
||||||
|
int sourceBlue = (testData.getRGB(x, y) & 0xff0000) >> 16;
|
||||||
|
int sourceAlpha = (testData.getRGB(x, y) & 0xff000000) >>> 24;
|
||||||
|
|
||||||
|
//get from-render rgba
|
||||||
|
int renderRed = screenshot.getRGB(x, y) & 0xff;
|
||||||
|
int renderGreen = (screenshot.getRGB(x, y) & 0xff00) >> 8;
|
||||||
|
int renderBlue = (screenshot.getRGB(x, y) & 0xff0000) >> 16;
|
||||||
|
int renderAlpha = (screenshot.getRGB(x, y) & 0xff000000) >>> 24;
|
||||||
|
|
||||||
|
if(
|
||||||
|
Math.abs(sourceRed - renderRed) > COLOR_COMPARE_THRESHOLD ||
|
||||||
|
Math.abs(sourceGreen - renderGreen) > COLOR_COMPARE_THRESHOLD ||
|
||||||
|
Math.abs(sourceBlue - renderBlue) > COLOR_COMPARE_THRESHOLD ||
|
||||||
|
Math.abs(sourceAlpha - renderAlpha) > COLOR_COMPARE_THRESHOLD
|
||||||
|
){
|
||||||
onFailure.run();
|
onFailure.run();
|
||||||
|
fail("Colors aren't approximately the same!");
|
||||||
}
|
}
|
||||||
assertEquals(testData.getRGB(x, y),screenshot.getRGB(x, y));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user