Bug 1085837 - Fix robocop testAppMenuPathways on Android 2.3. r=mcomella, a=test-only
--- 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.
*