protected void openActionBarMenu() { openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getTargetContext()); } }
@Test public void signOutSuccessful() { doReturn(Observable.just(MockModelFabric.newRibotList(17))) .when(component.getMockDataManager()) .getRibots(); doReturn(Observable.empty()) .when(component.getMockDataManager()) .signOut(); main.launchActivity(MAIN_ACTIVITY_INTENT); openActionBarOverflowOrOptionsMenu(main.getActivity()); onView(withText(R.string.action_sign_out)) .perform(click()); // Check that sign in screen open after sign out. onView(withText(R.string.action_sign_in)) .check(matches(isDisplayed())); }
private void fromGameEndGame() { openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); ViewInteraction endGameMenuItem = onView( allOf(withId(R.id.title), withText("End Game"), childAtPosition( childAtPosition( withClassName(is("android.support.v7.view.menu.ListMenuItemView")), 0), 0), isDisplayed())); endGameMenuItem.perform(click()); }
/** * Clicks a menu item regardless if it is in the overflow menu or * visible as icon in the action bar * @param activity * @param name Name of the menu item in the overflow menu * @param resourceId Resource identifier of the menu item */ public static void clickMenuItem(Activity activity, String name, int resourceId) { try { onView(withId(resourceId)).perform(click()); } catch (NoMatchingViewException e) { openActionBarOverflowOrOptionsMenu(activity); //Use onData as item might not be visible in the View without scrolling onData(allOf( Matchers.withMenuTitle(name))) .perform(click()); } }
public void test000About() throws InterruptedException { openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getContext()); onView(allOf(withText("About"), isDisplayed())).perform(click()); Thread.sleep(1000); onView(withId(R.id.webViewAbout)).check(matches(isDisplayed())); onView(withId(R.id.webViewAbout)).perform(pressBack()); onView(withId(R.id.webViewAbout)).check(doesNotExist()); }
@Test public void logout() { try { Thread.sleep(2000); } catch (InterruptedException e) { ZLog.logException(e); } mActivityTestRule.getActivity().runOnUiThread(new Runnable() { @Override public void run() { mActivityTestRule.getActivity().showView(mActivityTestRule.getActivity().findViewById(R.id.appBarLayout)); } }); try { Thread.sleep(2000); } catch (InterruptedException e) { ZLog.logException(e); } //Open overflow menu openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); //Click Logout Button onView(withText(R.string.logout)).perform(click()); //Check API Key for verifying assertNull(ZulipApp.get().getApiKey()); }
@Test public void testOptionsMenuScreenshot() { String expectedScreenshot = Utility.getScreenshot(InstrumentationRegistry.getContext(), "options_menu_screenshot.txt"); sleep(1000); ViewInteraction ignoreViewsButton = onView( allOf(withId(R.id.sample_dialog), isDisplayed())); ignoreViewsButton.perform(scrollTo(), click()); openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); ViewInteraction captureButton = onView( allOf(withId(R.id.title), withText("capture 1"), isDisplayed())); captureButton.perform(click()); sleep(1500); ViewInteraction screenshotImageView = onView(allOf(withId(R.id.imageView), isDisplayed())); screenshotImageView.check(matches(withDrawable(expectedScreenshot))); }