Search in sources :

Example 1 with WidgetTestActivity

use of org.odk.collect.android.support.WidgetTestActivity in project collect by opendatakit.

the class RangeWidgetUtilsTest method clickingPickerButton_showsNumberPickerDialog.

@Test
public void clickingPickerButton_showsNumberPickerDialog() {
    WidgetTestActivity activity = CollectHelpers.createThemedActivity(WidgetTestActivity.class);
    RangeWidgetUtils.showNumberPickerDialog(activity, new String[] {}, 0, 0);
    RobolectricHelpers.runLooper();
    NumberPickerDialog numberPickerDialog = (NumberPickerDialog) activity.getSupportFragmentManager().findFragmentByTag(NumberPickerDialog.NUMBER_PICKER_DIALOG_TAG);
    assertNotNull(numberPickerDialog);
}
Also used : WidgetTestActivity(org.odk.collect.android.support.WidgetTestActivity) NumberPickerDialog(org.odk.collect.android.fragments.dialogs.NumberPickerDialog) Test(org.junit.Test)

Example 2 with WidgetTestActivity

use of org.odk.collect.android.support.WidgetTestActivity in project collect by opendatakit.

the class GeneralStringWidgetTest method widgetShouldBeRegisteredForContextMenu.

/**
 * Unlike other widgets, String widgets that contain EditText should not be registered to
 * context menu as a whole because the Clipboard menu would be broken.
 *
 * https://github.com/getodk/collect/pull/4860
 */
@Test
public void widgetShouldBeRegisteredForContextMenu() {
    StringWidget widget = createWidget();
    List<View> viewsRegisterForContextMenu = ((WidgetTestActivity) activity).viewsRegisterForContextMenu;
    assertThat(viewsRegisterForContextMenu.size(), is(3));
    assertTrue(viewsRegisterForContextMenu.contains(widget.findViewWithTag(R.id.question_label)));
    assertTrue(viewsRegisterForContextMenu.contains(widget.findViewWithTag(R.id.help_text)));
    assertTrue(viewsRegisterForContextMenu.contains(widget.findViewWithTag(R.id.space_box)));
    assertThat(viewsRegisterForContextMenu.get(0).getId(), is(widget.getId()));
    assertThat(viewsRegisterForContextMenu.get(1).getId(), is(widget.getId()));
    assertThat(viewsRegisterForContextMenu.get(2).getId(), is(widget.getId()));
}
Also used : WidgetTestActivity(org.odk.collect.android.support.WidgetTestActivity) StringWidget(org.odk.collect.android.widgets.StringWidget) View(android.view.View) Test(org.junit.Test)

Example 3 with WidgetTestActivity

use of org.odk.collect.android.support.WidgetTestActivity in project collect by opendatakit.

the class GeneralExStringWidgetTest method widgetShouldBeRegisteredForContextMenu.

/**
 * Unlike other widgets, String widgets that contain EditText should not be registered to
 * context menu as a whole because the Clipboard menu would be broken.
 *
 * https://github.com/getodk/collect/pull/4860
 */
@Test
public void widgetShouldBeRegisteredForContextMenu() {
    StringWidget widget = createWidget();
    List<View> viewsRegisterForContextMenu = ((WidgetTestActivity) activity).viewsRegisterForContextMenu;
    assertThat(viewsRegisterForContextMenu.size(), is(3));
    assertTrue(viewsRegisterForContextMenu.contains(widget.findViewWithTag(R.id.question_label)));
    assertTrue(viewsRegisterForContextMenu.contains(widget.findViewWithTag(R.id.help_text)));
    assertTrue(viewsRegisterForContextMenu.contains(widget.findViewWithTag(R.id.space_box)));
    assertThat(viewsRegisterForContextMenu.get(0).getId(), is(widget.getId()));
    assertThat(viewsRegisterForContextMenu.get(1).getId(), is(widget.getId()));
    assertThat(viewsRegisterForContextMenu.get(2).getId(), is(widget.getId()));
}
Also used : WidgetTestActivity(org.odk.collect.android.support.WidgetTestActivity) ExStringWidget(org.odk.collect.android.widgets.ExStringWidget) StringWidget(org.odk.collect.android.widgets.StringWidget) View(android.view.View) Test(org.junit.Test)

Example 4 with WidgetTestActivity

use of org.odk.collect.android.support.WidgetTestActivity in project collect by opendatakit.

the class QuestionWidgetTest method widgetShouldBeRegisteredForContextMenu.

// The whole widget should be registered for context menu to support removing answers/groups
@Test
public void widgetShouldBeRegisteredForContextMenu() {
    QuestionWidget widget = (QuestionWidget) createWidget();
    List<View> viewsRegisterForContextMenu = ((WidgetTestActivity) activity).viewsRegisterForContextMenu;
    assertThat(viewsRegisterForContextMenu.size(), is(1));
    assertThat(viewsRegisterForContextMenu.get(0), is(widget));
}
Also used : WidgetTestActivity(org.odk.collect.android.support.WidgetTestActivity) QuestionWidget(org.odk.collect.android.widgets.QuestionWidget) View(android.view.View) Test(org.junit.Test)

Example 5 with WidgetTestActivity

use of org.odk.collect.android.support.WidgetTestActivity in project collect by opendatakit.

the class QuestionWidgetTest method whenQuestionHasAudio_audioButtonUsesIndexAsClipID.

@Test
public void whenQuestionHasAudio_audioButtonUsesIndexAsClipID() throws Exception {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withIndex("i am index").withAudioURI("ref").build();
    WidgetTestActivity activity = CollectHelpers.createThemedActivity(WidgetTestActivity.class);
    TestWidget widget = new TestWidget(activity, new QuestionDetails(prompt));
    AudioButton audioButton = widget.getAudioVideoImageTextLabel().findViewById(R.id.audioButton);
    verify(audioHelper).setAudio(audioButton, new Clip("i am index", "blah.mp3"));
}
Also used : Clip(org.odk.collect.audioclips.Clip) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) WidgetTestActivity(org.odk.collect.android.support.WidgetTestActivity) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) QuestionDetails(org.odk.collect.android.formentry.questions.QuestionDetails) AudioButton(org.odk.collect.android.audio.AudioButton) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 WidgetTestActivity (org.odk.collect.android.support.WidgetTestActivity)5 View (android.view.View)3 StringWidget (org.odk.collect.android.widgets.StringWidget)2 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)1 AudioButton (org.odk.collect.android.audio.AudioButton)1 QuestionDetails (org.odk.collect.android.formentry.questions.QuestionDetails)1 NumberPickerDialog (org.odk.collect.android.fragments.dialogs.NumberPickerDialog)1 MockFormEntryPromptBuilder (org.odk.collect.android.support.MockFormEntryPromptBuilder)1 ExStringWidget (org.odk.collect.android.widgets.ExStringWidget)1 QuestionWidget (org.odk.collect.android.widgets.QuestionWidget)1 Clip (org.odk.collect.audioclips.Clip)1