Bug 1085837 - Fix robocop testAppMenuPathways on Android 2.3; r=mcomella
authorGeoff Brown <gbrown@mozilla.com>
Fri, 19 Dec 2014 09:22:07 -0700
changeset 220548 aa47abc628177532902370efe0e7782e9141afe8
parent 220547 73b2de63fc8d9122bf8f108102459885ef596d04
child 220549 73dbbfed2b308b9ded17da84b68aacc44a8738a7
push id53133
push usergbrown@mozilla.com
push dateFri, 19 Dec 2014 16:22:24 +0000
treeherdermozilla-inbound@73dbbfed2b30 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1085837
milestone37.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 1085837 - Fix robocop testAppMenuPathways on Android 2.3; r=mcomella
mobile/android/base/tests/components/AppMenuComponent.java
--- a/mobile/android/base/tests/components/AppMenuComponent.java
+++ b/mobile/android/base/tests/components/AppMenuComponent.java
@@ -15,16 +15,17 @@ import org.mozilla.gecko.R;
 import org.mozilla.gecko.menu.MenuItemActionBar;
 import org.mozilla.gecko.menu.MenuItemDefault;
 import org.mozilla.gecko.tests.UITestContext;
 import org.mozilla.gecko.tests.helpers.DeviceHelper;
 import org.mozilla.gecko.tests.helpers.WaitHelper;
 import org.mozilla.gecko.util.HardwareUtils;
 
 import android.view.View;
+import android.widget.TextView;
 
 import com.jayway.android.robotium.solo.Condition;
 import com.jayway.android.robotium.solo.RobotiumUtils;
 import com.jayway.android.robotium.solo.Solo;
 
 /**
  * A class representing any interactions that take place on the app menu.
  */
@@ -169,16 +170,28 @@ public class AppMenuComponent extends Ba
 
         final List<MenuItemDefault> menuItemDefaultList = RobotiumUtils.filterViews(MenuItemDefault.class, views);
         for (MenuItemDefault menuItem : menuItemDefaultList) {
             if (menuItem.getText().equals(text)) {
                 return menuItem;
             }
         }
 
+        // On Android 2.3, menu items may be instances of
+        // com.android.internal.view.menu.ListMenuItemView, each with a child
+        // android.widget.RelativeLayout which in turn has a child
+        // TextView with the appropriate text.
+        final List<TextView> textViewList = RobotiumUtils.filterViews(TextView.class, views);
+        for (TextView textView : textViewList) {
+            if (textView.getText().equals(text)) {
+                View relativeLayout = (View) textView.getParent();
+                View listMenuItemView = (View)relativeLayout.getParent();
+                return listMenuItemView;
+            }
+        }
         return null;
     }
 
     /**
      * Helper function to let Robotium locate and click menu item from legacy Android menu (devices with Android 2.x).
      *
      * Robotium will also try to open the menu if there are no open dialog.
      *