src/androidTest/java/de/blau/android/layer/LayerDialogTest.java
/**
     * Test adding and then modifiy custom imagery
     */
Test adding and then modifiy custom imagery
Test adding and then modifiy custom imagery
@Test
    public void customImagery() {
        assertTrue(TestUtils.clickResource(device, true, device.getCurrentPackageName() + ":id/layers", true));
        assertTrue(TestUtils.clickResource(device, true, device.getCurrentPackageName() + ":id/add", true));
        TestUtils.scrollTo(main.getString(R.string.layer_add_custom_imagery), false);
        assertTrue(TestUtils.clickText(device, false, main.getString(R.string.layer_add_custom_imagery), true));
        assertTrue(TestUtils.findText(device, false, main.getString(R.string.add_layer_title)));
        UiObject name = device.findObject(new UiSelector().resourceId(device.getCurrentPackageName() + ":id/name"));
        try {
            name.setText("Custom imagery");
        } catch (UiObjectNotFoundException e) {
            fail(e.getMessage());
        }
        UiObject url = device.findObject(new UiSelector().resourceId(device.getCurrentPackageName() + ":id/url"));
        try {
            url.setText("https://test/");
        } catch (UiObjectNotFoundException e) {
            fail(e.getMessage());
        }
        assertTrue(TestUtils.clickText(device, false, main.getString(R.string.save_and_set), true));
        try (TileLayerDatabase db = new TileLayerDatabase(ApplicationProvider.getApplicationContext())) {
            TileLayerSource tls = TileLayerDatabase.getLayerWithUrl(main, db.getReadableDatabase(), "https://test/");
            assertNotNull(tls);
            assertEquals("Custom imagery", tls.getName());
        }
        TestUtils.clickText(device, true, main.getString(R.string.done), true, false);
        UiObject2 menuButton = TestUtils.getLayerButton(device, "Custom imagery", MENU_BUTTON);
        menuButton.clickAndWait(Until.newWindow(), 2000);
        assertTrue(TestUtils.clickText(device, false, main.getString(R.string.layer_edit_custom_imagery_configuration), true));
        assertTrue(TestUtils.findText(device, false, main.getString(R.string.edit_layer_title)));
        url = device.findObject(new UiSelector().resourceId(device.getCurrentPackageName() + ":id/url"));
        try {
            url.setText("https://test2/");
        } catch (UiObjectNotFoundException e) {
            fail(e.getMessage());
        }
        assertTrue(TestUtils.clickText(device, false, main.getString(R.string.save), true));
        try (TileLayerDatabase db = new TileLayerDatabase(ApplicationProvider.getApplicationContext())) {
            TileLayerSource tls = TileLayerDatabase.getLayerWithUrl(main, db.getReadableDatabase(), "https://test2/");
            assertNotNull(tls);
        }
    }
@ Test public void customImagery ( ) { assertTrue ( TestUtils . clickResource ( device , true , device . getCurrentPackageName ( ) + ":id/layers" , true ) ) ; assertTrue ( TestUtils . clickResource ( device , true , device . getCurrentPackageName ( ) + ":id/add" , true ) ) ; TestUtils . scrollTo ( main . getString ( R . string . layer_add_custom_imagery ) , false ) ; assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . layer_add_custom_imagery ) , true ) ) ; assertTrue ( TestUtils . findText ( device , false , main . getString ( R . string . add_layer_title ) ) ) ; UiObject name = device . findObject ( new UiSelector ( ) . resourceId ( device . getCurrentPackageName ( ) + ":id/name" ) ) ; try { name . setText ( "Custom imagery" ) ; } catch ( UiObjectNotFoundException e ) { fail ( e . getMessage ( ) ) ; } UiObject url = device . findObject ( new UiSelector ( ) . resourceId ( device . getCurrentPackageName ( ) + ":id/url" ) ) ; try { url . setText ( "https://test/" ) ; } catch ( UiObjectNotFoundException e ) { fail ( e . getMessage ( ) ) ; } assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . save_and_set ) , true ) ) ; try ( TileLayerDatabase db = new TileLayerDatabase ( ApplicationProvider . getApplicationContext ( ) ) ) { TileLayerSource tls = TileLayerDatabase . getLayerWithUrl ( main , db . getReadableDatabase ( ) , "https://test/" ) ; assertNotNull ( tls ) ; assertEquals ( "Custom imagery" , tls . getName ( ) ) ; } TestUtils . clickText ( device , true , main . getString ( R . string . done ) , true , false ) ; UiObject2 menuButton = TestUtils . getLayerButton ( device , "Custom imagery" , MENU_BUTTON ) ; menuButton . clickAndWait ( Until . newWindow ( ) , 2000 ) ; assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . layer_edit_custom_imagery_configuration ) , true ) ) ; assertTrue ( TestUtils . findText ( device , false , main . getString ( R . string . edit_layer_title ) ) ) ; url = device . findObject ( new UiSelector ( ) . resourceId ( device . getCurrentPackageName ( ) + ":id/url" ) ) ; try { url . setText ( "https://test2/" ) ; } catch ( UiObjectNotFoundException e ) { fail ( e . getMessage ( ) ) ; } assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . save ) , true ) ) ; try ( TileLayerDatabase db = new TileLayerDatabase ( ApplicationProvider . getApplicationContext ( ) ) ) { TileLayerSource tls = TileLayerDatabase . getLayerWithUrl ( main , db . getReadableDatabase ( ) , "https://test2/" ) ; assertNotNull ( tls ) ; } }
Test adding and then modifiy custom imagery
Test adding and then modifiy custom imagery