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.
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.