Bug 1400101 - [robocop] Find toolbar first and use it to find menu button. r=JanH,nechen
authorJing-wei Wu <topwu.tw@gmail.com>
Fri, 15 Sep 2017 15:58:10 +0800
changeset 665578 08d09442ab4b8efb8104b2ba0d6f4eee8818efb9
parent 665577 3baecf7b25f2d4a0d8cda5f773878a0f9d941ea5
child 665579 5500f432a88828303595de17bf31d127baa12ff9
push id80115
push userbmo:eoger@fastmail.com
push dateFri, 15 Sep 2017 18:29:01 +0000
reviewersJanH, nechen
Bug 1400101 - [robocop] Find toolbar first and use it to find menu button. r=JanH,nechen Sometimes Robocop is confused when are multiple `R.id.menu` UI components shown on screen, one is the menu button on toolbar and otehrs are context menus on Activity Stream. To access the menu on toolbar, a simple fix is access toolbar first and use it to find its child. MozReview-Commit-ID: Jw4sTLeR3li
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/AppMenuComponent.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/AppMenuComponent.java
@@ -15,16 +15,17 @@ import java.util.concurrent.Callable;
 import org.mozilla.gecko.AppConstants;
 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.RobotiumHelper;
 import org.mozilla.gecko.tests.helpers.WaitHelper;
+import org.mozilla.gecko.toolbar.BrowserToolbar;
 import android.text.TextUtils;
 import android.view.View;
 import android.widget.TextView;
 import android.widget.RelativeLayout;
 import com.robotium.solo.Condition;
 import com.robotium.solo.RobotiumUtils;
@@ -112,17 +113,18 @@ public class AppMenuComponent extends Ba
             fAssertFalse("The parent 'page' menu item is not enabled", parentMenuItemView.isEnabled());
             fAssertEquals("The parent 'page' menu item is visible", View.VISIBLE, parentMenuItemView.getVisibility());
         // Close the App Menu.
     private View getOverflowMenuButtonView() {
-        return mSolo.getView(R.id.menu);
+        final BrowserToolbar toolbar = (BrowserToolbar) mSolo.getView(R.id.browser_toolbar);
+        return toolbar.findViewById(R.id.menu);
      * Try to find a MenuItemActionBar/MenuItemDefault with the given text set as contentDescription / text.
      * When using legacy menus, make sure the menu has been opened to the appropriate level
      * (i.e. base menu or "More" menu) to ensure the appropriate menu views are in memory.
      * TODO: ^ Maybe we just need to have opened the "More" menu and the current one doesn't matter.