Changeset 16983 in josm


Ignore:
Timestamp:
2020-08-30T21:08:19+02:00 (4 weeks ago)
Author:
simon04
Message:

see #18694 - Extract ImageProviderTestManual, ImageProviderTestIT

Location:
trunk/test/functional/org/openstreetmap/josm/tools
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/functional/org/openstreetmap/josm/tools/ImageProviderTest.java

    r16982 r16983  
    1010import static org.openstreetmap.josm.gui.mappaint.MapCSSRendererTest.assertImageEquals;
    1111
    12 import java.awt.Color;
    1312import java.awt.Dimension;
    14 import java.awt.Graphics;
    1513import java.awt.GraphicsEnvironment;
    16 import java.awt.GridLayout;
    1714import java.awt.Image;
    1815import java.awt.Point;
    1916import java.awt.Toolkit;
    2017import java.awt.Transparency;
    21 import java.awt.event.MouseEvent;
    22 import java.awt.event.MouseListener;
    2318import java.awt.image.BufferedImage;
    2419import java.io.File;
     
    3227
    3328import javax.swing.ImageIcon;
    34 import javax.swing.JFrame;
    35 import javax.swing.JPanel;
    3629
    3730import org.junit.Before;
    3831import org.junit.BeforeClass;
    39 import org.junit.Ignore;
    4032import org.junit.Rule;
    4133import org.junit.Test;
     
    161153
    162154    /**
    163      * Test fetching an image using {@code wiki://} protocol.
    164      */
    165     @Test
    166     public void testWikiProtocol() {
    167         // https://commons.wikimedia.org/wiki/File:OpenJDK_logo.svg
    168         assertNotNull(ImageProvider.get("wiki://OpenJDK_logo.svg"));
    169     }
    170 
    171     /**
    172155     * Test fetching an image using {@code data:} URL.
    173156     */
     
    309292    }
    310293
    311 
    312     /**
    313      * Test getting a cursor
    314      */
    315     @Ignore("manual execution only, as the look of the cursor cannot be checked automatedly")
    316     @Test
    317     public void testGetCursor() throws InterruptedException {
    318         JFrame frame = new JFrame();
    319         frame.setSize(500, 500);
    320         frame.setLayout(new GridLayout(2, 2));
    321         JPanel leftUpperPanel = new JPanel(), rightUpperPanel = new JPanel(), leftLowerPanel = new JPanel(), rightLowerPanel = new JPanel();
    322         leftUpperPanel.setBackground(Color.DARK_GRAY);
    323         rightUpperPanel.setBackground(Color.DARK_GRAY);
    324         leftLowerPanel.setBackground(Color.DARK_GRAY);
    325         rightLowerPanel.setBackground(Color.DARK_GRAY);
    326         frame.add(leftUpperPanel);
    327         frame.add(rightUpperPanel);
    328         frame.add(leftLowerPanel);
    329         frame.add(rightLowerPanel);
    330 
    331         leftUpperPanel.setCursor(ImageProvider.getCursor("normal", "select_add")); // contains diagonal sensitive to alpha blending
    332         rightUpperPanel.setCursor(ImageProvider.getCursor("crosshair", "joinway")); // combination of overlay and hotspot not top left
    333         leftLowerPanel.setCursor(ImageProvider.getCursor("hand", "parallel_remove")); // reasonably nice bitmap cursor
    334         rightLowerPanel.setCursor(ImageProvider.getCursor("rotate", null)); // ugly bitmap cursor, cannot do much here
    335 
    336         frame.setVisible(true);
    337 
    338         // hover over the four quadrant to observe different cursors
    339 
    340         // draw red dot at hotspot when clicking
    341         frame.addMouseListener(new MouseListener() {
    342             @Override
    343             public void mouseClicked(MouseEvent e) {
    344                 Graphics graphics = frame.getGraphics();
    345                 graphics.setColor(Color.RED);
    346                 graphics.drawRect(e.getX(), e.getY(), 1, 1);
    347             }
    348 
    349             @Override
    350             public void mousePressed(MouseEvent e) { }
    351 
    352             @Override
    353             public void mouseReleased(MouseEvent e) { }
    354 
    355             @Override
    356             public void mouseEntered(MouseEvent e) { }
    357 
    358             @Override
    359             public void mouseExited(MouseEvent e) { }
    360         });
    361         Thread.sleep(9000); // test would time out after 10s
    362     }
    363294}
Note: See TracChangeset for help on using the changeset viewer.