Bug 870056 - Enable robocop testClearPrivateData; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Wed, 08 May 2013 14:46:36 -0600
changeset 142246 c51eab92e5cb0da35865403dc248c02f8a35472f
parent 142245 a20ea0d494a049d68544cdc43973b5a515f55b59
child 142248 d517c04f97ec4e9606d756ff24a8f893122c9b32
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs870056
milestone23.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 870056 - Enable robocop testClearPrivateData; r=jmaher
mobile/android/base/tests/BaseTest.java.in
mobile/android/base/tests/robocop.ini
mobile/android/base/tests/testClearPrivateData.java.in
--- a/mobile/android/base/tests/BaseTest.java.in
+++ b/mobile/android/base/tests/BaseTest.java.in
@@ -46,16 +46,17 @@ abstract class BaseTest extends Activity
     protected Solo mSolo;
     protected Driver mDriver;
     protected Assert mAsserter;
     protected Actions mActions;
     protected String mBaseUrl;
     protected String mRawBaseUrl;
     private String mLogFile;
     protected String mProfile;
+    public Device mDevice;
 
     protected void blockForGeckoReady() {
         try {
             Actions.EventExpecter geckoReadyExpector = mActions.expectGeckoEvent("Gecko:Ready");
             ClassLoader classLoader = getActivity().getClassLoader();
             Class appsCls = classLoader.loadClass("org.mozilla.gecko.GeckoThread");
             Class launchStateCls = classLoader.loadClass("org.mozilla.gecko.GeckoThread$LaunchState");
             Method checkLaunchState =  appsCls.getMethod("checkLaunchState", launchStateCls);
@@ -114,16 +115,17 @@ abstract class BaseTest extends Activity
             mAsserter = new FennecMochitestAssert();
         }
         mAsserter.setLogFile(mLogFile);
         mAsserter.setTestName(this.getClass().getName());
         // Set up Robotium.solo and Driver objects
         mSolo = new Solo(getInstrumentation(), mActivity);
         mDriver = new FennecNativeDriver(mActivity, mSolo, rootPath);
         mActions = new FennecNativeActions(mActivity, mSolo, getInstrumentation(), mAsserter);
+        mDevice = new Device();
     }
 
     @Override
     protected void runTest() throws Throwable {
         try {
             super.runTest();
         } catch (Throwable t) {
             // save screenshot -- written to /mnt/sdcard/Robotium-Screenshots
@@ -356,16 +358,35 @@ abstract class BaseTest extends Activity
         if (!rc) {
             // log out failed wait for diagnostic purposes only;
             // waitForText failures are sometimes expected/normal
             mAsserter.dumpLog("waitForText timeout on "+text);
         }
         return rc;
     }
 
+    /** 
+     * Select <item> from Menu > "Settings" > <section>
+     */
+    public void selectSettingsItem(String section, String item) {
+        String itemName = "^" + item + "$";
+        selectMenuItem("Settings");
+        // On tablets, settings are arranged in a hierarchy; if the item is not 
+        // in the first ("General") section, the section must be selected first.
+        if (mDevice.type.equals("tablet") && 
+            section != null &&
+            !section.equals("General")) {
+            String sectionName = "^" + section + "$";
+            waitForText(sectionName);
+            mSolo.clickOnText(sectionName);
+        }
+        waitForText(itemName);
+        mSolo.clickOnText(itemName);
+    }
+
     public final void selectMenuItem(String menuItemName) {
         // build the item name ready to be used
         String itemName = "^" + menuItemName + "$";
         mActions.sendSpecialKey(Actions.SpecialKey.MENU);
         if (waitForText(itemName)) {
             mSolo.clickOnText(itemName);
         } else {
             if (mSolo.searchText("(^More$|^Tools$)")) {
--- a/mobile/android/base/tests/robocop.ini
+++ b/mobile/android/base/tests/robocop.ini
@@ -23,17 +23,17 @@
 [testSearchSuggestions]
 # [testThumbnails] # see bug 813107
 [testAddonManager]
 [testHistory]
 [testVkbOverlap]
 # [testDoorHanger] # see bug 862493
 [testTabHistory]
 [testShareLink]
-# [testClearPrivateData] # see bug 862493
+[testClearPrivateData]
 # [testSettingsMenuItems] # see bug 843947
 [testSystemPages]
 # [testPermissions] # see bug 757475
 # [testJarReader] # see bug 738890
 [testDistribution]
 [testFindInPage]
 [testInputAwesomeBar]
 [testAddSearchEngine]
--- a/mobile/android/base/tests/testClearPrivateData.java.in
+++ b/mobile/android/base/tests/testClearPrivateData.java.in
@@ -12,34 +12,32 @@ public class testClearPrivateData extend
     }
 
     public void testClearPrivateData() {
         blockForGeckoReady();
         clearHistory();
     }
 
     private void clearHistory() {
-        // Loading a page so we are sure that there is at leats one history entry
+        // Loading a page so we are sure that there is at least one history entry
         String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
         loadAndPaint(url);
 
         // Checking that the history list is not empty
         ListView hList = getHistoryList("Today|Yesterday");
         mAsserter.ok(hList.getAdapter().getCount() > 0,"checking history exists","history exists");
 
         // Quit the awesomescreen
         mActions.sendSpecialKey(Actions.SpecialKey.BACK);
         waitForText("Browser Blank Page 01");
 
         // Clearing private data
-        selectMenuItem("Settings");
-        if (waitForText("^Clear private data$")) {
-            mSolo.clickOnText("^Clear private data$");
-        }
+        selectSettingsItem("Privacy & Security", "Clear private data");
         mAsserter.ok(mSolo.searchButton("Clear data"),"checking clear button","clear button exists");
         mSolo.clickOnButton("Clear data");
-        mAsserter.is(mSolo.waitForText("Private data cleared"),true,"private data cleared successfully");
+        // TODO: extra long wait here for bug 837274
+        mAsserter.is(mSolo.waitForText("Private data cleared", 0, 60000),true,"private data cleared successfully");
 
         // Checking that history list is empty
         hList = getHistoryList("History", 0);
         mAsserter.ok(hList != null,"checking history is cleared ","history is cleared");
     }
 }