Changeset 7142 in josm for trunk/test/performance


Ignore:
Timestamp:
2014-05-18T18:04:18+02:00 (6 years ago)
Author:
Don-vip
Message:

see #9691 - make unit test run in headless mode for continuous integration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.groovy

    r7141 r7142  
    88
    99import org.junit.*
     10import org.openstreetmap.josm.JOSMFixture
    1011import org.openstreetmap.josm.Main
    1112import org.openstreetmap.josm.data.Bounds
     
    1314import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer
    1415import org.openstreetmap.josm.gui.MainApplication
    15 import org.openstreetmap.josm.gui.layer.OsmDataLayer
     16import org.openstreetmap.josm.gui.NavigatableComponent
    1617import org.openstreetmap.josm.gui.mappaint.MapPaintStyles
    1718import org.openstreetmap.josm.gui.preferences.SourceEntry
     19import org.openstreetmap.josm.gui.preferences.ToolbarPreferences
    1820import org.openstreetmap.josm.io.Compression
    1921import org.openstreetmap.josm.io.OsmReader
     
    2729
    2830    /* ------------------------ configuration section  ---------------------------- */
    29     /**
    30      * The path to the JOSM home environment
    31      */
    32     def static JOSM_HOME="test/config/performance-josm.home"
    33 
    3431    /**
    3532     * The path to the style file used for rendering.
     
    4643
    4744    def static boolean checkTestEnvironment() {
    48           File f = new File(JOSM_HOME)
    49           if  (!f.isDirectory() || !f.exists()) {
    50               fail("JOSM_HOME refers to '${JOSM_HOME}. This is either not a directory or doesn't exist.\nPlease update configuration settings in the unit test file.")
    51           }
    52 
    53           f = new File(STYLE_FILE);
     45          File f = new File(STYLE_FILE);
    5446          if ( !f.isFile() || ! f.exists()) {
    5547              fail("STYLE_FILE refers to '${STYLE_FILE}. This is either not a file or doesn't exist.\nPlease update configuration settings in the unit test file.")
     
    5850
    5951    @BeforeClass
    60     public static void createJOSMFixture(){
    61         checkTestEnvironment()
    62         System.setProperty("josm.home", JOSM_HOME)
    63         MainApplication.main(new String[0])
     52    public static void createJOSMFixture() {
     53        JOSMFixture.createPerformanceTestFixture().init();
     54        Main.toolbar = new ToolbarPreferences();
     55        new MainApplication();
    6456    }
    6557
     
    7163    }
    7264
    73     def  loadStyle() {
     65    def loadStyle() {
    7466        print "Loading style '$STYLE_FILE' ..."
    7567        MapCSSStyleSource source = new MapCSSStyleSource(
     
    9385        print "Loading data file '$DATA_FILE' ..."
    9486        ds = OsmReader.parseDataSet(Compression.getUncompressedFileInputStream(new File(DATA_FILE)), null);
    95         Main.main.addLayer(new OsmDataLayer(ds,"test layer",null /* no file */));
    9687        println "DONE"
    9788    }
     
    10293        loadData()
    10394
    104         def mv = Main.map.mapView
    105 
     95        NavigatableComponent mv = new NavigatableComponent();
     96        mv.setBounds(0, 0, 1024, 768)
    10697        BufferedImage img = new BufferedImage(mv.getWidth(), mv.getHeight(), BufferedImage.TYPE_3BYTE_BGR)
    10798        Graphics2D g = img.createGraphics()
    10899        g.setClip(0,0, mv.getWidth(), mv.getHeight())
    109         def visitor = new StyledMapRenderer(g, Main.map.mapView, false)
     100        StyledMapRenderer visitor = new StyledMapRenderer(g, mv, false)
    110101
    111102        print "Rendering ..."
Note: See TracChangeset for help on using the changeset viewer.