Bug 869123: Fix testShareLink to support submenu in 14+. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 29 May 2013 16:06:41 -0700
changeset 145464 d9eaa9f9b291bafaaf002fd05628c66fcd3e800f
parent 145463 055a2357e1a8ecc42456d6d1fd10f1c5b5a10acb
child 145465 02fd86cfa7ed231f1acdb23b9b872c2753fd2033
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs869123
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 869123: Fix testShareLink to support submenu in 14+. [r=mfinkle]
mobile/android/base/tests/testShareLink.java.in
--- a/mobile/android/base/tests/testShareLink.java.in
+++ b/mobile/android/base/tests/testShareLink.java.in
@@ -6,16 +6,17 @@ import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.widget.ListView;
 import android.view.View;
 import android.view.ViewGroup;
 import java.util.ArrayList;
 import java.util.List;
 import android.app.Activity;
+import android.os.Build;
 import android.util.DisplayMetrics;
 
 /**
  * This test covers the opening and content of the Share Link pop-up list
  * The test opens the Share menu from the app menu, the URL bar, a link context menu and the Awesomescreen tabs
  */
 public class testShareLink extends BaseTest {
     ListView list;
@@ -29,21 +30,26 @@ public class testShareLink extends BaseT
     public void testShareLink() {
         url = getAbsoluteUrl("/robocop/robocop_big_link.html");
         ArrayList<String> shareOptions;
         blockForGeckoReady();
 
         loadUrl(url);
         waitForText("Big Link"); // Waiting for page title to ensure the page is loaded
         selectMenuItem("Share");
-        waitForText("Share via");
+        if (Build.VERSION.SDK_INT >= 14) {
+            // Check for our own sync in the submenu.
+            waitForText("Sync$");
+        } else {
+            waitForText("Share via");
+        }
 
         // Get list of current avaliable share activities and verify them
         shareOptions = getShareOptions();
-        ArrayList<String> displayedOptions = getSharePopupOption();
+        ArrayList<String> displayedOptions = getShareOptionsList();
         for (String option:shareOptions) {
              // Verify if the option is present in the list of displayed share options
              mAsserter.ok(optionDisplayed(option, displayedOptions), "Share option found", option);
         }
 
         // Test share from the awesomebar context menu
         mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the share menu
         mSolo.clickLongOnText("Big Link");
@@ -142,16 +148,36 @@ public class testShareLink extends BaseT
                            }
                       }
                   }
              }
         }
         return displayedOptions;
     }
 
+    public ArrayList<String> getShareSubMenuOption() {
+        ArrayList<String> displayedOptions = new ArrayList();
+        ListView shareMenu = getDisplayedShareList();
+        for (int i = 0; i < shareMenu.getAdapter().getCount();i++) {
+             View shareItem = shareMenu.getAdapter().getView(i, null, null);
+             if (shareItem instanceof android.widget.TextView) {
+                 displayedOptions.add(((android.widget.TextView)shareItem).getText().toString());
+             }
+        }
+        return displayedOptions;
+    }
+
+    public ArrayList<String> getShareOptionsList() {
+        if (Build.VERSION.SDK_INT >= 14) {
+            return getShareSubMenuOption();
+        } else {
+            return getSharePopupOption();
+        }
+    }
+
     private boolean optionDisplayed(String shareOption, ArrayList<String> displayedOptions) {
         for (String displayedOption: displayedOptions) {
             if (shareOption.equals(displayedOption)) {
                 return true;
             }
         }
         return false;
     }