src/androidTest/java/de/blau/android/prefs/CustomImageryTest.java
/**
     * Start prefs, custom imagery, add, load mbtiles
     */
Start prefs, custom imagery, add, load mbtiles
Start prefs custom imagery add load mbtiles
@Test
    public void customImageryValidMBTiles() {
        File mbtiles = null;
        try {
            mbtiles = JavaResources.copyFileFromResources(main, "map.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.mbt", true);
            Assert.assertTrue(TestUtils.findText(device, false, "My Map"));
            Assert.assertTrue(TestUtils.findText(device, false, "57.0527713171221"));
            Assert.assertTrue(TestUtils.clickText(device, false, main.getString(R.string.save_and_set), true, false));
            Assert.assertTrue(TestUtils.findText(device, false, "My Map"));
            Assert.assertTrue(TestUtils.clickText(device, false, main.getString(R.string.done), true, false));
            Assert.assertTrue(TestUtils.clickHome(device, true));
            UiObject2 extentButton = TestUtils.getLayerButton(device, "My Map", LayerDialogTest.EXTENT_BUTTON);
            extentButton.clickAndWait(Until.newWindow(), 2000);
        } catch (IOException e) {
            Assert.fail(e.getMessage());
        } finally {
            if (mbtiles != null) {
                mbtiles.delete();
            }
        }
    }
@ Test public void customImageryValidMBTiles ( ) { File mbtiles = null ; try { mbtiles = JavaResources . copyFileFromResources ( main , "map.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.mbt" , true ) ; Assert . assertTrue ( TestUtils . findText ( device , false , "My Map" ) ) ; Assert . assertTrue ( TestUtils . findText ( device , false , "57.0527713171221" ) ) ; Assert . assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . save_and_set ) , true , false ) ) ; Assert . assertTrue ( TestUtils . findText ( device , false , "My Map" ) ) ; Assert . assertTrue ( TestUtils . clickText ( device , false , main . getString ( R . string . done ) , true , false ) ) ; Assert . assertTrue ( TestUtils . clickHome ( device , true ) ) ; UiObject2 extentButton = TestUtils . getLayerButton ( device , "My Map" , LayerDialogTest . EXTENT_BUTTON ) ; extentButton . clickAndWait ( Until . newWindow ( ) , 2000 ) ; } catch ( IOException e ) { Assert . fail ( e . getMessage ( ) ) ; } finally { if ( mbtiles != null ) { mbtiles . delete ( ) ; } } }
Start prefs, custom imagery, add, load mbtiles
Start prefs custom imagery add load mbtiles
// wait for prefs