Bug 838596 - Robocop: Add test for 'Master Password' feature. r=jmaher
authorpaul.feher@softvision.ro
Fri, 10 May 2013 10:56:53 +0300
changeset 133580 e9193d5774f402b27e14432084818887579c4959
parent 133579 40a7daac0e2c8145505b8ee2d4e79149024b54dc
child 133581 aa3f8a04c2fc87eeebec4605e149c5a28c744f3e
push id24757
push userryanvm@gmail.com
push dateFri, 31 May 2013 20:11:58 +0000
treeherdermozilla-central@2222b07ab207 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs838596
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 838596 - Robocop: Add test for 'Master Password' feature. r=jmaher
mobile/android/base/tests/robocop.ini
mobile/android/base/tests/testMasterPassword.java.in
--- a/mobile/android/base/tests/robocop.ini
+++ b/mobile/android/base/tests/robocop.ini
@@ -35,14 +35,15 @@
 # [testSystemPages] # see bug 869030
 # [testPermissions] # see bug 757475
 # [testJarReader] # see bug 738890
 [testDistribution]
 [testFindInPage]
 [testInputAwesomeBar]
 [testAddSearchEngine]
 [testImportFromAndroid]
+[testMasterPassword]
 
 # Used for Talos, please don't use in mochitest
 #[testPan]
 #[testCheck]
 #[testCheck2]
 #[testBrowserProviderPerf]
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/tests/testMasterPassword.java.in
@@ -0,0 +1,213 @@
+#filter substitution
+package @ANDROID_PACKAGE_NAME@.tests;
+
+import @ANDROID_PACKAGE_NAME@.*;
+
+/* 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
+        selectMenuItem("Settings");
+        if (dev.type.equals("tablet")) {
+            mSolo.waitForText("Privacy & Security");
+            mSolo.clickOnText("Privacy & Security");
+        }
+        mSolo.waitForText("^Use master password$");
+        mSolo.clickOnText("^Use master password$");
+        mSolo.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);
+        mSolo.waitForText("^Cancel$");
+        mSolo.clickOnText("^Cancel$");
+        mSolo.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(mSolo.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.waitForText("^Use master password$");
+        mSolo.clickOnText("^Use master password$");
+        mAsserter.ok(mSolo.searchText("Remove Master Password"), "Checking if the password is enabled", "The password is enabled");
+        closeTabletKeyboard();
+        mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Go back to settings menu
+        mSolo.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
+        selectMenuItem("Settings");
+        if (dev.type.equals("tablet")) {
+            mSolo.waitForText("Privacy & Security");
+            mSolo.clickOnText("Privacy & Security");
+        }
+        mSolo.waitForText("^Use master password$");
+        mSolo.clickOnText("^Use master password$");
+        mSolo.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$");
+        mSolo.waitForText("^Remove Master Password$");
+        closeTabletKeyboard();
+        editPasswordField(0, password);
+        mSolo.clickOnButton("OK");
+
+        // Verify that the Master Password was disabled
+        mSolo.waitForText("^Use master password$");
+        mSolo.clickOnText("^Use master password$");
+        mAsserter.ok(mSolo.waitForText("^Create Master Password$"), "Checking if the password is disabled", "The password is disabled");
+        mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the VKB
+        mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the Master Password menu
+    }
+
+    public void editPasswordField(int i, String password) {
+        mSolo.clickOnEditText(i);
+        mActions.sendKeys(password);
+        mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the VKB
+    }
+
+    public void noDoorhangerDisplayed(String LOGIN_URL) {
+        mSolo.waitForText("Browser Blank Page 01 | Enter Search or Address");
+        loadUrl(LOGIN_URL);
+        mAsserter.is(mSolo.waitForText("Save password for"), false, "Doorhanger notification is hidden");
+    }
+
+    public void doorhangerDisplayed(String LOGIN_URL) {
+        mSolo.waitForText("Browser Blank Page 01 | Enter Search or Address");
+        loadUrl(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);
+            mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the keyboard for tablets
+        }
+    }
+
+    public void clearPrivateData() {
+
+        // Look for the 'Settings' menu if this device/OS uses it
+        selectMenuItem("Settings");
+        if (dev.type.equals("tablet")) {
+            mSolo.waitForText("Privacy & Security");
+            mSolo.clickOnText("Privacy & Security");
+        }
+
+        // Clear private data
+        mSolo.waitForText("^Clear private data$");
+        mSolo.clickOnText("^Clear private data$");
+        mSolo.waitForText("^Clear data$");
+        mSolo.clickOnText("^Clear data$");
+        mAsserter.ok(mSolo.waitForText("^Private data cleared$"), "Waiting for private data to be cleared", "Private data is cleared");
+
+        // Check that the Master Password isn't disabled by clearing private data
+        mSolo.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");
+        closeTabletKeyboard();
+        mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the Master Password menu
+        mSolo.waitForText("^Settings$");
+        mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the Settings Menu
+    }
+
+    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")) {
+                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
+                mSolo.clickOnButton(item);
+                doorhangerDisplayed(LOGIN_URL);// Check that the doorhanger is displayed again
+                mSolo.clickOnButton(item);
+                mSolo.waitForText("Browser Blank Page 01");
+            }
+        }
+    }
+}