mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
Transformer: remove unused bitmap test option.
Remove unused saveTestBitmapToCacheDirectory throwOnFailure option. #cleanup PiperOrigin-RevId: 444516857
This commit is contained in:
parent
877ba22b20
commit
b29d49637e
5 changed files with 48 additions and 57 deletions
|
|
@ -98,8 +98,8 @@ public final class AdvancedFrameProcessorPixelTest {
|
|||
Bitmap actualBitmap =
|
||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -120,8 +120,8 @@ public final class AdvancedFrameProcessorPixelTest {
|
|||
Bitmap actualBitmap =
|
||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -142,8 +142,8 @@ public final class AdvancedFrameProcessorPixelTest {
|
|||
Bitmap actualBitmap =
|
||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -164,8 +164,8 @@ public final class AdvancedFrameProcessorPixelTest {
|
|||
Bitmap actualBitmap =
|
||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
|
|||
|
|
@ -108,6 +108,8 @@ public class BitmapTestUtil {
|
|||
* of pixels in the image. The bitmap resolutions must match and they must use configuration
|
||||
* {@link Bitmap.Config#ARGB_8888}.
|
||||
*
|
||||
* <p>Tries to save a difference bitmap between expected and actual bitmaps.
|
||||
*
|
||||
* @param expected The expected {@link Bitmap}.
|
||||
* @param actual The actual {@link Bitmap} produced by the test.
|
||||
* @param testId The name of the test that produced the {@link Bitmap}, or {@code null} if the
|
||||
|
|
@ -148,41 +150,30 @@ public class BitmapTestUtil {
|
|||
}
|
||||
}
|
||||
if (testId != null) {
|
||||
try {
|
||||
saveTestBitmapToCacheDirectory(
|
||||
testId, "diff", differencesBitmap, /* throwOnFailure= */ false);
|
||||
} catch (IOException impossible) {
|
||||
throw new IllegalStateException(impossible);
|
||||
}
|
||||
maybeSaveTestBitmapToCacheDirectory(testId, "diff", differencesBitmap);
|
||||
}
|
||||
return (float) sumMaximumAbsoluteDifferences / (width * height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the {@link Bitmap} to the {@link Context#getCacheDir() cache directory} as a PNG.
|
||||
* Tries to save the {@link Bitmap} to the {@link Context#getCacheDir() cache directory} as a PNG.
|
||||
*
|
||||
* <p>File name will be {@code <testId>_<bitmapLabel>.png}. If {@code throwOnFailure} is {@code
|
||||
* false}, any {@link IOException} will be caught and logged.
|
||||
* <p>File name will be {@code <testId>_<bitmapLabel>.png}. If the file failed to write, any
|
||||
* {@link IOException} will be caught and logged.
|
||||
*
|
||||
* @param testId Name of the test that produced the {@link Bitmap}.
|
||||
* @param bitmapLabel Label to identify the bitmap.
|
||||
* @param bitmap The {@link Bitmap} to save.
|
||||
* @param throwOnFailure Whether to throw an exception if the bitmap can't be saved.
|
||||
* @throws IOException If the bitmap can't be saved and {@code throwOnFailure} is {@code true}.
|
||||
*/
|
||||
public static void saveTestBitmapToCacheDirectory(
|
||||
String testId, String bitmapLabel, Bitmap bitmap, boolean throwOnFailure) throws IOException {
|
||||
public static void maybeSaveTestBitmapToCacheDirectory(
|
||||
String testId, String bitmapLabel, Bitmap bitmap) {
|
||||
File file =
|
||||
new File(
|
||||
getApplicationContext().getExternalCacheDir(), testId + "_" + bitmapLabel + ".png");
|
||||
try (FileOutputStream outputStream = new FileOutputStream(file)) {
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, /* quality= */ 100, outputStream);
|
||||
} catch (IOException e) {
|
||||
if (throwOnFailure) {
|
||||
throw e;
|
||||
} else {
|
||||
Log.e(TAG, "Could not write Bitmap to file path: " + file.getAbsolutePath(), e);
|
||||
}
|
||||
Log.e(TAG, "Could not write Bitmap to file path: " + file.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,8 +95,8 @@ public final class FrameProcessorChainPixelTest {
|
|||
|
||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -116,8 +116,8 @@ public final class FrameProcessorChainPixelTest {
|
|||
|
||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -140,8 +140,8 @@ public final class FrameProcessorChainPixelTest {
|
|||
|
||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -164,8 +164,8 @@ public final class FrameProcessorChainPixelTest {
|
|||
|
||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -184,8 +184,8 @@ public final class FrameProcessorChainPixelTest {
|
|||
|
||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -204,8 +204,8 @@ public final class FrameProcessorChainPixelTest {
|
|||
|
||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||
outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -136,8 +136,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||
outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -163,8 +163,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||
outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -192,8 +192,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||
outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -221,8 +221,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||
outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -250,8 +250,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||
outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -279,8 +279,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||
outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -308,8 +308,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||
outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
@ -337,8 +337,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||
outputSize.getWidth(), outputSize.getHeight());
|
||||
|
||||
BitmapTestUtil.saveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap, /* throwOnFailure= */ false);
|
||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
|
||||
float averagePixelAbsoluteDifference =
|
||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class TransformationTest {
|
|||
|
||||
@Test
|
||||
public void transformToSpecificBitrate() throws Exception {
|
||||
String testId = TAG + "_transformWithSpecificBitrate";
|
||||
String testId = TAG + "_transformToSpecificBitrate";
|
||||
Context context = ApplicationProvider.getApplicationContext();
|
||||
Transformer transformer =
|
||||
new Transformer.Builder(context)
|
||||
|
|
|
|||
Loading…
Reference in a new issue