Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support default image answers #3579

Merged
merged 12 commits into from
Feb 12, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ protected void launchActivityForResult(Intent intent, final int resourceCode, fi
}
}

private File getFile() {
File getFile() {
lognaturel marked this conversation as resolved.
Show resolved Hide resolved
File file = new File(getInstanceFolder() + File.separator + binaryName);
if (!file.exists() && doesSupportDefaultValues()) {
file = new File(getDefaultFilePath());
Expand All @@ -318,7 +318,7 @@ private File getFile() {
return file;
}

private String getDefaultFilePath() {
String getDefaultFilePath() {
try {
return referenceManager.deriveReference(binaryName).getLocalURI();
} catch (InvalidReferenceException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,13 @@ public void usingReadOnlyOptionShouldMakeAllClickableElementsDisabled() {
assertThat(getWidget().chooseButton.getVisibility(), is(View.GONE));
assertThat(getWidget().annotateButton.getVisibility(), is(View.GONE));
}

@Test
public void defaultValuesShouldBeSupported() {
when(formEntryPrompt.getAnswerText()).thenReturn("jr://images/doc.png");
when(getWidget().getDefaultFilePath()).thenReturn("/samplePath/doc.png");

assertThat(getWidget().doesSupportDefaultValues(), is(true));
assertThat(getWidget().getFile().getPath(), is("/samplePath/doc.png"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,13 @@ public void usingReadOnlyOptionShouldMakeAllClickableElementsDisabled() {

assertThat(getWidget().drawButton.getVisibility(), is(View.GONE));
}

@Test
public void defaultValuesShouldBeSupported() {
when(formEntryPrompt.getAnswerText()).thenReturn("jr://images/doc.png");
when(getWidget().getDefaultFilePath()).thenReturn("/samplePath/doc.png");

assertThat(getWidget().doesSupportDefaultValues(), is(true));
assertThat(getWidget().getFile().getPath(), is("/samplePath/doc.png"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,12 @@ public void usingReadOnlyOptionShouldMakeAllClickableElementsDisabled() {
assertThat(getWidget().captureButton.getVisibility(), is(View.GONE));
assertThat(getWidget().chooseButton.getVisibility(), is(View.GONE));
}

@Test
public void defaultValuesShouldNotBeSupported() {
when(formEntryPrompt.getAnswerText()).thenReturn("jr://images/doc.png");

assertThat(getWidget().doesSupportDefaultValues(), is(false));
assertThat(getWidget().getFile().getPath(), is("/jr:/images/doc.png"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,13 @@ public void usingReadOnlyOptionShouldMakeAllClickableElementsDisabled() {

assertThat(getWidget().signButton.getVisibility(), is(View.GONE));
}

@Test
public void defaultValuesShouldBeSupported() {
when(formEntryPrompt.getAnswerText()).thenReturn("jr://images/doc.png");
when(getWidget().getDefaultFilePath()).thenReturn("/samplePath/doc.png");

assertThat(getWidget().doesSupportDefaultValues(), is(true));
assertThat(getWidget().getFile().getPath(), is("/samplePath/doc.png"));
}
}