зеркало из https://github.com/mozilla/gecko-dev.git
Bug 732212 - Robocop: Add tests for doorhanger notifications. r=bnicholson
This commit is contained in:
Родитель
5ed801d300
Коммит
03938f4294
|
@ -17,6 +17,7 @@ import java.io.InputStream;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* A convenient base class suitable for most Robocop tests.
|
||||
|
@ -28,6 +29,7 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
|||
private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";
|
||||
private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
|
||||
private static final int VERIFY_URL_TIMEOUT = 2000;
|
||||
private static final int MAX_WAIT_MS = 3000;
|
||||
|
||||
private static Class<Activity> mLauncherActivityClass;
|
||||
private Activity mActivity;
|
||||
|
@ -358,4 +360,36 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
|||
int tabCountInt = Integer.parseInt(tabCountText);
|
||||
mAsserter.is(tabCountInt, expectedTabCount, "The correct number of tabs are opened");
|
||||
}
|
||||
|
||||
public void addTab(String url) {
|
||||
Element tabs = null;
|
||||
Element addTab = null;
|
||||
|
||||
Activity activity = getActivity();
|
||||
tabs = mDriver.findElement(activity, "tabs");
|
||||
addTab = mDriver.findElement(activity, "add_tab");
|
||||
final int addTabId = addTab.getId();
|
||||
mAsserter.ok(tabs.click(), "checking that tabs clicked", "tabs element clicked");
|
||||
|
||||
// wait for addTab to appear (this is usually immediate)
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
public boolean test() {
|
||||
View addTabView = getActivity().findViewById(addTabId);
|
||||
if (addTabView == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, MAX_WAIT_MS);
|
||||
mAsserter.ok(success, "waiting for add tab view", "add tab view available");
|
||||
|
||||
mAsserter.ok(addTab.click(), "checking that add_tab clicked", "add_tab element clicked");
|
||||
|
||||
// must pause before sending keys, until awesome bar is displayed; waiting for known text is simple
|
||||
mSolo.waitForText("History");
|
||||
|
||||
// cannot use loadUrl(): getText fails because we are using a different urlbar
|
||||
mActions.sendKeys(url);
|
||||
hitEnterAndWait();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
[testAddonManager]
|
||||
[testHistory]
|
||||
[testVkbOverlap]
|
||||
[testDoorHanger]
|
||||
# [testPermissions] # see bug 757475
|
||||
# [testJarReader] # see bug 738890
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<html>
|
||||
<script>
|
||||
function login(){
|
||||
document.login.username.value="Test";
|
||||
document.login.password.value="Test";
|
||||
document.getElementById('submit').click();
|
||||
}
|
||||
</script>
|
||||
<head>
|
||||
<title>Robocop Login</title>
|
||||
</head>
|
||||
<body onload="login()">
|
||||
<h2>User Login </h2>
|
||||
<form name="login" method="post" action="robocop_blank_01.html">
|
||||
Username: <input type="text" name="username" id="username"><br>
|
||||
Password: <input type="password" name="password" id="password"><br>
|
||||
<input type="submit" id="submit" name="submit" value="Login!">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,7 @@
|
|||
<html manifest="robocop_offline">
|
||||
<head>
|
||||
<title>Robocop offline storage</title>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,97 @@
|
|||
#filter substitution
|
||||
package @ANDROID_PACKAGE_NAME@.tests;
|
||||
|
||||
import @ANDROID_PACKAGE_NAME@.*;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
|
||||
/* This test will test if doorhangers are displayed and dismissed
|
||||
The test will test:
|
||||
* geolocation doorhangers - sharing and not sharing the location dismisses the doorhanger
|
||||
* opening a new tab hides the doorhanger
|
||||
* offline storage permission doorhangers - allowing and not allowing offline storage dismisses the doorhanger
|
||||
* Password Manager doorhangers - Remember and Not Now options dismiss the doorhanger
|
||||
*/
|
||||
public class testDoorHanger extends BaseTest {
|
||||
|
||||
@Override
|
||||
protected int getTestType() {
|
||||
return TEST_MOCHITEST;
|
||||
}
|
||||
|
||||
public void testDoorHanger() {
|
||||
String GEO_URL = getAbsoluteUrl("/robocop/robocop_geolocation.html");
|
||||
String BLANK_URL = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
||||
String OFFLINE_STORAGE_URL = getAbsoluteUrl("/robocop/robocop_offline_storage.html");
|
||||
String LOGIN_URL = getAbsoluteUrl("/robocop/robocop_login.html");
|
||||
|
||||
blockForGeckoReady();
|
||||
|
||||
// Test geolocation notification
|
||||
loadUrl(GEO_URL);
|
||||
mSolo.waitForText("wants your location");
|
||||
mAsserter.is(mSolo.searchText("wants your location"), true, "Geolocation doorhanger has been displayed");
|
||||
|
||||
// Test "Share" button hides the notification
|
||||
mSolo.clickOnCheckBox(0);
|
||||
mSolo.clickOnText("Share");
|
||||
mAsserter.is(mSolo.searchText("wants your location"), false, "Geolocation doorhanger has been hidden");
|
||||
|
||||
// Re-trigger geolocation notification
|
||||
loadUrl(GEO_URL);
|
||||
mSolo.waitForText("wants your location");
|
||||
|
||||
// Test "Don't share" button hides the notification
|
||||
mSolo.clickOnCheckBox(0);
|
||||
mSolo.clickOnText("Don't share");
|
||||
mAsserter.is(mSolo.searchText("wants your location"), false, "Geolocation doorhanger has been hidden");
|
||||
|
||||
// Re-trigger geolocation notification
|
||||
loadUrl(GEO_URL);
|
||||
mSolo.waitForText("wants your location");
|
||||
|
||||
// Add a new tab
|
||||
addTab(BLANK_URL);
|
||||
|
||||
// Make sure doorhanger is hidden
|
||||
mAsserter.is(mSolo.searchText("wants your location"), false, "Doorhanger notification is hidden");
|
||||
|
||||
// Load offline storage page
|
||||
loadUrl(OFFLINE_STORAGE_URL);
|
||||
mSolo.waitForText("wants to store data on your device for offline use");
|
||||
|
||||
// Test doorhanger dismissed when tapping "Not Now"
|
||||
mSolo.clickOnText("Not Now");
|
||||
mAsserter.is(mSolo.searchText("wants to store data on your device for offline use"), false, "Doorhanger notification is hidden");
|
||||
|
||||
// Load offline storage page
|
||||
loadUrl(OFFLINE_STORAGE_URL);
|
||||
mSolo.waitForText("wants to store data on your device for offline use");
|
||||
|
||||
// Test doorhanger dismissed when tapping "Allow" and is not displayed again
|
||||
mSolo.clickOnText("Allow");
|
||||
mAsserter.is(mSolo.searchText("wants to store data on your device for offline use"), false, "Doorhanger notification is hidden");
|
||||
loadUrl(OFFLINE_STORAGE_URL);
|
||||
mAsserter.is(mSolo.searchText("wants to store data on your device for offline use"), false, "Doorhanger is no longer triggered");
|
||||
|
||||
// Load login page
|
||||
loadUrl(LOGIN_URL);
|
||||
mSolo.waitForText("to remeber password for");
|
||||
|
||||
// Test doorhanger is dismissed when tapping "Not Now"
|
||||
mSolo.clickOnText("Not Now");
|
||||
mAsserter.is(mSolo.searchText("to remeber password for"), false, "Doorhanger notification is hidden");
|
||||
|
||||
// Load login page
|
||||
loadUrl(LOGIN_URL);
|
||||
mSolo.waitForText("prevented this site from opening");
|
||||
|
||||
// Test doorhanger is dismissed when tapping "Never show" and is no longer triggered
|
||||
mSolo.clickOnText("Remember");
|
||||
mAsserter.is(mSolo.searchText("to remeber password for"), false, "Doorhanger notification is hidden");
|
||||
|
||||
// Reload the page and check that there is no doorhanger displayed
|
||||
loadUrl(LOGIN_URL);
|
||||
mAsserter.is(mSolo.searchText("to remeber password for"), false, "Doorhanger notification is hidden");
|
||||
}
|
||||
}
|
|
@ -57,40 +57,6 @@ public class testNewTab extends BaseTest {
|
|||
closeTabs();
|
||||
}
|
||||
|
||||
private void addTab(String url) {
|
||||
final int addTabId = addTab.getId();
|
||||
|
||||
boolean clicked = tabs.click();
|
||||
if (!clicked) {
|
||||
mAsserter.ok(clicked != false, "checking that tabs clicked", "tabs element clicked");
|
||||
}
|
||||
|
||||
// wait for addTab to appear (this is usually immediate)
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
public boolean test() {
|
||||
View addTabView = getActivity().findViewById(addTabId);
|
||||
if (addTabView == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, MAX_WAIT_MS);
|
||||
if (!success) {
|
||||
mAsserter.ok(success != false, "waiting for add tab view", "add tab view available");
|
||||
}
|
||||
|
||||
clicked = addTab.click();
|
||||
if (!clicked) {
|
||||
mAsserter.ok(clicked != false, "checking that add_tab clicked", "add_tab element clicked");
|
||||
}
|
||||
// must pause before sending keys, until awesome bar is displayed; waiting for known text is simple
|
||||
mSolo.waitForText("History");
|
||||
|
||||
// cannot use loadUrl(): getText fails because we are using a different urlbar
|
||||
mActions.sendKeys(url);
|
||||
hitEnterAndWait();
|
||||
}
|
||||
|
||||
private void closeTabs() {
|
||||
final int closeTabId = closeTab.getId();
|
||||
String tabCountText = null;
|
||||
|
|
Загрузка…
Ссылка в новой задаче