Search in sources :

Example 1 with RandomString

use of net.bytebuddy.utility.RandomString in project collect by opendatakit.

the class AllWidgetsFormTest method testStringWidget.

public void testStringWidget() {
    String stringWidgetText = randomString();
    onVisibleEditText().perform(replaceText(stringWidgetText));
    // captures screenshot of string widget
    Screengrab.screenshot("string-input");
    openWidgetList();
    onView(withText("String widget")).perform(click());
    onVisibleEditText().check(matches(withText(stringWidgetText)));
    onView(withText("String widget")).perform(swipeLeft());
}
Also used : RandomString(net.bytebuddy.utility.RandomString)

Example 2 with RandomString

use of net.bytebuddy.utility.RandomString in project collect by opendatakit.

the class AllWidgetsFormTest method testExStringWidget.

public void testExStringWidget() {
    // Manually input the value:
    String exStringWidgetFirstText = randomString();
    when(activityAvailability.isActivityAvailable(any(Intent.class))).thenReturn(false);
    onView(withText("Launch")).perform(click());
    onVisibleEditText().perform(replaceText(exStringWidgetFirstText));
    openWidgetList();
    onView(withText("Ex string widget")).perform(click());
    Screengrab.screenshot("ex-string");
    onVisibleEditText().check(matches(withText(exStringWidgetFirstText)));
    // Replace with Intent value:
    String exStringWidgetSecondText = randomString();
    Intent stringIntent = new Intent();
    stringIntent.putExtra("value", exStringWidgetSecondText);
    ActivityResult exStringResult = new ActivityResult(RESULT_OK, stringIntent);
    intending(allOf(hasAction("change.uw.android.BREATHCOUNT"), hasExtra("value", exStringWidgetFirstText))).respondWith(exStringResult);
    when(activityAvailability.isActivityAvailable(any(Intent.class))).thenReturn(true);
    onView(withText("Launch")).perform(click());
    onView(withText(exStringWidgetSecondText)).check(matches(isDisplayed()));
    Screengrab.screenshot("ex-string2");
    openWidgetList();
    onView(withText("Ex string widget")).perform(click());
    onVisibleEditText().check(matches(withText(exStringWidgetSecondText)));
    onView(withText("Ex string widget")).perform(swipeLeft());
}
Also used : Intent(android.content.Intent) RandomString(net.bytebuddy.utility.RandomString) ActivityResult(android.app.Instrumentation.ActivityResult)

Aggregations

RandomString (net.bytebuddy.utility.RandomString)2 ActivityResult (android.app.Instrumentation.ActivityResult)1 Intent (android.content.Intent)1