diff options
author | Sam Dubey <dubeyshubham@google.com> | 2023-05-25 12:11:02 +0000 |
---|---|---|
committer | Sam Dubey <dubeyshubham@google.com> | 2023-06-14 14:30:43 +0000 |
commit | 78e778112d77891f4fd66aee56535f98cd6e9a6c (patch) | |
tree | cf3055f6d6c8d0158691e494402a8e17c6e18d7b | |
parent | 404c7211fc6cbfc92e730e4ca01266b5b388e53e (diff) | |
download | platform_testing-78e778112d77891f4fd66aee56535f98cd6e9a6c.tar.gz |
Check duration key exists before running video validation
Media validation fails on P23 device due to missing DURATION KEY.
Bug: b/281649792
Test: Forrest (Also verified that it passes on older devices)
Change-Id: I0710d373730e9543ed62109dd7f0d36ba6b87ad6
-rw-r--r-- | libraries/media-helper/src/android/test/mediahelper/MediaValidationHelper.java | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/libraries/media-helper/src/android/test/mediahelper/MediaValidationHelper.java b/libraries/media-helper/src/android/test/mediahelper/MediaValidationHelper.java index c7a66c429..60f16f6ca 100644 --- a/libraries/media-helper/src/android/test/mediahelper/MediaValidationHelper.java +++ b/libraries/media-helper/src/android/test/mediahelper/MediaValidationHelper.java @@ -85,20 +85,21 @@ public class MediaValidationHelper { * be longer than it. */ private static void validateVideoTrackMediaFormat( - MediaFormat format, int expHeight, int expWidth, long minDurationMillis) { - long durationMillis = + MediaFormat format, int expHeight, int expWidth, long minDurationMillis) { + if (format.containsKey(MediaFormat.KEY_DURATION)) { + long durationMillis = TimeUnit.MICROSECONDS.toMillis(format.getLong(MediaFormat.KEY_DURATION)); - int width = format.getInteger(MediaFormat.KEY_WIDTH); - int height = format.getInteger(MediaFormat.KEY_HEIGHT); - Log.d( + int width = format.getInteger(MediaFormat.KEY_WIDTH); + int height = format.getInteger(MediaFormat.KEY_HEIGHT); + Log.d( TAG, String.format( - "Duration: %d; Width: %d; Height: %d", durationMillis, width, height)); - assertThat(durationMillis).isGreaterThan(minDurationMillis); - assertThat(width).isEqualTo(expWidth); - assertThat(height).isEqualTo(expHeight); + "Duration: %d; Width: %d; Height: %d", durationMillis, width, height)); + assertThat(durationMillis).isGreaterThan(minDurationMillis); + assertThat(width).isEqualTo(expWidth); + assertThat(height).isEqualTo(expHeight); + } } - /** * Validates that the image file height and weight is greater than certain value. * |