Skip to content

Commit

Permalink
Merge pull request #6273 from grzesiek2010/COLLECT-6266
Browse files Browse the repository at this point in the history
Fixed hiding error in external widgets
  • Loading branch information
seadowg authored Jul 22, 2024
2 parents 8dcf4f9 + 6649c62 commit b44e199
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ private void onException(String toastText) {

@Override
public void hideError() {
super.hideError();
binding.widgetAnswerText.setError(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public abstract class QuestionWidget extends FrameLayout implements Widget {
private final View guidanceTextLayout;
private final View textLayout;
private final TextView warningText;
protected final View errorLayout;
public final View errorLayout;
protected final Settings settings;
private AtomicBoolean expanded;
protected final ThemeUtils themeUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static junit.framework.Assert.assertTrue;

import android.view.View;
import android.widget.TextView;

import org.javarosa.core.model.data.IAnswerData;
import org.junit.Test;
Expand All @@ -11,6 +12,7 @@
import org.odk.collect.android.widgets.ExStringWidget;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -64,6 +66,26 @@ public void widgetShouldBeRegisteredForContextMenu() {
assertThat(viewsRegisterForContextMenu.get(1).getId(), is(widget.getId()));
}

@Test
public void errorDisappearsOnSetData() {
ExStringWidget widget = getWidget();
widget.displayError("blah");
widget.setData("answer");

assertThat(widget.errorLayout.getVisibility(), equalTo(TextView.GONE));
assertThat(widget.getBackground(), equalTo(null));
}

@Test
public void errorDisappearsOnAddingAnswerManuallyViaTheTextField() {
ExStringWidget widget = getWidget();
widget.displayError("blah");
widget.binding.widgetAnswerText.getBinding().editText.setText("answer");

assertThat(widget.errorLayout.getVisibility(), equalTo(TextView.GONE));
assertThat(widget.getBackground(), equalTo(null));
}

@Test
public abstract void verifyInputType();
}

0 comments on commit b44e199

Please sign in to comment.