Bug 1400101 - [robocop] Find toolbar first and use it to find menu button. r?JanH,nechen draft
authorJing-wei Wu <topwu.tw@gmail.com>
Fri, 15 Sep 2017 15:58:10 +0800
changeset 665299 3572ff159e60e98ab3a1ba32d7f6e38600aaa67e
parent 665298 2916c33507aeb61b4432a6477dd52002e0e2a7ca
child 731725 c81b7bd4b0f95b174545b2000d6ecab78fc3c21d
push id80004
push userbmo:topwu.tw@gmail.com
push dateFri, 15 Sep 2017 07:59:45 +0000
reviewersJanH, nechen
bugs1400101
milestone57.0
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
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/AppMenuComponent.java
--- 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.
         mSolo.goBack();
     }
 
     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.