Bug 928870 - Add test for Android gUM doorhanger. r=gbrown

This commit is contained in:
Gian-Carlo Pascutto 2013-10-22 11:10:17 +02:00
parent 415c4b7638
commit 2ff01736a9
3 changed files with 104 additions and 0 deletions

View File

@ -46,6 +46,7 @@
[testDeviceSearchEngine]
[testPrivateBrowsing]
[testReaderMode]
[testGetUserMedia]
# Used for Talos, please don't use in mochitest
#[testPan]

View File

@ -0,0 +1,63 @@
<!DOCTYPE html>
<html><head>
<title>gUM Test Page</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="utf-8">
</head>
<body>
<script type="application/javascript">
var video_status = false;
var video = document.createElement("video");
video.setAttribute("width", 640);
video.setAttribute("height", 480);
var audio_status = false;
var audio = document.createElement("audio");
audio.setAttribute("controls", true);
startAudioVideo();
function startAudioVideo() {
video_status = true;
audio_status = true;
startMedia({video:true, audio:true});
}
function stopMedia() {
if (video_status) {
video.mozSrcObject.stop();
video.mozSrcObject = null;
content.removeChild(video);
capturing = false;
video_status = false;
}
if (audio_status) {
audio.mozSrcObject.stop();
audio.mozSrcObject = null;
content.removeChild(audio);
audio_status = false;
}
}
function startMedia(param) {
try {
window.navigator.mozGetUserMedia(param, function(stream) {
message.innerHTML = "<p>Success!</p>";
if (video_status) {
content.appendChild(video);
video.mozSrcObject = stream;
video.play();
}
if (audio_status) {
content.appendChild(audio);
audio.mozSrcObject = stream;
audio.play();
}
}, function(err) {
stopMedia();
});
} catch(e) {
stopMedia();
}
}
</script>
</body></html>

View File

@ -0,0 +1,40 @@
#filter substitution
package @ANDROID_PACKAGE_NAME@.tests;
import @ANDROID_PACKAGE_NAME@.*;
import android.app.Activity;
import android.hardware.Camera;
import android.os.Build;
import java.lang.reflect.Method;
public class testGetUserMedia extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testGetUserMedia() {
String GUM_URL = getAbsoluteUrl("/robocop/robocop_getusermedia.html");
String GUM_MESSAGE = "Would you like to share your camera and microphone with";
String GUM_ALLOW = "Share";
String GUM_DENY = "Don't share";
blockForGeckoReady();
// Only try GUM test if the device has a camera. If there's a working Camera,
// we'll assume there is a working audio device as well.
// getNumberOfCameras is Gingerbread/9+
// We could avoid that requirement by trying to open a Camera but we
// already know our 2.2/Tegra test devices don't have them.
if (Build.VERSION.SDK_INT >= 9) {
if (Camera.getNumberOfCameras() > 0) {
// Test GUM notification
inputAndLoadUrl(GUM_URL);
waitForText(GUM_MESSAGE);
mAsserter.is(mSolo.searchText(GUM_MESSAGE), true, "GetUserMedia doorhanger has been displayed");
}
}
}
}