src/androidTest/java/de/blau/android/prefs/CustomImageryTest.java
/**
     * Start prefs, custom imagery, add, load invalid mbtiles
     */
Start prefs, custom imagery, add, load invalid mbtiles
Start prefs custom imagery add load invalid mbtiles
@Test
    public void customImageryInvalidMBTiles() {
        File mbtiles = null;
        try {
            mbtiles = JavaResources.copyFileFromResources(main, "map-no-meta.mbt", null, "mbtiles");
            Preferences prefs = new Preferences(main);
            LayerUtils.removeImageryLayers(main);
            main.getMap().setPrefs(main, prefs);
            monitor = instrumentation.addMonitor(PrefEditor.class.getName(), null, false);
            Assert.assertTrue(TestUtils.clickButton(device, device.getCurrentPackageName() + ":id/menu_config", true));
            instrumentation.waitForMonitorWithTimeout(monitor, 40000); 
            Assert.assertTrue(TestUtils.clickText(device, false, main.getString(R.string.config_customlayers_title), true, false));
            Assert.assertTrue(TestUtils.clickButton(device, device.getCurrentPackageName() + ":id/add", true));
            Assert.assertTrue(TestUtils.clickButton(device, device.getCurrentPackageName() + ":id/file_button", true));
            TestUtils.selectFile(device, main, "mbtiles", "map-no-meta.mbt", true);
            UiObject url = device.findObject(new UiSelector().resourceId(device.getCurrentPackageName() + ":id/url"));
            try {
                Assert.assertEquals("", url.getText()); 
            } catch (UiObjectNotFoundException e) {
                Assert.fail(e.getMessage());
            }
        } catch (IOException e) {
            Assert.fail(e.getMessage());
        } finally {
            if (mbtiles != null) {
                mbtiles.delete();
            }
        }
    }
@ Test public void customImageryInvalidMBTiles ( ) { File mbtiles = null ; try { mbtiles = JavaResources . copyFileFromResources ( main , "map-no-meta.mbt" , null , "mbtiles" ) ; Preferences prefs = new Preferences ( main ) ; LayerUtils . removeImageryLayers ( main ) ; main . getMap ( ) . setPrefs ( main , prefs ) ; monitor = instrumentation . addMonitor ( PrefEditor . class . getName ( ) , null , false ) ; Assert . assertTrue ( TestUtils . clickButton ( device , device . getCurrentPackageName ( ) + ":id/menu_config" , true ) ) ; instrumentation . waitForMonitorWithTimeout ( monitor , 40000 ) ; Assert . assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . config_customlayers_title ) , true , false ) ) ; Assert . assertTrue ( TestUtils . clickButton ( device , device . getCurrentPackageName ( ) + ":id/add" , true ) ) ; Assert . assertTrue ( TestUtils . clickButton ( device , device . getCurrentPackageName ( ) + ":id/file_button" , true ) ) ; TestUtils . selectFile ( device , main , "mbtiles" , "map-no-meta.mbt" , true ) ; UiObject url = device . findObject ( new UiSelector ( ) . resourceId ( device . getCurrentPackageName ( ) + ":id/url" ) ) ; try { Assert . assertEquals ( "" , url . getText ( ) ) ; } catch ( UiObjectNotFoundException e ) { Assert . fail ( e . getMessage ( ) ) ; } } catch ( IOException e ) { Assert . fail ( e . getMessage ( ) ) ; } finally { if ( mbtiles != null ) { mbtiles . delete ( ) ; } } }
Start prefs, custom imagery, add, load invalid mbtiles
Start prefs custom imagery add load invalid mbtiles
// wait for prefs // url not set