generate-object-position-video-tests.sh 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. reftestListFileName="$VIDEO_REFTEST_PATH/reftest.list"
  31. # Loop across all <video poster> tests:
  32. for origTestName in object-position-png-*p.html; do
  33. # Find the corresponding reference case:
  34. origReferenceName=$(echo $origTestName |
  35. sed "s/p.html/-ref.html/")
  36. # The generated testcase will have "-webm" instead of "-png", and unlike
  37. # the original png test, it won't have a single-letter suffix to indicate the
  38. # particular container element. (since it's unnecessary -- there's only one
  39. # possible container element for webm, "<video>")
  40. videoTestName=$(echo $origTestName |
  41. sed "s/png/webm/" |
  42. sed "s/p.html/.html/")
  43. videoReferenceName=$(echo $videoTestName |
  44. sed "s/.html/-ref.html/")
  45. # Generate reference file (dropping "support" subdir from image paths):
  46. echo "Copying $origReferenceName to $VIDEO_REFTEST_PATH."
  47. videoReferenceFullPath=$VIDEO_REFTEST_PATH/$videoReferenceName
  48. hg cp $origReferenceName $videoReferenceFullPath
  49. sed -i "s,support/,," $videoReferenceFullPath
  50. # Generate testcase
  51. # (converting <video poster="support/foo.png"> to <video src="foo.webm">):
  52. echo "Generating $videoTestName from $origTestName."
  53. videoTestFullPath=$VIDEO_REFTEST_PATH/$videoTestName
  54. hg cp $origTestName $videoTestFullPath
  55. sed -i "s/PNG image/WebM video/" $videoTestFullPath
  56. sed -i "s/poster/src/" $videoTestFullPath
  57. sed -i "s,support/,," $videoTestFullPath
  58. sed -i "s/png/webm/" $videoTestFullPath
  59. sed -i "s/$origReferenceName/$videoReferenceName/" $videoTestFullPath
  60. # Update reftest manifest:
  61. annotation="fails-if(layersGPUAccelerated) skip-if(Android||B2G)"
  62. comment="# Bug 1098417 for across-the-board failure, Bug 1083516 for layersGPUAccelerated failures, Bug 1084564 for Android/B2G failures"
  63. echo "$annotation == $videoTestName $videoReferenceName $comment" \
  64. >> $reftestListFileName
  65. done