src/androidTest/java/de/blau/android/propertyeditor/SaveResumeTest.java
/**
     * Edit a tag in the PropertyEditor - restart app - check that edit is still there
     */
Edit a tag in the PropertyEditor - restart app - check that edit is still there
Edit a tag in the PropertyEditor - restart app - check that edit is still there
@Test
    public void editTag() {
        ActivityMonitor monitor = instrumentation.addMonitor(PropertyEditor.class.getName(), null, false);
        Node n = (Node) App.getDelegator().getOsmElement(Node.NAME, 101792984);
        assertNotNull(n);
        PropertyEditorData[] single = new PropertyEditorData[1];
        single[0] = new PropertyEditorData(n, null);
        try (ActivityScenario<PropertyEditor> scenario = ActivityScenario.launch(PropertyEditor.buildIntent(main, single, false, false, null, null))) {
            Activity propertyEditor = instrumentation.waitForMonitorWithTimeout(monitor, 30000);
            assertTrue(propertyEditor instanceof PropertyEditor);
            TestUtils.clickText(device, true, main.getString(R.string.menu_tags), false, false);
            final String original = "Bergdietikon";
            UiObject2 o = device.wait(Until.findObject(By.clickable(true).textStartsWith(original)), 500);
            assertNotNull(o);
            final String edited = "dietikonBerg";
            UiObject editText = device.findObject(new UiSelector().clickable(true).textStartsWith(original));
            try {
                editText.click();
                editText.setText(edited);
                instrumentation.sendCharacterSync(KeyEvent.KEYCODE_TAB); 
            } catch (UiObjectNotFoundException e) {
                fail(e.getMessage());
            }
            scenario.recreate();
            o = device.wait(Until.findObject(By.clickable(true).textStartsWith(edited)), 500);
            assertNotNull(o);
        }
    }
@ Test public void editTag ( ) { ActivityMonitor monitor = instrumentation . addMonitor ( PropertyEditor . class . getName ( ) , null , false ) ; Node n = ( Node ) App . getDelegator ( ) . getOsmElement ( Node . NAME , 101792984 ) ; assertNotNull ( n ) ; PropertyEditorData [ ] single = new PropertyEditorData [ 1 ] ; single [ 0 ] = new PropertyEditorData ( n , null ) ; try ( ActivityScenario < PropertyEditor > scenario = ActivityScenario . launch ( PropertyEditor . buildIntent ( main , single , false , false , null , null ) ) ) { Activity propertyEditor = instrumentation . waitForMonitorWithTimeout ( monitor , 30000 ) ; assertTrue ( propertyEditor instanceof PropertyEditor ) ; TestUtils . clickText ( device , true , main . getString ( R . string . menu_tags ) , false , false ) ; final String original = "Bergdietikon" ; UiObject2 o = device . wait ( Until . findObject ( By . clickable ( true ) . textStartsWith ( original ) ) , 500 ) ; assertNotNull ( o ) ; final String edited = "dietikonBerg" ; UiObject editText = device . findObject ( new UiSelector ( ) . clickable ( true ) . textStartsWith ( original ) ) ; try { editText . click ( ) ; editText . setText ( edited ) ; instrumentation . sendCharacterSync ( KeyEvent . KEYCODE_TAB ) ; } catch ( UiObjectNotFoundException e ) { fail ( e . getMessage ( ) ) ; } scenario . recreate ( ) ; o = device . wait ( Until . findObject ( By . clickable ( true ) . textStartsWith ( edited ) ) , 500 ) ; assertNotNull ( o ) ; } }
Edit a tag in the PropertyEditor - restart app - check that edit is still there
Edit a tag in the PropertyEditor - restart app - check that edit is still there
// this seems to be necessary to guarantee // things will be changed // check that we still have the change