src/androidTest/java/de/blau/android/search/ObjectSearchTest.java
/**
     * Search for a single object with a regexp
     */
Search for a single object with a regexp
Search for a single object with a regexp
@Test
    public void singleWithRegexp() {
        TestUtils.clickOverflowButton(device);
        TestUtils.clickText(device, false, main.getString(R.string.search_objects_title), true, false);
        UiObject checkbox = device.findObject(new UiSelector().clickable(true).resourceId(device.getCurrentPackageName() + ":id/checkbox"));
        try {
            checkbox.click();
        } catch (UiObjectNotFoundException e) {
            Assert.fail(e.getMessage());
        }
        UiObject searchEditText = device.findObject(new UiSelector().clickable(true).resourceId(device.getCurrentPackageName() + ":id/text_line_edit"));
        try {
            searchEditText.click();
            searchEditText.setText("\"addr:str.et\"=Kirchstra.*se \"addr:hous.*umber\"=4");
        } catch (UiObjectNotFoundException e) {
            Assert.fail(e.getMessage());
        }
        TestUtils.clickButton(device, "android:id/button1", true);
        TestUtils.findText(device, false, main.getString(R.string.actionmode_wayselect), 5000);
        List<OsmElement> selected = logic.getSelectedElements();
        Assert.assertEquals(1, selected.size());
        Assert.assertTrue(selected.get(0) instanceof Way);
        Assert.assertEquals(210558045L, selected.get(0).getOsmId());
    }
@ Test public void singleWithRegexp ( ) { TestUtils . clickOverflowButton ( device ) ; TestUtils . clickText ( device , false , main . getString ( R . string . search_objects_title ) , true , false ) ; UiObject checkbox = device . findObject ( new UiSelector ( ) . clickable ( true ) . resourceId ( device . getCurrentPackageName ( ) + ":id/checkbox" ) ) ; try { checkbox . click ( ) ; } catch ( UiObjectNotFoundException e ) { Assert . fail ( e . getMessage ( ) ) ; } UiObject searchEditText = device . findObject ( new UiSelector ( ) . clickable ( true ) . resourceId ( device . getCurrentPackageName ( ) + ":id/text_line_edit" ) ) ; try { searchEditText . click ( ) ; searchEditText . setText ( "\"addr:str.et\"=Kirchstra.*se \"addr:hous.*umber\"=4" ) ; } catch ( UiObjectNotFoundException e ) { Assert . fail ( e . getMessage ( ) ) ; } TestUtils . clickButton ( device , "android:id/button1" , true ) ; TestUtils . findText ( device , false , main . getString ( R . string . actionmode_wayselect ) , 5000 ) ; List < OsmElement > selected = logic . getSelectedElements ( ) ; Assert . assertEquals ( 1 , selected . size ( ) ) ; Assert . assertTrue ( selected . get ( 0 ) instanceof Way ) ; Assert . assertEquals ( 210558045L , selected . get ( 0 ) . getOsmId ( ) ) ; }
Search for a single object with a regexp
Search for a single object with a regexp