Changeset 17834 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2021-04-28T22:01:28+02:00 (4 years ago)
Author:
simon04
Message:

see #20813 - Add ImageDisplayTest.testLoadImageRunnablePerformance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplayTest.java

    r17275 r17834  
    55
    66import java.awt.Dimension;
     7import java.awt.Graphics2D;
    78import java.awt.Rectangle;
     9import java.awt.image.BufferedImage;
     10import java.nio.file.DirectoryStream;
     11import java.nio.file.Files;
     12import java.nio.file.Path;
     13import java.nio.file.Paths;
    814
     15import org.junit.jupiter.api.Disabled;
    916import org.junit.jupiter.api.extension.RegisterExtension;
    1017import org.junit.jupiter.api.Test;
    1118import org.openstreetmap.josm.gui.layer.geoimage.ImageDisplay.VisRect;
     19import org.openstreetmap.josm.gui.layer.imagery.ImageryFilterSettings;
    1220import org.openstreetmap.josm.testutils.JOSMTestRules;
    1321
     
    4351                ImageDisplay.calculateDrawImageRectangle(new VisRect(0, 0, 10, 5), new Dimension(8, 6)));
    4452    }
     53
     54    /**
     55     * Performance test for {@link ImageDisplay.LoadImageRunnable}
     56     * @throws Exception if any error occurs
     57     */
     58    @Test
     59    @Disabled("Set working directory to image folder and run manually")
     60    void testLoadImageRunnablePerformance() throws Exception {
     61        ImageDisplay imageDisplay = new ImageDisplay(new ImageryFilterSettings());
     62        imageDisplay.setSize(640, 480);
     63        Graphics2D graphics = new BufferedImage(640, 480, BufferedImage.TYPE_INT_RGB).createGraphics();
     64        try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(".").toAbsolutePath(), "*.{JPG,jpg}")) {
     65            for (Path p : stream) {
     66                Runnable loadImage = imageDisplay.setImage0(new ImageEntry(p.toFile()));
     67                loadImage.run();
     68                imageDisplay.paintComponent(graphics);
     69            }
     70        }
     71    }
    4572}
Note: See TracChangeset for help on using the changeset viewer.