generate-object-fit-video-tests.sh 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. #
  3. # Any copyright is dedicated to the Public Domain.
  4. # http://creativecommons.org/publicdomain/zero/1.0/
  5. #
  6. # Script to generate <video src> reftest files, from corresponding reftest
  7. # files that use <video poster>.
  8. #
  9. # This script expects to be run from this working directory:
  10. # mozilla-central/layout/reftests/w3c-css/submitted/images3
  11. #
  12. # It requires that the tools png2yuv and vpxenc be available, from the
  13. # Ubuntu packages 'mjpegtools' and 'vpx-tools'. More info here:
  14. # http://wiki.webmproject.org/howtos/convert-png-frames-to-webm-video
  15. VIDEO_REFTEST_PATH="../../../webm-video"
  16. imageFileArr=("colors-16x8.png" "colors-8x16.png")
  17. numImageFiles=${#imageFileArr[@]}
  18. # Copy image files, and generate webm files:
  19. for ((i = 0; i < $numImageFiles; i++)); do
  20. imageFileName=${imageFileArr[$i]}
  21. imageDest=$VIDEO_REFTEST_PATH/$imageFileName
  22. echo "Copying $imageDest."
  23. hg cp support/$imageFileName $imageDest
  24. videoDest=`echo $imageDest | sed "s/png/webm/"`
  25. echo "Generating $videoDest."
  26. png2yuv -f 1 -I p -b 1 -n 1 -j $imageDest \
  27. | vpxenc --passes=1 --pass=1 --codec=vp9 --lossless=1 --max-q=0 -o $videoDest -
  28. hg add $videoDest
  29. done
  30. # Add comment & default-preferences line to reftest.list in dest directory:
  31. reftestListFileName="$VIDEO_REFTEST_PATH/reftest.list"
  32. echo "
  33. # Tests for <video src> with 'object-fit' & 'object-position':
  34. # These tests should be very similar to tests in our w3c-css/submitted/images3
  35. # reftest directory. They live here because they use WebM video (VP9), and it
  36. # wouldn't be fair of us to make a W3C testsuite implicitly depend on any
  37. # particular (non-spec-mandated) video codec.
  38. default-preferences test-pref(layout.css.object-fit-and-position.enabled,true)"\
  39. >> $reftestListFileName
  40. # Loop across all <video poster> tests:
  41. for origTestName in object*p.html; do
  42. # Find the corresponding reference case:
  43. origReferenceName=$(echo $origTestName |
  44. sed "s/p.html/-ref.html/")
  45. # The generated testcase will have "-webm" instead of "-png", and unlike
  46. # the original png test, it won't have a single-letter suffix to indicate the
  47. # particular container element. (since it's unnecessary -- there's only one
  48. # possible container element for webm, "<video>")
  49. videoTestName=$(echo $origTestName |
  50. sed "s/png/webm/" |
  51. sed "s/p.html/.html/")
  52. videoReferenceName=$(echo $videoTestName |
  53. sed "s/.html/-ref.html/")
  54. # Generate reference file (dropping "support" subdir from image paths):
  55. echo "Copying $origReferenceName to $VIDEO_REFTEST_PATH."
  56. videoReferenceFullPath=$VIDEO_REFTEST_PATH/$videoReferenceName
  57. hg cp $origReferenceName $videoReferenceFullPath
  58. sed -i "s,support/,," $videoReferenceFullPath
  59. # Generate testcase
  60. # (converting <video poster="support/foo.png"> to <video src="foo.webm">):
  61. echo "Generating $videoTestName from $origTestName."
  62. videoTestFullPath=$VIDEO_REFTEST_PATH/$videoTestName
  63. hg cp $origTestName $videoTestFullPath
  64. sed -i "s/PNG image/WebM video/" $videoTestFullPath
  65. sed -i "s/poster/src/" $videoTestFullPath
  66. sed -i "s,support/,," $videoTestFullPath
  67. sed -i "s/png/webm/" $videoTestFullPath
  68. sed -i "s/$origReferenceName/$videoReferenceName/" $videoTestFullPath
  69. # Update reftest manifest:
  70. annotation="fails-if(layersGPUAccelerated) skip-if(Android||B2G)"
  71. comment="# Bug 1083516 for layersGPUAccelerated failures, Bug 1084564 for Android/B2G failures"
  72. echo "$annotation == $videoTestName $videoReferenceName $comment" \
  73. >> $reftestListFileName
  74. done