forked from getodk/collect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for search appearance/function over CSVs
- Loading branch information
1 parent
78b629b
commit 33d66af
Showing
8 changed files
with
165 additions
and
13 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
collect_app/src/androidTest/assets/forms/external-csv-search-produce.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name,label | ||
artichoke,Artichoke | ||
apple,Apple | ||
banana,Banana | ||
blueberry,Blueberry | ||
cherimoya,Cherimoya | ||
carrot,Carrot |
41 changes: 41 additions & 0 deletions
41
collect_app/src/androidTest/assets/forms/external-csv-search.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0"?> | ||
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:odk="http://www.opendatakit.org/xforms" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<h:head> | ||
<h:title>external-csv-search</h:title> | ||
<model> | ||
<instance> | ||
<external-csv-search id="external-csv-search"> | ||
<multi_produce/> | ||
<produce_search/> | ||
<produce/> | ||
<meta> | ||
<instanceID/> | ||
</meta> | ||
</external-csv-search> | ||
</instance> | ||
<bind nodeset="/external-csv-search/multi_produce" type="select"/> | ||
<bind nodeset="/external-csv-search/produce_search" type="string"/> | ||
<bind nodeset="/external-csv-search/produce" type="select1"/> | ||
<bind calculate="concat('uuid:', uuid())" nodeset="/external-csv-search/meta/instanceID" readonly="true()" type="string"/> | ||
</model> | ||
</h:head> | ||
<h:body> | ||
<select appearance="search('external-csv-search-produce')" ref="/external-csv-search/multi_produce"> | ||
<label>Multiple produce</label> | ||
<item> | ||
<label>label</label> | ||
<value>name</value> | ||
</item> | ||
</select> | ||
<input ref="/external-csv-search/produce_search"> | ||
<label>Produce search</label> | ||
</input> | ||
<select1 appearance="search('external-csv-search-produce', 'contains', 'name', /external-csv-search/produce_search )" ref="/external-csv-search/produce"> | ||
<label>Produce</label> | ||
<item> | ||
<label>label</label> | ||
<value>name</value> | ||
</item> | ||
</select1> | ||
</h:body> | ||
</h:html> |
82 changes: 82 additions & 0 deletions
82
...ect_app/src/androidTest/java/org/odk/collect/android/formentry/ExternalCsvSearchTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package org.odk.collect.android.formentry; | ||
|
||
import android.Manifest; | ||
|
||
import androidx.test.espresso.intent.rule.IntentsTestRule; | ||
import androidx.test.rule.GrantPermissionRule; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.odk.collect.android.activities.FormEntryActivity; | ||
import org.odk.collect.android.test.FormLoadingUtils; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
|
||
import static androidx.test.espresso.Espresso.onView; | ||
import static androidx.test.espresso.action.ViewActions.replaceText; | ||
import static androidx.test.espresso.action.ViewActions.swipeLeft; | ||
import static androidx.test.espresso.action.ViewActions.swipeRight; | ||
import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; | ||
import static androidx.test.espresso.assertion.ViewAssertions.matches; | ||
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withClassName; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.CoreMatchers.endsWith; | ||
|
||
public class ExternalCsvSearchTest { | ||
private static final String EXTERNAL_CSV_SEARCH_FORM = "external-csv-search.xml"; | ||
|
||
@Rule | ||
public IntentsTestRule<FormEntryActivity> activityTestRule = FormLoadingUtils.getFormActivityTestRuleFor(EXTERNAL_CSV_SEARCH_FORM); | ||
|
||
@Rule | ||
public GrantPermissionRule permissionRule = GrantPermissionRule.grant( | ||
Manifest.permission.READ_EXTERNAL_STORAGE, | ||
Manifest.permission.WRITE_EXTERNAL_STORAGE); | ||
|
||
@BeforeClass | ||
public static void copyFormToSdCard() throws IOException { | ||
FormLoadingUtils.copyFormToSdCard(EXTERNAL_CSV_SEARCH_FORM, "forms", | ||
Collections.singletonList("external-csv-search-produce.csv")); | ||
} | ||
|
||
@Test | ||
public void simpleSearchStatement_ShouldDisplayAllCsvChoices() { | ||
onView(withText("Multiple produce")).check(matches(isDisplayed())); | ||
|
||
onView(withText("Artichoke")).check(matches(isDisplayed())); | ||
onView(withText("Apple")).check(matches(isDisplayed())); | ||
onView(withText("Banana")).check(matches(isDisplayed())); | ||
onView(withText("Blueberry")).check(matches(isDisplayed())); | ||
onView(withText("Cherimoya")).check(matches(isDisplayed())); | ||
onView(withText("Carrot")).check(matches(isDisplayed())); | ||
} | ||
|
||
@Test | ||
// Regression: https://github.com/opendatakit/collect/issues/3132 | ||
public void searchStatementWithContainsFilter_ShouldUpdateOnSearchChange() { | ||
onView(withText("Multiple produce")).perform(swipeLeft()); | ||
|
||
onView(withText("Produce search")).check(matches(isDisplayed())); | ||
onView(withClassName(endsWith("EditText"))).perform(replaceText("A")); | ||
onView(withText("Produce search")).perform(swipeLeft()); | ||
onView(withText("Artichoke")).check(matches(isDisplayed())); | ||
onView(withText("Apple")).check(matches(isDisplayed())); | ||
onView(withText("Banana")).check(matches(isDisplayed())); | ||
onView(withText("Blueberry")).check(doesNotExist()); | ||
onView(withText("Cherimoya")).check(matches(isDisplayed())); | ||
onView(withText("Carrot")).check(matches(isDisplayed())); | ||
|
||
onView(withText("Produce")).perform(swipeRight()); | ||
onView(withClassName(endsWith("EditText"))).perform(replaceText("B")); | ||
onView(withText("Produce search")).perform(swipeLeft()); | ||
onView(withText("Artichoke")).check(doesNotExist()); | ||
onView(withText("Apple")).check(doesNotExist()); | ||
onView(withText("Banana")).check(matches(isDisplayed())); | ||
onView(withText("Blueberry")).check(matches(isDisplayed())); | ||
onView(withText("Cherimoya")).check(doesNotExist()); | ||
onView(withText("Carrot")).check(doesNotExist()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters