src/androidTest/java/de/blau/android/filter/TagFilterTest.java
/**
     * Enable tagfilter, add filter, click object, remove filter etc
     */
Enable tagfilter, add filter, click object, remove filter etc
Enable tagfilter add filter click object remove filter etc
@Test
    public void simpleTagTest() {
        TestUtils.unlock(device);
        Node t = (Node) App.getDelegator().getOsmElement(Node.NAME, 3465444349L);
        assertNotNull(t);
        assertTrue(t.hasTag("amenity", "toilets"));
        assertTrue(TestUtils.clickOverflowButton(device));
        assertTrue(TestUtils.clickText(device, false, main.getString(R.string.menu_enable_tagfilter), false));
        monitor = instrumentation.addMonitor(TagFilterActivity.class.getName(), null, false);
        assertTrue(TestUtils.clickResource(device, false, device.getCurrentPackageName() + ":id/tagFilterButton", true));
        instrumentation.waitForMonitorWithTimeout(monitor, 40000); 
        instrumentation.removeMonitor(monitor);
        assertTrue(TestUtils.findText(device, false, main.getString(R.string.empty_list), 5000));
         add empty entry
        assertTrue(TestUtils.clickResource(device, false, device.getCurrentPackageName() + ":id/add", true));
        UiObject2 key = TestUtils.findObjectWithText(device, false, main.getString(R.string.key), 500, false);
        key.setText("amenity");
        UiObject2 value = TestUtils.findObjectWithText(device, false, main.getString(R.string.value), 500, false);
        value.setText("toilets");
         exit config activity
        TestUtils.clickHome(device, false);
        TestUtils.sleep(5000);  android 9 needs this
        TestUtils.clickAtCoordinates(device, map, t.getLon() / 1E7D, t.getLat() / 1E7D, true);
        assertTrue(TestUtils.findText(device, false, main.getString(R.string.actionmode_nodeselect), 5000));
        Node node = App.getLogic().getSelectedNode();
        assertNotNull(node);
        assertEquals(3465444349L, node.getOsmId());
        monitor = instrumentation.addMonitor(TagFilterActivity.class.getName(), null, false);
        assertTrue(TestUtils.clickResource(device, false, device.getCurrentPackageName() + ":id/tagFilterButton", true));
        instrumentation.waitForMonitorWithTimeout(monitor, 40000); 
        instrumentation.removeMonitor(monitor);
        assertTrue(TestUtils.clickResource(device, false, device.getCurrentPackageName() + ":id/delete", false));
        assertTrue(TestUtils.findText(device, false, main.getString(R.string.empty_list), 5000));
         exit config activity
        TestUtils.clickHome(device, false);
        TestUtils.sleep(5000);  android 9 needs this
         clicking now should select nothing
        TestUtils.clickAtCoordinates(device, map, t.getLon() / 1E7D, t.getLat() / 1E7D, true);
        assertFalse(TestUtils.findText(device, false, main.getString(R.string.actionmode_nodeselect), 2000));
         disable tag filter
        assertTrue(TestUtils.clickOverflowButton(device));
        assertTrue(TestUtils.clickText(device, false, main.getString(R.string.menu_enable_tagfilter), false));
    }
@ Test public void simpleTagTest ( ) { TestUtils . unlock ( device ) ; Node t = ( Node ) App . getDelegator ( ) . getOsmElement ( Node . NAME , 3465444349L ) ; assertNotNull ( t ) ; assertTrue ( t . hasTag ( "amenity" , "toilets" ) ) ; assertTrue ( TestUtils . clickOverflowButton ( device ) ) ; assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . menu_enable_tagfilter ) , false ) ) ; monitor = instrumentation . addMonitor ( TagFilterActivity . class . getName ( ) , null , false ) ; assertTrue ( TestUtils . clickResource ( device , false , device . getCurrentPackageName ( ) + ":id/tagFilterButton" , true ) ) ; instrumentation . waitForMonitorWithTimeout ( monitor , 40000 ) ; instrumentation . removeMonitor ( monitor ) ; assertTrue ( TestUtils . findText ( device , false , main . getString ( R . string . empty_list ) , 5000 ) ) ; assertTrue ( TestUtils . clickResource ( device , false , device . getCurrentPackageName ( ) + ":id/add" , true ) ) ; UiObject2 key = TestUtils . findObjectWithText ( device , false , main . getString ( R . string . key ) , 500 , false ) ; key . setText ( "amenity" ) ; UiObject2 value = TestUtils . findObjectWithText ( device , false , main . getString ( R . string . value ) , 500 , false ) ; value . setText ( "toilets" ) ; TestUtils . clickHome ( device , false ) ; TestUtils . sleep ( 5000 ) ; TestUtils . clickAtCoordinates ( device , map , t . getLon ( ) / 1E7D , t . getLat ( ) / 1E7D , true ) ; assertTrue ( TestUtils . findText ( device , false , main . getString ( R . string . actionmode_nodeselect ) , 5000 ) ) ; Node node = App . getLogic ( ) . getSelectedNode ( ) ; assertNotNull ( node ) ; assertEquals ( 3465444349L , node . getOsmId ( ) ) ; monitor = instrumentation . addMonitor ( TagFilterActivity . class . getName ( ) , null , false ) ; assertTrue ( TestUtils . clickResource ( device , false , device . getCurrentPackageName ( ) + ":id/tagFilterButton" , true ) ) ; instrumentation . waitForMonitorWithTimeout ( monitor , 40000 ) ; instrumentation . removeMonitor ( monitor ) ; assertTrue ( TestUtils . clickResource ( device , false , device . getCurrentPackageName ( ) + ":id/delete" , false ) ) ; assertTrue ( TestUtils . findText ( device , false , main . getString ( R . string . empty_list ) , 5000 ) ) ; TestUtils . clickHome ( device , false ) ; TestUtils . sleep ( 5000 ) ; TestUtils . clickAtCoordinates ( device , map , t . getLon ( ) / 1E7D , t . getLat ( ) / 1E7D , true ) ; assertFalse ( TestUtils . findText ( device , false , main . getString ( R . string . actionmode_nodeselect ) , 2000 ) ) ; assertTrue ( TestUtils . clickOverflowButton ( device ) ) ; assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . menu_enable_tagfilter ) , false ) ) ; }
Enable tagfilter, add filter, click object, remove filter etc
Enable tagfilter add filter click object remove filter etc
// enable tag filter // start filter config activity // // add empty entry // exit config activity // android 9 needs this // start filter config activity // // exit config activity // android 9 needs this // clicking now should select nothing // disable tag filter