TriggerWidget extends QuestionWidget { public CheckBox getCheckBox() { return triggerButton; } TriggerWidget(Context context, QuestionDetails prompt); @Override void clearAnswer(); @Override IAnswerData getAnswer(); @Override void setOnLongClickListener(OnLongClickListener l); @Override void cancelLongPress(); CheckBox getCheckBox();  }
@Test public void usingReadOnlyOption_makesAllClickableElementsDisabled() { TriggerWidget widget = createWidget(promptWithReadOnly()); assertThat(widget.getCheckBox().getVisibility(), equalTo(View.VISIBLE)); assertThat(widget.getCheckBox().isEnabled(), equalTo(Boolean.FALSE)); }
@Test public void whenPromptAnswerDoesNotHaveAnswer_checkboxIsUnchecked() { TriggerWidget widget = createWidget(promptWithAnswer(null)); assertThat(widget.getCheckBox().isChecked(), equalTo(false)); }
@Test public void whenPromptHasAnswer_checkboxIsChecked() { TriggerWidget widget = createWidget(promptWithAnswer(new StringData("OK"))); assertThat(widget.getCheckBox().isChecked(), equalTo(true)); }
@Test public void checkingCheckbox_callsValueChangeListeners() { TriggerWidget widget = createWidget(promptWithAnswer(null)); WidgetValueChangedListener valueChangedListener = mockValueChangedListener(widget); CheckBox triggerButton = widget.getCheckBox(); triggerButton.setChecked(true); verify(valueChangedListener).widgetValueChanged(widget); }