Bug 846340 - Robocop: Add test for 'Clear Site settings', 'Clear Saved passwords' and 'Clear history' options. r=gbrown

This commit is contained in:
teodora vermesan 2013-11-21 12:17:48 +02:00
parent 4d2ce56f4a
commit e90d3c9ee4
2 changed files with 82 additions and 6 deletions

View File

@ -52,6 +52,13 @@ public class StringHelper {
"Add to Home Screen" "Add to Home Screen"
}; };
public static final String[] CONTEXT_MENU_ITEMS_IN_URL_BAR = new String[] {
"Share",
"Copy Address",
"Edit Site Settings",
"Add to Home Screen"
};
public static final String TITLE_PLACE_HOLDER = "Enter Search or Address"; public static final String TITLE_PLACE_HOLDER = "Enter Search or Address";
// Robocop page urls // Robocop page urls

View File

@ -1,8 +1,17 @@
package org.mozilla.gecko.tests; package org.mozilla.gecko.tests;
import android.view.View;
import org.mozilla.gecko.*; import org.mozilla.gecko.*;
import java.util.ArrayList; import java.util.ArrayList;
/**
* This patch tests the clear private data options:
* - clear history option by: adding and checking that clear private
* data option removes the history items but not the users bookmarks
* - clear site settings and clear saved password by: checking
* each option present in the doorhanger and clearing the settings from
* the URL bar context menu and settings menu
*/
public class testClearPrivateData extends PixelTest { public class testClearPrivateData extends PixelTest {
private final int TEST_WAIT_MS = 10000; private final int TEST_WAIT_MS = 10000;
@ -14,21 +23,25 @@ public class testClearPrivateData extends PixelTest {
public void testClearPrivateData() { public void testClearPrivateData() {
blockForGeckoReady(); blockForGeckoReady();
clearHistory(); clearHistory();
clearSiteSettings();
clearPassword();
} }
private void clearHistory() { private void clearHistory() {
// Loading a page and adding a second one as bookmark to have user made bookmarks and history // Loading a page and adding a second one as bookmark to have user made bookmarks and history
String blank1 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); String blank1 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
String blank2 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL); String blank2 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL);
String title = StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE;
loadAndPaint(blank1); inputAndLoadUrl(blank1);
waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); verifyPageTitle(title);
mDatabaseHelper.addOrUpdateMobileBookmark(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, blank2); mDatabaseHelper.addOrUpdateMobileBookmark(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, blank2);
// Checking that the history list is not empty // Checking that the history list is not empty
verifyHistoryCount(1); verifyHistoryCount(1);
clearPrivateData();
//clear and check for device
checkDevice(title);
// Checking that history list is empty // Checking that history list is empty
verifyHistoryCount(0); verifyHistoryCount(0);
@ -45,4 +58,60 @@ public class testClearPrivateData extends PixelTest {
}, TEST_WAIT_MS); }, TEST_WAIT_MS);
mAsserter.ok(match, "Checking that the number of history items is correct", String.valueOf(expectedCount) + " history items present in the database"); mAsserter.ok(match, "Checking that the number of history items is correct", String.valueOf(expectedCount) + " history items present in the database");
} }
public void clearSiteSettings() {
String shareStrings[] = {"Share your location with", "Share", "Don't share", "There are no settings to clear"};
String titleGeolocation = StringHelper.ROBOCOP_GEOLOCATION_TITLE;
String url = getAbsoluteUrl(StringHelper.ROBOCOP_GEOLOCATION_URL);
loadCheckDismiss(shareStrings[1], url, shareStrings[0]);
checkOption(shareStrings[1], "Clear");
checkOption(shareStrings[3], "Cancel");
loadCheckDismiss(shareStrings[2], url, shareStrings[0]);
checkOption(shareStrings[2], "Cancel");
checkDevice(titleGeolocation);
}
public void clearPassword(){
String passwordStrings[] = {"Save password", "Save", "Don't save"};
String title = StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE;
String loginUrl = getAbsoluteUrl(StringHelper.ROBOCOP_LOGIN_URL);
loadCheckDismiss(passwordStrings[1], loginUrl, passwordStrings[0]);
checkOption(passwordStrings[1], "Clear");
loadCheckDismiss(passwordStrings[2], loginUrl, passwordStrings[0]);
checkDevice(title);
}
// clear private data and verify the device type because for phone there is an extra back action to exit the settings menu
public void checkDevice(String title) {
clearPrivateData();
if (mDevice.type.equals("phone")) {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mAsserter.ok(waitForText(StringHelper.PRIVACY_SECTION_LABEL), "waiting to perform one back", "one back");
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
verifyPageTitle(title);
}
else {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
verifyPageTitle(title);
}
}
// Load a URL, verify that the doorhanger appears and dismiss it
public void loadCheckDismiss(String option, String url, String message) {
inputAndLoadUrl(url);
waitForText(message);
mAsserter.is(mSolo.searchText(message), true, "Doorhanger:" + message + " has been displayed");
mSolo.clickOnButton(option);
mAsserter.is(mSolo.searchText(message), false, "Doorhanger:" + message + " has been hidden");
}
//Verify if there are settings to be clear if so clear them from the URL bar context menu
public void checkOption(String option, String button) {
final View toolbarView = mSolo.getView("browser_toolbar");
mSolo.clickLongOnView(toolbarView);
mAsserter.ok(waitForText(StringHelper.CONTEXT_MENU_ITEMS_IN_URL_BAR[2]), "Waiting for the pop-up to open", "Pop up was openend");
mSolo.clickOnText(StringHelper.CONTEXT_MENU_ITEMS_IN_URL_BAR[2]);
mAsserter.ok(waitForText(option), "Verify that the option: " + option + " is in the list", "The option is in the list. There are settings to clear");
mSolo.clickOnButton(button);
}
} }