mirror of
https://github.com/androidx/media.git
synced 2025-05-08 08:00:49 +08:00
Test: Rename FrameProcessor Pixel Tests.
Rename tests using the action state expectation pattern. PiperOrigin-RevId: 504546583
This commit is contained in:
parent
f083ff264d
commit
5d04d38d35
@ -59,6 +59,9 @@ import org.junit.runner.RunWith;
|
|||||||
/**
|
/**
|
||||||
* Pixel test for frame processing via {@link GlEffectsFrameProcessor}.
|
* Pixel test for frame processing via {@link GlEffectsFrameProcessor}.
|
||||||
*
|
*
|
||||||
|
* <p>Uses a {@link GlEffectsFrameProcessor} to process one frame, and checks that the actual output
|
||||||
|
* matches expected output, either from a golden file or from another edit.
|
||||||
|
*
|
||||||
* <p>Expected images are taken from an emulator, so tests on different emulators or physical
|
* <p>Expected images are taken from an emulator, so tests on different emulators or physical
|
||||||
* devices may fail. To test on other devices, please increase the {@link
|
* devices may fail. To test on other devices, please increase the {@link
|
||||||
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
|
* BitmapPixelTestUtil#MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} and/or inspect the saved output
|
||||||
@ -112,8 +115,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_noEdits_producesExpectedOutput() throws Exception {
|
public void noEffects_matchesGoldenFile() throws Exception {
|
||||||
String testId = "processData_noEdits";
|
String testId = "noEffects_matchesGoldenFile";
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
new GlEffectsFrameProcessorTestRunner.Builder(testId).build();
|
new GlEffectsFrameProcessorTestRunner.Builder(testId).build();
|
||||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
@ -127,8 +130,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_noEditsWithCache_leavesFrameUnchanged() throws Exception {
|
public void noEffects_withFrameCache_matchesGoldenFile() throws Exception {
|
||||||
String testId = "processData_noEditsWithCache";
|
String testId = "noEffects_withFrameCache_matchesGoldenFile";
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
||||||
.setEffects(new FrameCache(/* capacity= */ 5))
|
.setEffects(new FrameCache(/* capacity= */ 5))
|
||||||
@ -144,8 +147,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_withPixelWidthHeightRatio_producesExpectedOutput() throws Exception {
|
public void setPixelWidthHeightRatio_matchesGoldenFile() throws Exception {
|
||||||
String testId = "processData_withPixelWidthHeightRatio";
|
String testId = "setPixelWidthHeightRatio_matchesGoldenFile";
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
new GlEffectsFrameProcessorTestRunner.Builder(testId).setPixelWidthHeightRatio(2f).build();
|
new GlEffectsFrameProcessorTestRunner.Builder(testId).setPixelWidthHeightRatio(2f).build();
|
||||||
Bitmap expectedBitmap = readBitmap(SCALE_WIDE_PNG_ASSET_PATH);
|
Bitmap expectedBitmap = readBitmap(SCALE_WIDE_PNG_ASSET_PATH);
|
||||||
@ -159,9 +162,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_withMatrixTransformation_translateRight_producesExpectedOutput()
|
public void matrixTransformation_matchesGoldenFile() throws Exception {
|
||||||
throws Exception {
|
String testId = "matrixTransformation_matchesGoldenFile";
|
||||||
String testId = "processData_withMatrixTransformation_translateRight";
|
|
||||||
Matrix translateRightMatrix = new Matrix();
|
Matrix translateRightMatrix = new Matrix();
|
||||||
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
|
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
@ -179,9 +181,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_withMatrixAndScaleToFitTransformation_producesExpectedOutput()
|
public void matrixAndScaleToFitTransformation_matchesGoldenFile() throws Exception {
|
||||||
throws Exception {
|
String testId = "matrixAndScaleToFitTransformation_matchesGoldenFile";
|
||||||
String testId = "processData_withMatrixAndScaleToFitTransformation";
|
|
||||||
Matrix translateRightMatrix = new Matrix();
|
Matrix translateRightMatrix = new Matrix();
|
||||||
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
|
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
@ -201,9 +202,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_withScaleToFitAndMatrixTransformation_producesExpectedOutput()
|
public void scaleToFitAndMatrixTransformation_matchesGoldenFile() throws Exception {
|
||||||
throws Exception {
|
String testId = "scaleToFitAndMatrixTransformation_matchesGoldenFile";
|
||||||
String testId = "processData_withScaleToFitAndMatrixTransformation";
|
|
||||||
Matrix translateRightMatrix = new Matrix();
|
Matrix translateRightMatrix = new Matrix();
|
||||||
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
|
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
@ -223,9 +223,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_withPresentation_createForHeight_producesExpectedOutput()
|
public void presentation_createForHeight_matchesGoldenFile() throws Exception {
|
||||||
throws Exception {
|
String testId = "presentation_createForHeight_matchesGoldenFile";
|
||||||
String testId = "processData_withPresentation_createForHeight";
|
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
||||||
.setEffects(Presentation.createForHeight(480))
|
.setEffects(Presentation.createForHeight(480))
|
||||||
@ -241,8 +240,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_withCropThenPresentation_producesExpectedOutput() throws Exception {
|
public void cropThenPresentation_matchesGoldenFile() throws Exception {
|
||||||
String testId = "processData_withCropThenPresentation";
|
String testId = "cropThenPresentation_matchesGoldenFile";
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
||||||
.setEffects(
|
.setEffects(
|
||||||
@ -261,9 +260,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_withScaleToFitTransformation_rotate45_producesExpectedOutput()
|
public void scaleToFitTransformation_rotate45_matchesGoldenFile() throws Exception {
|
||||||
throws Exception {
|
String testId = "scaleToFitTransformation_rotate45_matchesGoldenFile";
|
||||||
String testId = "processData_withScaleToFitTransformation_rotate45";
|
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
||||||
.setEffects(new ScaleToFitTransformation.Builder().setRotationDegrees(45).build())
|
.setEffects(new ScaleToFitTransformation.Builder().setRotationDegrees(45).build())
|
||||||
@ -279,9 +277,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_withTwoWrappedScaleToFitTransformations_producesExpectedOutput()
|
public void twoWrappedScaleToFitTransformations_matchesGoldenFile() throws Exception {
|
||||||
throws Exception {
|
String testId = "twoWrappedScaleToFitTransformations_matchesGoldenFile";
|
||||||
String testId = "processData_withTwoWrappedScaleToFitTransformations";
|
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
||||||
.setEffects(
|
.setEffects(
|
||||||
@ -303,11 +300,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void
|
public void manyComposedMatrixEffects_matchesSingleEffect() throws Exception {
|
||||||
processData_withManyComposedMatrixTransformations_producesSameOutputAsCombinedTransformation()
|
String testId = "manyComposedMatrixEffects_matchesSingleEffect";
|
||||||
throws Exception {
|
|
||||||
String testId =
|
|
||||||
"processData_withManyComposedMatrixTransformations_producesSameOutputAsCombinedTransformation";
|
|
||||||
Crop centerCrop =
|
Crop centerCrop =
|
||||||
new Crop(/* left= */ -0.5f, /* right= */ 0.5f, /* bottom= */ -0.5f, /* top= */ 0.5f);
|
new Crop(/* left= */ -0.5f, /* right= */ 0.5f, /* bottom= */ -0.5f, /* top= */ 0.5f);
|
||||||
ImmutableList.Builder<Effect> full10StepRotationAndCenterCrop = new ImmutableList.Builder<>();
|
ImmutableList.Builder<Effect> full10StepRotationAndCenterCrop = new ImmutableList.Builder<>();
|
||||||
@ -339,8 +333,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_increaseBrightness_producesExpectedOutput() throws Exception {
|
public void increaseBrightness_matchesGoldenFile() throws Exception {
|
||||||
String testId = "processData_increaseBrightness";
|
String testId = "increaseBrightness_matchesGoldenFile";
|
||||||
ImmutableList<Effect> increaseBrightness =
|
ImmutableList<Effect> increaseBrightness =
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
new RgbAdjustment.Builder().setRedScale(5).build(),
|
new RgbAdjustment.Builder().setRedScale(5).build(),
|
||||||
@ -361,9 +355,9 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void processData_fullRotationIncreaseBrightnessAndCenterCrop_producesExpectedOutput()
|
public void manyComposedMatrixAndRgbEffects_producesSameOutputAsCombinedEffects()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
String testId = "drawFrame_fullRotationIncreaseBrightnessAndCenterCrop";
|
String testId = "manyComposedMatrixAndRgbEffects_producesSameOutputAsCombinedEffects";
|
||||||
Crop centerCrop =
|
Crop centerCrop =
|
||||||
new Crop(/* left= */ -0.5f, /* right= */ 0.5f, /* bottom= */ -0.5f, /* top= */ 0.5f);
|
new Crop(/* left= */ -0.5f, /* right= */ 0.5f, /* bottom= */ -0.5f, /* top= */ 0.5f);
|
||||||
ImmutableList<Effect> increaseBrightnessFullRotationCenterCrop =
|
ImmutableList<Effect> increaseBrightnessFullRotationCenterCrop =
|
||||||
@ -405,10 +399,10 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void
|
public void manyComposedMatrixAndRgbEffects_withFrameCache_producesSameOutputAsCombinedEffects()
|
||||||
processData_fullRotationIncreaseBrightnessAndCenterCropWithCache_leavesFrameUnchanged()
|
throws Exception {
|
||||||
throws Exception {
|
String testId =
|
||||||
String testId = "processData_fullRotationIncreaseBrightnessAndCenterCropWithCache";
|
"manyComposedMatrixAndRgbEffects_withFrameCache_producesSameOutputAsCombinedEffects";
|
||||||
Crop centerCrop =
|
Crop centerCrop =
|
||||||
new Crop(/* left= */ -0.5f, /* right= */ 0.5f, /* bottom= */ -0.5f, /* top= */ 0.5f);
|
new Crop(/* left= */ -0.5f, /* right= */ 0.5f, /* bottom= */ -0.5f, /* top= */ 0.5f);
|
||||||
ImmutableList<Effect> increaseBrightnessFullRotationCenterCrop =
|
ImmutableList<Effect> increaseBrightnessFullRotationCenterCrop =
|
||||||
@ -452,9 +446,8 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void drawFrame_grayscaleAndIncreaseRedChannel_producesGrayscaleAndRedImage()
|
public void grayscaleThenIncreaseRedChannel_matchesGoldenFile() throws Exception {
|
||||||
throws Exception {
|
String testId = "grayscaleThenIncreaseRedChannel_matchesGoldenFile";
|
||||||
String testId = "drawFrame_grayscaleAndIncreaseRedChannel";
|
|
||||||
glEffectsFrameProcessorTestRunner =
|
glEffectsFrameProcessorTestRunner =
|
||||||
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
new GlEffectsFrameProcessorTestRunner.Builder(testId)
|
||||||
.setEffects(
|
.setEffects(
|
||||||
@ -473,9 +466,9 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("b/261877288 Test can only run on physical devices because decoder can't decode HLG.")
|
@Ignore("b/261877288 Test can only run on physical devices because decoder can't decode HLG.")
|
||||||
public void drawHlgFrame_toneMap_producesExpectedOutput() throws Exception {
|
public void toneMap_hlgFrame_matchesGoldenFile() throws Exception {
|
||||||
// TODO(b/239735341): Move this test to mobileharness testing.
|
// TODO(b/239735341): Move this test to mobileharness testing.
|
||||||
String testId = "drawHlgFrame_toneMap";
|
String testId = "toneMap_hlgFrame_matchesGoldenFile";
|
||||||
ColorInfo hlgColor =
|
ColorInfo hlgColor =
|
||||||
new ColorInfo.Builder()
|
new ColorInfo.Builder()
|
||||||
.setColorSpace(C.COLOR_SPACE_BT2020)
|
.setColorSpace(C.COLOR_SPACE_BT2020)
|
||||||
@ -506,9 +499,9 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("b/261877288 Test can only run on physical devices because decoder can't decode PQ.")
|
@Ignore("b/261877288 Test can only run on physical devices because decoder can't decode PQ.")
|
||||||
public void drawPqFrame_toneMap_producesExpectedOutput() throws Exception {
|
public void toneMap_pqFrame_matchesGoldenFile() throws Exception {
|
||||||
// TODO(b/239735341): Move this test to mobileharness testing.
|
// TODO(b/239735341): Move this test to mobileharness testing.
|
||||||
String testId = "drawPqFrame_toneMap";
|
String testId = "toneMap_pqFrame_matchesGoldenFile";
|
||||||
ColorInfo pqColor =
|
ColorInfo pqColor =
|
||||||
new ColorInfo.Builder()
|
new ColorInfo.Builder()
|
||||||
.setColorSpace(C.COLOR_SPACE_BT2020)
|
.setColorSpace(C.COLOR_SPACE_BT2020)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user