src/androidTest/java/de/blau/android/propertyeditor/PropertyEditorTest.java
/**
     * Add a conditional restriction, this is just a rough test without using the actual UI elements of the editor
     */
Add a conditional restriction, this is just a rough test without using the actual UI elements of the editor
Add a conditional restriction this is just a rough test without using the actual UI elements of the editor
@Test
    public void conditionalRestrictionEditor() {
        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, 27009604L);
        assertNotNull(w);
        main.performTagEdit(w, null, false, false);
        Activity propertyEditor = instrumentation.waitForMonitorWithTimeout(monitor, 30000);
        assertTrue(propertyEditor instanceof PropertyEditor);
        if (!((PropertyEditor) propertyEditor).paneLayout()) {
            assertTrue(TestUtils.clickText(device, true, main.getString(R.string.tag_menu_preset), false, false));
        }
        boolean found = TestUtils.clickText(device, true, getTranslatedPresetGroupName(main, "Highways"), true, false);
        assertTrue(found);
        found = TestUtils.clickText(device, true, getTranslatedPresetGroupName(main, "Streets"), true, false);
        assertTrue(found);
        found = TestUtils.clickText(device, true, getTranslatedPresetItemName(main, "Residential"), true, false);
        assertTrue(found);
        assertTrue(TestUtils.findText(device, false, "Kindhauserstrasse"));
        found = TestUtils.clickText(device, true, getTranslatedPresetItemName(main, "Cond. & direct. max speed"), true, false);
        assertTrue(found);
        UiObject2 conditionalMaxSpeed = null;
        try {
            conditionalMaxSpeed = getField(device, "Max speed @", 1);
        } catch (UiObjectNotFoundException e) {
            fail();
        }
        assertNotNull(conditionalMaxSpeed);
        conditionalMaxSpeed.click();
        assertTrue(TestUtils.findText(device, false, "50 @"));
        assertTrue(TestUtils.clickButton(device, device.getCurrentPackageName() + ":id/add", true));
        assertTrue(TestUtils.clickText(device, false, main.getString(R.string.tag_restriction_add_restriction), false));
        UiObject editValue = TestUtils.findObjectWithResourceId(device, device.getCurrentPackageName() + ":id/editValue", 1);
        try {
            editValue.setText("30");
        } catch (UiObjectNotFoundException e) {
            fail(e.getMessage());
        }
        UiObject condition0 = TestUtils.findObjectWithResourceId(device, device.getCurrentPackageName() + ":id/editCondition", 0);
        try {
            condition0.setText("maxweight>40");
        } catch (UiObjectNotFoundException e) {
            fail(e.getMessage());
        }
        assertTrue(TestUtils.clickButton(device, device.getCurrentPackageName() + ":id/add", true));
        assertTrue(TestUtils.clickText(device, false, main.getString(R.string.refresh), false));
        assertTrue(TestUtils.clickButton(device, device.getCurrentPackageName() + ":id/save", true));
        try {
            conditionalMaxSpeed = getField(device, "Max speed @", 1);
        } catch (UiObjectNotFoundException e) {
            fail();
        }
        assertEquals("50 @ Mo-Fr 19:00-31:00,Sa,Su; 30 @ maxweight>40", conditionalMaxSpeed.getText());
    }
@ Test public void conditionalRestrictionEditor ( ) { 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 , 27009604L ) ; assertNotNull ( w ) ; main . performTagEdit ( w , null , false , false ) ; Activity propertyEditor = instrumentation . waitForMonitorWithTimeout ( monitor , 30000 ) ; assertTrue ( propertyEditor instanceof PropertyEditor ) ; if ( ! ( ( PropertyEditor ) propertyEditor ) . paneLayout ( ) ) { assertTrue ( TestUtils . clickText ( device , true , main . getString ( R . string . tag_menu_preset ) , false , false ) ) ; } boolean found = TestUtils . clickText ( device , true , getTranslatedPresetGroupName ( main , "Highways" ) , true , false ) ; assertTrue ( found ) ; found = TestUtils . clickText ( device , true , getTranslatedPresetGroupName ( main , "Streets" ) , true , false ) ; assertTrue ( found ) ; found = TestUtils . clickText ( device , true , getTranslatedPresetItemName ( main , "Residential" ) , true , false ) ; assertTrue ( found ) ; assertTrue ( TestUtils . findText ( device , false , "Kindhauserstrasse" ) ) ; found = TestUtils . clickText ( device , true , getTranslatedPresetItemName ( main , "Cond. & direct. max speed" ) , true , false ) ; assertTrue ( found ) ; UiObject2 conditionalMaxSpeed = null ; try { conditionalMaxSpeed = getField ( device , "Max speed @" , 1 ) ; } catch ( UiObjectNotFoundException e ) { fail ( ) ; } assertNotNull ( conditionalMaxSpeed ) ; conditionalMaxSpeed . click ( ) ; assertTrue ( TestUtils . findText ( device , false , "50 @" ) ) ; assertTrue ( TestUtils . clickButton ( device , device . getCurrentPackageName ( ) + ":id/add" , true ) ) ; assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . tag_restriction_add_restriction ) , false ) ) ; UiObject editValue = TestUtils . findObjectWithResourceId ( device , device . getCurrentPackageName ( ) + ":id/editValue" , 1 ) ; try { editValue . setText ( "30" ) ; } catch ( UiObjectNotFoundException e ) { fail ( e . getMessage ( ) ) ; } UiObject condition0 = TestUtils . findObjectWithResourceId ( device , device . getCurrentPackageName ( ) + ":id/editCondition" , 0 ) ; try { condition0 . setText ( "maxweight>40" ) ; } catch ( UiObjectNotFoundException e ) { fail ( e . getMessage ( ) ) ; } assertTrue ( TestUtils . clickButton ( device , device . getCurrentPackageName ( ) + ":id/add" , true ) ) ; assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . refresh ) , false ) ) ; assertTrue ( TestUtils . clickButton ( device , device . getCurrentPackageName ( ) + ":id/save" , true ) ) ; try { conditionalMaxSpeed = getField ( device , "Max speed @" , 1 ) ; } catch ( UiObjectNotFoundException e ) { fail ( ) ; } assertEquals ( "50 @ Mo-Fr 19:00-31:00,Sa,Su; 30 @ maxweight>40" , conditionalMaxSpeed . getText ( ) ) ; }
Add a conditional restriction, this is just a rough test without using the actual UI elements of the editor
Add a conditional restriction this is just a rough test without using the actual UI elements of the editor