Bug 1069222 - testcase for ImageCapture on gonk. r=roc
authorAlfredo Yang <ayang@mozilla.com>
Tue, 14 Oct 2014 23:05:00 +0200
changeset 210506 ec4e1f0988cd4ceedebd57c5f9bce536b823ed97
parent 210505 522b1d79b69e24d8dff4b3204ed13360f075e521
child 210507 01f454a80ce43d5b18ddc6b4c0414754affd4dc8
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersroc
bugs1069222
milestone36.0a1
Bug 1069222 - testcase for ImageCapture on gonk. r=roc
content/media/test/test_imagecapture.html
--- a/content/media/test/test_imagecapture.html
+++ b/content/media/test/test_imagecapture.html
@@ -33,16 +33,17 @@ function gcTest(track) {
       };
       imageCapture.onerror = function(error) {
         ok(false, "takePhoto failure in gc testing");
         reject();
       };
 
       imageCapture.takePhoto();
     }
+    info("Call gc ");
     SpecialPowers.gc();
   });
 }
 
 // Continue calling takePhoto() in rapid succession.
 function rapidTest(track) {
   return new Promise(function(resolve, reject) {
     var imageCapture = new ImageCapture(track);
@@ -106,18 +107,30 @@ function trackTest(track) {
 
     track.enabled = false;
     imageCapture.takePhoto()
   });
 }
 
 function init() {
   return new Promise(function(resolve, reject) {
+    var constraints;
+    if (SpecialPowers.Services.appinfo.widgetToolkit == "gonk") {
+      info("B2G ImageCapture test");
+      // Reduce repeat count due to b2g emulator is very slow.
+      repeat = 20;
+      // Use gonk camera, MedieEngine will be the backend of ImageCapture.
+      constraints = {video: true};
+    } else {
+      // use fake camera, MediaStreamGraph will be the backend of ImageCapture.
+      constraints = {video: true, fake: true}
+    }
+
     window.navigator.mozGetUserMedia(
-      {video: true, fake: true},
+      constraints,
       function(stream) {
         var track = stream.getVideoTracks()[0];
         resolve(track);
       },
       function(err) {
         reject(err);
       }
     );
@@ -132,20 +145,21 @@ function start() {
     info("ImageCapture blob test.");
     return blobTest(track);
   }).then(function(track) {
     info("ImageCapture rapid takePhoto() test.");
     return rapidTest(track);
   }).then(function(track) {
     info("ImageCapture multiple instances test.");
     return gcTest(track);
-  }).then(function() {
-    SimpleTest.finish();
-  });
+  }).then(SimpleTest.finish);
 }
 
+SimpleTest.requestCompleteLog();
 SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["dom.imagecapture.enabled", true]]}, start);
 
+SpecialPowers.pushPrefEnv({"set": [["dom.imagecapture.enabled", true],
+                                  ["media.navigator.permission.disabled", true]
+                                  ]}, start);
 </script>
 </pre>
 </body>
 </html>