tests.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>OpenCV JS Tests</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.20.0.css" type="text/css" media="screen">
  8. <style>
  9. body {
  10. font-family: Monospace;
  11. background-color: #ffffff;
  12. margin: 0px;
  13. }
  14. a {
  15. color: #0040ff;
  16. }
  17. </style>
  18. <script src="http://code.jquery.com/qunit/qunit-2.0.1.js"></script>
  19. <script type="text/javascript">
  20. QUnit.config.autostart = false;
  21. QUnit.log(function(details) {
  22. if (details.result) {
  23. return;
  24. }
  25. var loc = details.module + ": " + details.name + ": ",
  26. output = "FAILED: " + loc + ( details.message ? details.message : "" )
  27. prefix = details.message ? ", " : "";
  28. if (details.actual) {
  29. output += prefix + "expected: " + details.expected + ", actual: " + details.actual;
  30. prefix = ', ';
  31. }
  32. if (details.source) {
  33. output += prefix + details.source;
  34. }
  35. console.warn(output);
  36. });
  37. QUnit.done(function(details) {
  38. console.log("Total: " + details.total + " Failed: " + details.failed + " Passed: " + details.passed);
  39. console.log("Time(ms): " + details.runtime);
  40. });
  41. // Helper for opencv.js (see below)
  42. var Module = {
  43. preRun: [function() {
  44. Module.FS_createPreloadedFile('/', 'haarcascade_frontalface_default.xml', 'haarcascade_frontalface_default.xml', true, false);
  45. }],
  46. postRun: [] ,
  47. onRuntimeInitialized: function() {
  48. console.log("Emscripten runtime is ready, launching QUnit tests...");
  49. if (window.cv instanceof Promise) {
  50. window.cv.then((target) => {
  51. window.cv = target;
  52. //console.log(cv.getBuildInformation());
  53. QUnit.start();
  54. })
  55. } else {
  56. // for backward compatible
  57. // console.log(cv.getBuildInformation());
  58. QUnit.start();
  59. }
  60. },
  61. print: (function() {
  62. var element = document.getElementById('output');
  63. if (element) element.value = ''; // clear browser cache
  64. return function(text) {
  65. console.log(text);
  66. if (element) {
  67. element.value += text + "\n";
  68. element.scrollTop = element.scrollHeight; // focus on bottom
  69. }
  70. };
  71. })(),
  72. printErr: function(text) {
  73. console.error(text);
  74. },
  75. setStatus: function(text) {
  76. console.log(text);
  77. },
  78. totalDependencies: 0
  79. };
  80. Module.setStatus('Downloading...');
  81. window.onerror = function(event) {
  82. Module.setStatus('Exception thrown, see JavaScript console');
  83. Module.setStatus = function(text) {
  84. if (text) Module.printErr('[post-exception status] ' + text);
  85. };
  86. };
  87. function opencvjs_LoadError() {
  88. Module.printErr('Failed to load/initialize opencv.js');
  89. QUnit.module('LoaderFatalError', {});
  90. QUnit.config.module = 'LoaderFatalError';
  91. QUnit.only("Failed to load OpenCV.js", function(assert) {
  92. assert.ok(false, "Can't load/initialize opencv.js");
  93. });
  94. QUnit.start();
  95. }
  96. </script>
  97. </head>
  98. <body>
  99. <div id="qunit"></div>
  100. <div id="qunit-fixture"></div>
  101. <script type="application/javascript" async src="opencv.js" onerror="opencvjs_LoadError()"></script>
  102. <script type="application/javascript" src="test_mat.js"></script>
  103. <script type="application/javascript" src="test_utils.js"></script>
  104. <script type="application/javascript" src="test_imgproc.js"></script>
  105. <script type="application/javascript" src="test_objdetect.js"></script>
  106. <script type="application/javascript" src="test_video.js"></script>
  107. <script type="application/javascript" src="test_photo.js"></script>
  108. <script type="application/javascript" src="test_features2d.js"></script>
  109. <script type="application/javascript" src="test_calib3d.js"></script>
  110. </body>
  111. </html>