mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
4a207df851
--HG-- rename : build/mobile/robocop/Actions.java.in => build/mobile/robocop/Actions.java rename : build/mobile/robocop/Assert.java.in => build/mobile/robocop/Assert.java rename : build/mobile/robocop/Driver.java.in => build/mobile/robocop/Driver.java rename : build/mobile/robocop/Element.java.in => build/mobile/robocop/Element.java rename : build/mobile/robocop/FennecInstrumentationTestRunner.java.in => build/mobile/robocop/FennecInstrumentationTestRunner.java rename : build/mobile/robocop/FennecMochitestAssert.java.in => build/mobile/robocop/FennecMochitestAssert.java rename : build/mobile/robocop/FennecNativeActions.java.in => build/mobile/robocop/FennecNativeActions.java rename : build/mobile/robocop/FennecNativeDriver.java.in => build/mobile/robocop/FennecNativeDriver.java rename : build/mobile/robocop/FennecNativeElement.java.in => build/mobile/robocop/FennecNativeElement.java rename : build/mobile/robocop/FennecTalosAssert.java.in => build/mobile/robocop/FennecTalosAssert.java rename : build/mobile/robocop/PaintedSurface.java.in => build/mobile/robocop/PaintedSurface.java rename : build/mobile/robocop/RoboCopException.java.in => build/mobile/robocop/RoboCopException.java rename : build/mobile/robocop/RobocopUtils.java.in => build/mobile/robocop/RobocopUtils.java rename : mobile/android/base/tests/AboutHomeTest.java.in => mobile/android/base/tests/AboutHomeTest.java rename : mobile/android/base/tests/BaseTest.java.in => mobile/android/base/tests/BaseTest.java rename : mobile/android/base/tests/ContentContextMenuTest.java.in => mobile/android/base/tests/ContentContextMenuTest.java rename : mobile/android/base/tests/ContentProviderTest.java.in => mobile/android/base/tests/ContentProviderTest.java rename : mobile/android/base/tests/DatabaseHelper.java.in => mobile/android/base/tests/DatabaseHelper.java rename : mobile/android/base/tests/JavascriptTest.java.in => mobile/android/base/tests/JavascriptTest.java rename : mobile/android/base/tests/MotionEventHelper.java.in => mobile/android/base/tests/MotionEventHelper.java rename : mobile/android/base/tests/MotionEventReplayer.java.in => mobile/android/base/tests/MotionEventReplayer.java rename : mobile/android/base/tests/PixelTest.java.in => mobile/android/base/tests/PixelTest.java rename : mobile/android/base/tests/StringHelper.java.in => mobile/android/base/tests/StringHelper.java rename : mobile/android/base/tests/testAboutPage.java.in => mobile/android/base/tests/testAboutPage.java rename : mobile/android/base/tests/testAddSearchEngine.java.in => mobile/android/base/tests/testAddSearchEngine.java rename : mobile/android/base/tests/testAddonManager.java.in => mobile/android/base/tests/testAddonManager.java rename : mobile/android/base/tests/testAwesomebar.java.in => mobile/android/base/tests/testAwesomebar.java rename : mobile/android/base/tests/testAwesomebarSwipes.java.in => mobile/android/base/tests/testAwesomebarSwipes.java rename : mobile/android/base/tests/testAxisLocking.java.in => mobile/android/base/tests/testAxisLocking.java rename : mobile/android/base/tests/testBookmark.java.in => mobile/android/base/tests/testBookmark.java rename : mobile/android/base/tests/testBookmarkFolders.java.in => mobile/android/base/tests/testBookmarkFolders.java rename : mobile/android/base/tests/testBookmarkKeyword.java.in => mobile/android/base/tests/testBookmarkKeyword.java rename : mobile/android/base/tests/testBookmarklets.java.in => mobile/android/base/tests/testBookmarklets.java rename : mobile/android/base/tests/testBookmarksPage.java.in => mobile/android/base/tests/testBookmarksPage.java rename : mobile/android/base/tests/testBrowserProvider.java.in => mobile/android/base/tests/testBrowserProvider.java rename : mobile/android/base/tests/testBrowserProviderPerf.java.in => mobile/android/base/tests/testBrowserProviderPerf.java rename : mobile/android/base/tests/testBrowserSearchVisibility.java.in => mobile/android/base/tests/testBrowserSearchVisibility.java rename : mobile/android/base/tests/testCheck.java.in => mobile/android/base/tests/testCheck.java rename : mobile/android/base/tests/testCheck2.java.in => mobile/android/base/tests/testCheck2.java rename : mobile/android/base/tests/testClearPrivateData.java.in => mobile/android/base/tests/testClearPrivateData.java rename : mobile/android/base/tests/testDeviceSearchEngine.java.in => mobile/android/base/tests/testDeviceSearchEngine.java rename : mobile/android/base/tests/testDistribution.java.in => mobile/android/base/tests/testDistribution.java rename : mobile/android/base/tests/testDoorHanger.java.in => mobile/android/base/tests/testDoorHanger.java rename : mobile/android/base/tests/testFindInPage.java.in => mobile/android/base/tests/testFindInPage.java rename : mobile/android/base/tests/testFlingCorrectness.java.in => mobile/android/base/tests/testFlingCorrectness.java rename : mobile/android/base/tests/testFormHistory.java.in => mobile/android/base/tests/testFormHistory.java rename : mobile/android/base/tests/testGetUserMedia.java.in => mobile/android/base/tests/testGetUserMedia.java rename : mobile/android/base/tests/testHistory.java.in => mobile/android/base/tests/testHistory.java rename : mobile/android/base/tests/testHomeBanner.java.in => mobile/android/base/tests/testHomeBanner.java rename : mobile/android/base/tests/testImportFromAndroid.java.in => mobile/android/base/tests/testImportFromAndroid.java rename : mobile/android/base/tests/testInputUrlBar.java.in => mobile/android/base/tests/testInputUrlBar.java rename : mobile/android/base/tests/testJNI.java.in => mobile/android/base/tests/testJNI.java rename : mobile/android/base/tests/testJarReader.java.in => mobile/android/base/tests/testJarReader.java rename : mobile/android/base/tests/testLinkContextMenu.java.in => mobile/android/base/tests/testLinkContextMenu.java rename : mobile/android/base/tests/testLoad.java.in => mobile/android/base/tests/testLoad.java rename : mobile/android/base/tests/testMailToContextMenu.java.in => mobile/android/base/tests/testMailToContextMenu.java rename : mobile/android/base/tests/testMasterPassword.java.in => mobile/android/base/tests/testMasterPassword.java rename : mobile/android/base/tests/testNewTab.java.in => mobile/android/base/tests/testNewTab.java rename : mobile/android/base/tests/testOrderedBroadcast.java.in => mobile/android/base/tests/testOrderedBroadcast.java rename : mobile/android/base/tests/testOverscroll.java.in => mobile/android/base/tests/testOverscroll.java rename : mobile/android/base/tests/testPan.java.in => mobile/android/base/tests/testPan.java rename : mobile/android/base/tests/testPanCorrectness.java.in => mobile/android/base/tests/testPanCorrectness.java rename : mobile/android/base/tests/testPasswordEncrypt.java.in => mobile/android/base/tests/testPasswordEncrypt.java rename : mobile/android/base/tests/testPasswordProvider.java.in => mobile/android/base/tests/testPasswordProvider.java rename : mobile/android/base/tests/testPermissions.java.in => mobile/android/base/tests/testPermissions.java rename : mobile/android/base/tests/testPictureLinkContextMenu.java.in => mobile/android/base/tests/testPictureLinkContextMenu.java rename : mobile/android/base/tests/testPrefsObserver.java.in => mobile/android/base/tests/testPrefsObserver.java rename : mobile/android/base/tests/testPrivateBrowsing.java.in => mobile/android/base/tests/testPrivateBrowsing.java rename : mobile/android/base/tests/testPromptGridInput.java.in => mobile/android/base/tests/testPromptGridInput.java rename : mobile/android/base/tests/testReaderMode.java.in => mobile/android/base/tests/testReaderMode.java rename : mobile/android/base/tests/testSearchSuggestions.java.in => mobile/android/base/tests/testSearchSuggestions.java rename : mobile/android/base/tests/testSettingsMenuItems.java.in => mobile/android/base/tests/testSettingsMenuItems.java rename : mobile/android/base/tests/testShareLink.java.in => mobile/android/base/tests/testShareLink.java rename : mobile/android/base/tests/testSharedPreferences.java.in => mobile/android/base/tests/testSharedPreferences.java rename : mobile/android/base/tests/testSystemPages.java.in => mobile/android/base/tests/testSystemPages.java rename : mobile/android/base/tests/testTabHistory.java.in => mobile/android/base/tests/testTabHistory.java rename : mobile/android/base/tests/testThumbnails.java.in => mobile/android/base/tests/testThumbnails.java rename : mobile/android/base/tests/testVkbOverlap.java.in => mobile/android/base/tests/testVkbOverlap.java rename : mobile/android/base/tests/test_bug720538.java.in => mobile/android/base/tests/test_bug720538.java extra : rebase_source : c8d715aa110b07c6010054a674879e143a5f04e7 extra : amend_source : fb5714b78e055e336b5e0c6a0da8eb8c931ff09e extra : histedit_source : ec57d8ba94000092438a2ba0bf4fb66091e98513%2C114ade72bb9b72b96557da74f1179734fa347e5c
222 lines
11 KiB
Java
222 lines
11 KiB
Java
package org.mozilla.gecko.tests;
|
|
|
|
import org.mozilla.gecko.*;
|
|
|
|
/* This patch tests the Master Password feature first by enabling the password,
|
|
then testing it on a login page and finally disabling the password */
|
|
public class testMasterPassword extends PixelTest {
|
|
Device dev;
|
|
|
|
@Override
|
|
protected int getTestType() {
|
|
return TEST_MOCHITEST;
|
|
}
|
|
|
|
public void testMasterPassword() {
|
|
blockForGeckoReady();
|
|
|
|
dev = new Device();
|
|
String password = ("Good");
|
|
String badPassword = ("Bad");
|
|
|
|
enableMasterPassword(password, badPassword);
|
|
verifyLoginPage(password, badPassword);
|
|
disableMasterPassword(password, badPassword);
|
|
}
|
|
|
|
public void enableMasterPassword(String password, String badPassword) {
|
|
|
|
// Look for the 'Settings' menu if this device/OS uses it
|
|
selectSettingsItem("Privacy", "Use master password");
|
|
waitForText("^Create Master Password$");
|
|
|
|
// Verify that the OK button is not activated until both fields are filled
|
|
closeTabletKeyboard();
|
|
mAsserter.ok(!mSolo.getButton("OK").isEnabled(), "Verify if the OK button is inactive", "The OK button is inactive until both fields are filled");
|
|
|
|
// Verify that the OK button is not activated until the Confirm password field is filled
|
|
editPasswordField(0, password);
|
|
mAsserter.ok(!mSolo.getButton("OK").isEnabled(), "Verify if the OK button is inactive", "The OK button is inactive until the Confirm password field is filled");
|
|
|
|
// Verify that the OK button is not activated until both fields contain the same password
|
|
editPasswordField(1, badPassword);
|
|
mAsserter.ok(!mSolo.getButton("OK").isEnabled(), "Verify if the OK button is inactive", "The OK button is inactive until both fields contain the same password");
|
|
|
|
// Verify that the OK button is not activated until the Password field is filled
|
|
mSolo.clearEditText(0);
|
|
mAsserter.ok(!mSolo.getButton("OK").isEnabled(), "Verify if the OK button is inactive", "The OK button is inactive until the Password field is filled");
|
|
|
|
// Check that the Master Password is not set when canceling the action
|
|
mSolo.clickOnEditText(0);
|
|
mActions.sendKeys(password);
|
|
mSolo.clearEditText(1);
|
|
mSolo.clickOnEditText(1);
|
|
mActions.sendKeys(password);
|
|
waitForText("^Cancel$");
|
|
mSolo.clickOnText("^Cancel$");
|
|
waitForText("^Use master password$");
|
|
mSolo.clickOnText("^Use master password$");
|
|
mAsserter.ok(mSolo.waitForText("^Create Master Password$"), "Checking if no password was set if the action was canceled", "No password was set");
|
|
|
|
// Enable Master Password
|
|
mSolo.clickOnEditText(0);
|
|
mActions.sendKeys(password);
|
|
mSolo.clickOnEditText(1);
|
|
mActions.sendKeys(password);
|
|
|
|
// Verify that the input characters are converted to dots automatically
|
|
mAsserter.ok(waitForText("."), "waiting to convert the letters in dots", "The letters are converted in dots");
|
|
mSolo.clickOnButton("OK");
|
|
|
|
// Verify that the Master Password was set
|
|
mSolo.searchText("Privacy");
|
|
mAsserter.ok(mSolo.waitForText("^Use master password$"), "Checking if Use master password is present", "Use master password is present");
|
|
mSolo.clickOnText("^Use master password$");
|
|
mAsserter.ok(mSolo.waitForText("Remove Master Password"), "Checking if the password is enabled", "The password is enabled");
|
|
clickOnButton("Cancel"); // Go back to settings menu
|
|
|
|
if ("phone".equals(mDevice.type)) {
|
|
// Phones don't have headers like tablets, so we need to pop up one more level.
|
|
waitForText("Use master password");
|
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
|
}
|
|
waitForText("Settings");
|
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the Settings Menu
|
|
}
|
|
|
|
public void disableMasterPassword(String password, String badPassword) {
|
|
|
|
// Look for the 'Settings' menu if this device/OS uses it
|
|
selectSettingsItem("Privacy", "Use master password");
|
|
waitForText("^Remove Master Password$");
|
|
|
|
// Verify that the OK button is not activated if the password field is empty
|
|
closeTabletKeyboard();
|
|
mAsserter.ok(!mSolo.getButton("OK").isEnabled(), "Verify if the OK button is inactive", "The OK button is inactive if the password field is empty");
|
|
|
|
// Verify that the OK button is activated if the password field contains characters
|
|
editPasswordField(0, badPassword);
|
|
mAsserter.ok(mSolo.getButton("OK").isEnabled(), "Verify if the OK button is activated", "The OK button is activated even if the wrong password is filled");
|
|
mSolo.clickOnButton("OK");
|
|
mAsserter.ok(mSolo.waitForText("^Incorrect password$"), "Waiting for Incorrect password notification", "The Incorrect password notification appears");
|
|
|
|
// Disable Master Password
|
|
mSolo.clickOnText("^Use master password$");
|
|
waitForText("^Remove Master Password$");
|
|
closeTabletKeyboard();
|
|
editPasswordField(0, password);
|
|
mSolo.clickOnButton("OK");
|
|
|
|
// Verify that the Master Password was disabled
|
|
mSolo.searchText("Privacy");
|
|
mAsserter.ok(mSolo.waitForText("^Use master password$"), "Checking if Use master password is present", "Use master password is present");
|
|
mSolo.clickOnText("^Use master password$");
|
|
mAsserter.ok(waitForText("^Create Master Password$"), "Checking if the password is disabled", "The password is disabled");
|
|
clickOnButton("Cancel"); // Go back to settings menu
|
|
}
|
|
|
|
public void editPasswordField(int i, String password) {
|
|
mSolo.clickOnEditText(i);
|
|
mActions.sendKeys(password);
|
|
toggleVKB(); // Don't use BACK; this will close the password dialog on devices with hardware keyboard.
|
|
}
|
|
|
|
public void noDoorhangerDisplayed(String LOGIN_URL) {
|
|
waitForText("Browser Blank Page 01|Enter Search or Address");
|
|
inputAndLoadUrl(LOGIN_URL);
|
|
mAsserter.is(waitForText("Save password for"), false, "Doorhanger notification is hidden");
|
|
}
|
|
|
|
public void doorhangerDisplayed(String LOGIN_URL) {
|
|
waitForText("Browser Blank Page 01|Enter Search or Address");
|
|
inputAndLoadUrl(LOGIN_URL);
|
|
mAsserter.is(mSolo.waitForText("Save password for"), true, "Doorhanger notification is displayed");
|
|
}
|
|
|
|
// Checks to see if the device is a Tablet, because for those devices we need an extra back action to close the keyboard
|
|
public void closeTabletKeyboard() {
|
|
if (dev.type.equals("tablet")) {
|
|
mSolo.sleep(1500);
|
|
toggleVKB();// Close the keyboard for tablets
|
|
}
|
|
}
|
|
|
|
public void clearPrivateData() {
|
|
|
|
// Look for the 'Settings' menu if this device/OS uses it
|
|
selectSettingsItem("Privacy", "Clear private data");
|
|
|
|
waitForText("Browsing & download history"); // Make sure the Clear private data pop-up is displayed
|
|
Actions.EventExpecter clearPrivateDataEventExpecter = mActions.expectGeckoEvent("Sanitize:Finished");
|
|
if (mSolo.searchText("Clear data") && !mSolo.searchText("Cookies")) {
|
|
mSolo.clickOnText("^Clear data$");
|
|
clearPrivateDataEventExpecter.blockForEvent();
|
|
} else { // For some reason the pop-up was not opened
|
|
if (mSolo.searchText("Cookies")) {
|
|
mSolo.clickOnText("^Clear private data$");
|
|
waitForText("Browsing & download history"); // Make sure the Clear private data pop-up is displayed
|
|
mSolo.clickOnText("^Clear data$");
|
|
clearPrivateDataEventExpecter.blockForEvent();
|
|
} else {
|
|
mAsserter.ok(false, "Something happened and the clear data dialog could not be opened", "Failed to clear data");
|
|
}
|
|
}
|
|
|
|
// Check that the Master Password isn't disabled by clearing private data
|
|
waitForText("^Use master password$");
|
|
mSolo.clickOnText("^Use master password$");
|
|
mAsserter.ok(mSolo.searchText("^Remove Master Password$"), "Checking if the master password was disabled by clearing private data", "The master password is not disabled by clearing private data");
|
|
clickOnButton("Cancel"); // Close the Master Password menu
|
|
|
|
if ("phone".equals(mDevice.type)) {
|
|
// Phones don't have headers like tablets, so we need to pop up one more level.
|
|
waitForText("Use master password");
|
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
|
}
|
|
waitForText("Settings");
|
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the Settings Menu
|
|
// Make sure the settings menu has been closed.
|
|
mAsserter.ok(mSolo.waitForText("Browser Blank Page 01"), "Waiting for blank browser page after exiting settings", "Blank browser page present");
|
|
}
|
|
|
|
public void verifyLoginPage(String password, String badPassword) {
|
|
String LOGIN_URL = getAbsoluteUrl("/robocop/robocop_login.html");
|
|
String option [] = {"Save", "Don't save"};
|
|
|
|
doorhangerDisplayed(LOGIN_URL);// Check that the doorhanger is displayed
|
|
for (String item:option) {
|
|
if (item.equals("Save")) {
|
|
mAsserter.ok(mSolo.waitForText("Save"), "Checking if Save option is present", "Save option is present");
|
|
mSolo.clickOnButton(item);
|
|
|
|
// Verify that the Master Password isn't deactivated when the password field is empty
|
|
closeTabletKeyboard();
|
|
mSolo.clickOnButton("OK");
|
|
|
|
// Verify that the Master Password isn't deactivated when using the wrong password
|
|
closeTabletKeyboard();
|
|
editPasswordField(0, badPassword);
|
|
mSolo.clickOnButton("OK");
|
|
|
|
// Verify that the Master Password is deactivated when using the right password
|
|
closeTabletKeyboard();
|
|
editPasswordField(0, password);
|
|
mSolo.clickOnButton("OK");
|
|
|
|
// Verify that the Master Password is triggered once per session
|
|
noDoorhangerDisplayed(LOGIN_URL);// Check that the doorhanger isn't displayed
|
|
} else {
|
|
clearPrivateData();
|
|
doorhangerDisplayed(LOGIN_URL);// Check that the doorhanger is displayed
|
|
mAsserter.ok(mSolo.waitForText("Don't save"), "Checking if Don't save option is present again", "Don't save option is present again");
|
|
mSolo.clickOnText("Don't save");
|
|
doorhangerDisplayed(LOGIN_URL);// Check that the doorhanger is displayed again
|
|
mAsserter.ok(mSolo.waitForText("Don't save"), "Checking if Don't save option is present again", "Don't save option is present again");
|
|
mSolo.clickOnText("Don't save");
|
|
// Make sure the settings menu has been closed.
|
|
mAsserter.ok(mSolo.waitForText("Browser Blank Page 01"), "Waiting for blank browser page after exiting settings", "Blank browser page present");
|
|
}
|
|
}
|
|
}
|
|
}
|