RobotiumTech / robotium

Android UI Testing
http://www.robotium.org
Apache License 2.0
2.86k stars 786 forks source link

Clicking on Action bar in contextual action mode is not happening when menu item is not displayed #792

Open crocsoftware opened 9 years ago

crocsoftware commented 9 years ago

I have a menu with is displayed on context selected in a list. When I attempt to test it - if the menu is written like this

<item android:id="@+id/menu_copy"
          android:icon="@drawable/ic_menu_copy"
          android:title="@string/copy_diary_item"
          android:showAsAction="always"/>
    <item android:id="@+id/menu_add_to_favorites"
          android:icon="@drawable/ic_favorite_on"
          android:title="@string/add_to_favorites"
          android:showAsAction="ifRoom"/>
    <item android:id="@+id/menu_edit"
          android:icon="@android:drawable/ic_menu_edit"
          android:title="@string/edit_diary_item"
          android:showAsAction="always"/>
    <item android:id="@+id/menu_delete"
          android:icon="@android:drawable/ic_menu_delete"
          android:title="@string/delete_diary_data"
          android:showAsAction="always"/>

However , if the show as Action is "ifRoom" - the click was not made. The click is done VIA

solo.clickOnView(getActivity().findViewById(R.id.menu_copy));

I couldn't find any other way to make it work.