Bug 1018928 - Expand Android gUM + gUM Doorhanger tests. r=mfinkle

This commit is contained in:
Gian-Carlo Pascutto 2014-07-01 15:38:03 +02:00
parent 1967a87d4a
commit b7a4bcd508
3 changed files with 64 additions and 11 deletions

View File

@ -40,6 +40,8 @@ skip-if = android_version == "10"
skip-if = processor == "x86" skip-if = processor == "x86"
[testFormHistory] [testFormHistory]
[testGetUserMedia] [testGetUserMedia]
# disabled on 2.3; see bug 981881]
skip-if = android_version == "10"
# [testHistory] # see bug 915350 # [testHistory] # see bug 915350
[testHomeBanner] [testHomeBanner]
# disabled on x86 only; bug 957185 # disabled on x86 only; bug 957185

View File

@ -4,6 +4,7 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="utf-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="utf-8">
</head> </head>
<body> <body>
<div id="content"></div>
<script type="application/javascript"> <script type="application/javascript">
var video_status = false; var video_status = false;
var video = document.createElement("video"); var video = document.createElement("video");
@ -14,6 +15,9 @@
var audio = document.createElement("audio"); var audio = document.createElement("audio");
audio.setAttribute("controls", true); audio.setAttribute("controls", true);
var content = document.getElementById("content");
document.title = "gUM Test Page";
startAudioVideo(); startAudioVideo();
function startAudioVideo() { function startAudioVideo() {
@ -41,7 +45,6 @@
function startMedia(param) { function startMedia(param) {
try { try {
window.navigator.mozGetUserMedia(param, function(stream) { window.navigator.mozGetUserMedia(param, function(stream) {
message.innerHTML = "<p>Success!</p>";
if (video_status) { if (video_status) {
content.appendChild(video); content.appendChild(video);
video.mozSrcObject = stream; video.mozSrcObject = stream;
@ -52,7 +55,18 @@
audio.mozSrcObject = stream; audio.mozSrcObject = stream;
audio.play(); audio.play();
} }
var audioTracks = stream.getAudioTracks();
var videoTracks = stream.getVideoTracks();
document.title = "";
if (audioTracks.length > 0) {
document.title += "audio";
}
if (videoTracks.length > 0) {
document.title += "video";
}
document.title += " gumtest";
}, function(err) { }, function(err) {
document.title = "failed gumtest";
stopMedia(); stopMedia();
}); });
} catch(e) { } catch(e) {
@ -60,4 +74,4 @@
} }
} }
</script> </script>
</body></html> </body></html>

View File

@ -8,8 +8,13 @@ public class testGetUserMedia extends BaseTest {
String GUM_URL = getAbsoluteUrl("/robocop/robocop_getusermedia.html"); String GUM_URL = getAbsoluteUrl("/robocop/robocop_getusermedia.html");
String GUM_MESSAGE = "Would you like to share your camera and microphone with"; String GUM_MESSAGE = "Would you like to share your camera and microphone with";
String GUM_ALLOW = "Share"; String GUM_ALLOW = "^Share$";
String GUM_DENY = "Don't share"; String GUM_DENY = "^Don't Share$";
String GUM_PAGE_FAILED = "failed gumtest";
String GUM_PAGE_AUDIO = "audio gumtest";
String GUM_PAGE_VIDEO = "video gumtest";
String GUM_PAGE_AUDIOVIDEO = "audiovideo gumtest";
blockForGeckoReady(); blockForGeckoReady();
@ -18,13 +23,45 @@ public class testGetUserMedia extends BaseTest {
// getNumberOfCameras is Gingerbread/9+ // getNumberOfCameras is Gingerbread/9+
// We could avoid that requirement by trying to open a Camera but we // 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. // already know our 2.2/Tegra test devices don't have them.
if (Build.VERSION.SDK_INT >= 9) { if (Build.VERSION.SDK_INT < 9) {
if (Camera.getNumberOfCameras() > 0) { return;
// Test GUM notification
inputAndLoadUrl(GUM_URL);
waitForText(GUM_MESSAGE);
mAsserter.is(mSolo.searchText(GUM_MESSAGE), true, "GetUserMedia doorhanger has been displayed");
}
} }
if (Camera.getNumberOfCameras() <= 0) {
return;
}
// Test GUM notification showing
inputAndLoadUrl(GUM_URL);
waitForText(GUM_MESSAGE);
mAsserter.is(mSolo.searchText(GUM_MESSAGE), true, "GetUserMedia doorhanger has been displayed");
mSolo.clickOnButton(GUM_DENY);
verifyPageTitle(GUM_PAGE_FAILED);
inputAndLoadUrl(GUM_URL);
waitForText(GUM_MESSAGE);
// Cameras don't work on the testing hardware, so stream a tab
mSolo.clickOnText("Back facing camera");
mSolo.clickOnText("Choose a tab to stream");
mSolo.clickOnButton(GUM_ALLOW);
mSolo.clickOnText("gUM Test Page");
verifyPageTitle(GUM_PAGE_AUDIOVIDEO);
inputAndLoadUrl(GUM_URL);
waitForText(GUM_MESSAGE);
mSolo.clickOnText("Back facing camera");
mSolo.clickOnText("No Video");
mSolo.clickOnButton(GUM_ALLOW);
verifyPageTitle(GUM_PAGE_AUDIO);
inputAndLoadUrl(GUM_URL);
waitForText(GUM_MESSAGE);
// Cameras don't work on the testing hardware, so stream a tab
mSolo.clickOnText("Back facing camera");
mSolo.clickOnText("Choose a tab to stream");
mSolo.clickOnText("Microphone 1");
mSolo.clickOnText("No Audio");
mSolo.clickOnButton(GUM_ALLOW);
mSolo.clickOnText("gUM Test Page");
verifyPageTitle(GUM_PAGE_VIDEO);
} }
} }