src/androidTest/java/de/blau/android/propertyeditor/PropertyEditorTest.java
/**
     * Add a tag and check if that has added a preset item to the MRU display
     */
Add a tag and check if that has added a preset item to the MRU display
Add a tag and check if that has added a preset item to the MRU display
@Test
    public void presetsViaManualTag() {
        final CountDownLatch signal = new CountDownLatch(1);
        mockServer.enqueue("capabilities1");
        mockServer.enqueue("download1");
        Logic logic = App.getLogic();
        logic.downloadBox(main, new BoundingBox(8.3879800D, 47.3892400D, 8.3844600D, 47.3911300D), false, new SignalHandler(signal));
        try {
            signal.await(30, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            fail(e.getMessage());
        }
        Way w = (Way) App.getDelegator().getOsmElement(Way.NAME, 210468113L);
        assertNotNull(w);
        try {
            logic.setTags(main, w, null);
        } catch (OsmIllegalOperationException e) {
            fail(e.getMessage());
        }
        main.performTagEdit(w, 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/editValue")), 500);
        UiObject keyEditText = device.findObject(new UiSelector().clickable(true).resourceId(device.getCurrentPackageName() + ":id/editKey"));
        UiObject valueEditText = device.findObject(new UiSelector().clickable(true).resourceId(device.getCurrentPackageName() + ":id/editValue"));
        String key = Tags.KEY_BUILDING;
        String value = Tags.VALUE_YES;
        try {
            keyEditText.click();
            keyEditText.setText(key);
            valueEditText.click();
            valueEditText.setText(value);
        } catch (UiObjectNotFoundException e) {
            fail(e.getMessage());
        }
        if (!((PropertyEditor) propertyEditor).paneLayout()) {
            TestUtils.clickText(device, true, main.getString(R.string.menu_tags), false, false);
        }
        PresetItem presetItem = ((PropertyEditor) propertyEditor).getBestPreset();
        assertNotNull(presetItem);
        assertEquals("Building", presetItem.getName());
        assertTrue(TestUtils.clickText(device, true, presetItem.getTranslatedName(), false, false)); 
    }
@ Test public void presetsViaManualTag ( ) { final CountDownLatch signal = new CountDownLatch ( 1 ) ; mockServer . enqueue ( "capabilities1" ) ; mockServer . enqueue ( "download1" ) ; Logic logic = App . getLogic ( ) ; logic . downloadBox ( main , new BoundingBox ( 8.3879800D , 47.3892400D , 8.3844600D , 47.3911300D ) , false , new SignalHandler ( signal ) ) ; try { signal . await ( 30 , TimeUnit . SECONDS ) ; } catch ( InterruptedException e ) { fail ( e . getMessage ( ) ) ; } Way w = ( Way ) App . getDelegator ( ) . getOsmElement ( Way . NAME , 210468113L ) ; assertNotNull ( w ) ; try { logic . setTags ( main , w , null ) ; } catch ( OsmIllegalOperationException e ) { fail ( e . getMessage ( ) ) ; } main . performTagEdit ( w , 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/editValue" ) ) , 500 ) ; UiObject keyEditText = device . findObject ( new UiSelector ( ) . clickable ( true ) . resourceId ( device . getCurrentPackageName ( ) + ":id/editKey" ) ) ; UiObject valueEditText = device . findObject ( new UiSelector ( ) . clickable ( true ) . resourceId ( device . getCurrentPackageName ( ) + ":id/editValue" ) ) ; String key = Tags . KEY_BUILDING ; String value = Tags . VALUE_YES ; try { keyEditText . click ( ) ; keyEditText . setText ( key ) ; valueEditText . click ( ) ; valueEditText . setText ( value ) ; } catch ( UiObjectNotFoundException e ) { fail ( e . getMessage ( ) ) ; } if ( ! ( ( PropertyEditor ) propertyEditor ) . paneLayout ( ) ) { TestUtils . clickText ( device , true , main . getString ( R . string . menu_tags ) , false , false ) ; } PresetItem presetItem = ( ( PropertyEditor ) propertyEditor ) . getBestPreset ( ) ; assertNotNull ( presetItem ) ; assertEquals ( "Building" , presetItem . getName ( ) ) ; assertTrue ( TestUtils . clickText ( device , true , presetItem . getTranslatedName ( ) , false , false ) ) ; }
Add a tag and check if that has added a preset item to the MRU display
Add a tag and check if that has added a preset item to the MRU display
// building // preset // should now be // added to MRU