Bug 1069222 - testcase for ImageCapture on gonk. r=roc
☠☠ backed out by 4414bcd4350e ☠ ☠
authorAlfredo Yang <ayang@mozilla.com>
Tue, 14 Oct 2014 00:28:00 +0200
changeset 210327 3193763d0a3bbe6bfca4a07f73802320e3b8ca07
parent 210326 d150f12f7e603ec059a76b6b0ffe6fe03d3deaee
child 210328 f9faedda0179e32f5b103920b2ba154fc78118bb
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.name == "B2G") {
+      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>