Bug 1069222 - testcase for ImageCapture on gonk. r=roc
--- 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>