Search in sources :

Example 1 with FakeWaitingForDataRegistry

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

the class ExDecimalWidgetTest method digitsAboveLimitOfFifteenShouldBeTruncatedFromRight.

@Test
public // This should never be possible because the EditText has a limit on it
void digitsAboveLimitOfFifteenShouldBeTruncatedFromRight() {
    Double eighteenDigitDouble = 9999999999999994.;
    String fifteenDigitString = "999999999999994";
    assertSame(15, fifteenDigitString.length());
    when(formEntryPrompt.getAnswerValue()).thenReturn(answerData);
    when(answerData.getValue()).thenReturn(eighteenDigitDouble);
    ExDecimalWidget exDecimalWidget = new ExDecimalWidget(activity, new QuestionDetails(formEntryPrompt), new FakeWaitingForDataRegistry(), stringRequester);
    assertThat(exDecimalWidget.getAnswerText(), is(equalTo(fifteenDigitString)));
    exDecimalWidget = new ExDecimalWidget(activity, new QuestionDetails(formEntryPrompt), new FakeWaitingForDataRegistry(), stringRequester);
    assertThat(exDecimalWidget.getAnswerText(), is(equalTo(fifteenDigitString)));
}
Also used : FakeWaitingForDataRegistry(org.odk.collect.android.widgets.support.FakeWaitingForDataRegistry) QuestionDetails(org.odk.collect.android.formentry.questions.QuestionDetails) GeneralExStringWidgetTest(org.odk.collect.android.widgets.base.GeneralExStringWidgetTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 QuestionDetails (org.odk.collect.android.formentry.questions.QuestionDetails)1 GeneralExStringWidgetTest (org.odk.collect.android.widgets.base.GeneralExStringWidgetTest)1 FakeWaitingForDataRegistry (org.odk.collect.android.widgets.support.FakeWaitingForDataRegistry)1