src/androidTest/java/de/blau/android/propertyeditor/PropertyEditorTest.java
/**
     * Add a tag and relation membership to a new node
     */
Add a tag and relation membership to a new node
Add a tag and relation membership to a new node
@Test
    public void newNode() {
        Logic logic = App.getLogic();
        Map map = main.getMap();
        logic.setZoom(map, 20);
        float tolerance = DataStyle.getCurrent().getWayToleranceValue();
        System.out.println("Tolerance " + tolerance);
        Relation r = logic.createRelation(main, Tags.VALUE_ROUTE, new ArrayList<>());
        java.util.Map<String, String> tags = new TreeMap<>(r.getTags());
        tags.put(Tags.KEY_NAME, "test");
        logic.setTags(main, r, tags);
        logic.setSelectedWay(null);
        logic.setSelectedNode(null);
        logic.setSelectedRelation(null);
        try {
            logic.performAdd(main, 1000.0f, 0.0f);
        } catch (OsmIllegalOperationException e1) {
            fail(e1.getMessage());
        }
        Node n = logic.getSelectedNode();
        assertNotNull(n);
        main.performTagEdit(n, null, false, false);
        Activity propertyEditor = instrumentation.waitForMonitorWithTimeout(monitor, 30000);
        assertTrue(propertyEditor instanceof PropertyEditor);
        TestUtils.clickText(device, true, main.getString(R.string.tag_details), false, false);
        device.wait(Until.findObject(By.clickable(true).res(device.getCurrentPackageName() + ":id/editKey")), 500);
        UiObject editText = device.findObject(new UiSelector().clickable(true).resourceId(device.getCurrentPackageName() + ":id/editKey"));
        try {
            editText.setText("key");
        } catch (UiObjectNotFoundException e) {
            fail(e.getMessage());
        }
        editText = device.findObject(new UiSelector().clickable(true).resourceId(device.getCurrentPackageName() + ":id/editValue"));
        try {
            editText.setText("value");
        } catch (UiObjectNotFoundException e) {
            fail(e.getMessage());
        }
        assertTrue(TestUtils.clickText(device, true, main.getString(R.string.relations), false, false));
        assertTrue(TestUtils.clickOverflowButton(device));
        assertTrue(TestUtils.clickText(device, false, "Add to relation", true));
        assertTrue(TestUtils.clickText(device, false, "test", true));
        TestUtils.clickHome(device, true);
        assertTrue(n.hasTag("key", "value"));
        List<Relation> parents = n.getParentRelations();
        assertNotNull(parents);
        assertEquals(1, parents.size());
        assertEquals(r, parents.get(0));
    }
@ Test public void newNode ( ) { Logic logic = App . getLogic ( ) ; Map map = main . getMap ( ) ; logic . setZoom ( map , 20 ) ; float tolerance = DataStyle . getCurrent ( ) . getWayToleranceValue ( ) ; System . out . println ( "Tolerance " + tolerance ) ; Relation r = logic . createRelation ( main , Tags . VALUE_ROUTE , new ArrayList < > ( ) ) ; java . util . Map < String , String > tags = new TreeMap < > ( r . getTags ( ) ) ; tags . put ( Tags . KEY_NAME , "test" ) ; logic . setTags ( main , r , tags ) ; logic . setSelectedWay ( null ) ; logic . setSelectedNode ( null ) ; logic . setSelectedRelation ( null ) ; try { logic . performAdd ( main , 1000.0f , 0.0f ) ; } catch ( OsmIllegalOperationException e1 ) { fail ( e1 . getMessage ( ) ) ; } Node n = logic . getSelectedNode ( ) ; assertNotNull ( n ) ; main . performTagEdit ( n , null , false , false ) ; Activity propertyEditor = instrumentation . waitForMonitorWithTimeout ( monitor , 30000 ) ; assertTrue ( propertyEditor instanceof PropertyEditor ) ; TestUtils . clickText ( device , true , main . getString ( R . string . tag_details ) , false , false ) ; device . wait ( Until . findObject ( By . clickable ( true ) . res ( device . getCurrentPackageName ( ) + ":id/editKey" ) ) , 500 ) ; UiObject editText = device . findObject ( new UiSelector ( ) . clickable ( true ) . resourceId ( device . getCurrentPackageName ( ) + ":id/editKey" ) ) ; try { editText . setText ( "key" ) ; } catch ( UiObjectNotFoundException e ) { fail ( e . getMessage ( ) ) ; } editText = device . findObject ( new UiSelector ( ) . clickable ( true ) . resourceId ( device . getCurrentPackageName ( ) + ":id/editValue" ) ) ; try { editText . setText ( "value" ) ; } catch ( UiObjectNotFoundException e ) { fail ( e . getMessage ( ) ) ; } assertTrue ( TestUtils . clickText ( device , true , main . getString ( R . string . relations ) , false , false ) ) ; assertTrue ( TestUtils . clickOverflowButton ( device ) ) ; assertTrue ( TestUtils . clickText ( device , false , "Add to relation" , true ) ) ; assertTrue ( TestUtils . clickText ( device , false , "test" , true ) ) ; TestUtils . clickHome ( device , true ) ; assertTrue ( n . hasTag ( "key" , "value" ) ) ; List < Relation > parents = n . getParentRelations ( ) ; assertNotNull ( parents ) ; assertEquals ( 1 , parents . size ( ) ) ; assertEquals ( r , parents . get ( 0 ) ) ; }
Add a tag and relation membership to a new node
Add a tag and relation membership to a new node
// create a relation for testing