src/test/java/de/blau/android/resources/TileLayerServerTest.java
/**
     * Test that imagery is sorted as expected
     */
Test that imagery is sorted as expected
Test that imagery is sorted as expected
@Test
    public void sort() {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        InputStream is = loader.getResourceAsStream("imagery_test.geojson");
        try (TileLayerDatabase db = new TileLayerDatabase(main)) {
            TileLayerSource.parseImageryFile(main, db.getWritableDatabase(), TileLayerDatabase.SOURCE_JOSM_IMAGERY, is, false);
            TileLayerSource.getListsLocked(main, db.getReadableDatabase(), true);
        } catch (IOException e) {
            Assert.fail(e.getMessage());
        }
        List<String> names = Arrays.asList(TileLayerSource.getNames(null, false));
        int iA = names.indexOf("A imagery");
        Assert.assertNotEquals(-1, iA);
        int iAnoDate = names.indexOf("A no date imagery");
        Assert.assertNotEquals(-1, iAnoDate);
        int iB = names.indexOf("B imagery");
        Assert.assertNotEquals(-1, iB);
        int iBnoDate = names.indexOf("B no date imagery");
        Assert.assertNotEquals(-1, iBnoDate);
        int iC = names.indexOf("C imagery");
        Assert.assertNotEquals(-1, iC);
        Assert.assertTrue(iAnoDate < iBnoDate); 
        TileLayerSource a = TileLayerSource.get(main, "A", false);
        TileLayerSource b = TileLayerSource.get(main, "B", false);
        Assert.assertTrue(a.getEndDate() < b.getEndDate());
        Assert.assertTrue(iA > iB); 
        Assert.assertTrue(iA > iC && iB > iC); 
    }
@ Test public void sort ( ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; InputStream is = loader . getResourceAsStream ( "imagery_test.geojson" ) ; try ( TileLayerDatabase db = new TileLayerDatabase ( main ) ) { TileLayerSource . parseImageryFile ( main , db . getWritableDatabase ( ) , TileLayerDatabase . SOURCE_JOSM_IMAGERY , is , false ) ; TileLayerSource . getListsLocked ( main , db . getReadableDatabase ( ) , true ) ; } catch ( IOException e ) { Assert . fail ( e . getMessage ( ) ) ; } List < String > names = Arrays . asList ( TileLayerSource . getNames ( null , false ) ) ; int iA = names . indexOf ( "A imagery" ) ; Assert . assertNotEquals ( - 1 , iA ) ; int iAnoDate = names . indexOf ( "A no date imagery" ) ; Assert . assertNotEquals ( - 1 , iAnoDate ) ; int iB = names . indexOf ( "B imagery" ) ; Assert . assertNotEquals ( - 1 , iB ) ; int iBnoDate = names . indexOf ( "B no date imagery" ) ; Assert . assertNotEquals ( - 1 , iBnoDate ) ; int iC = names . indexOf ( "C imagery" ) ; Assert . assertNotEquals ( - 1 , iC ) ; Assert . assertTrue ( iAnoDate < iBnoDate ) ; TileLayerSource a = TileLayerSource . get ( main , "A" , false ) ; TileLayerSource b = TileLayerSource . get ( main , "B" , false ) ; Assert . assertTrue ( a . getEndDate ( ) < b . getEndDate ( ) ) ; Assert . assertTrue ( iA > iB ) ; Assert . assertTrue ( iA > iC && iB > iC ) ; }
Test that imagery is sorted as expected
Test that imagery is sorted as expected
// alphabetic // date // preference