Changeset 10405 in josm for trunk/test


Ignore:
Timestamp:
2016-06-16T19:14:33+02:00 (4 years ago)
Author:
Don-vip
Message:

fix #12959 - Do not make unit tests rely on JFrame for headless mode (patch by michael2402) - gsoc-core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java

    r10402 r10405  
    99import java.awt.geom.Point2D;
    1010
    11 import javax.swing.JFrame;
     11import javax.swing.JPanel;
    1212
    1313import org.CustomMatchers;
     
    3232public class NavigatableComponentTest {
    3333
     34    private final class NavigatableComponentMock extends NavigatableComponent {
     35        @Override
     36        public Point getLocationOnScreen() {
     37            return new Point(30, 40);
     38        }
     39
     40        @Override
     41        protected boolean isVisibleOnScreen() {
     42            return true;
     43        }
     44    }
     45
    3446    private static final int HEIGHT = 200;
    3547    private static final int WIDTH = 300;
     
    4860    @Before
    4961    public void setUp() {
    50         component = new NavigatableComponent() {
    51             @Override
    52             public Point getLocationOnScreen() {
    53                 return new Point(30, 40);
    54             }
    55         };
     62        component = new NavigatableComponentMock();
    5663        component.setBounds(new Rectangle(WIDTH, HEIGHT));
    5764        // wait for the event to be propagated.
     
    6269        });
    6370        component.setVisible(true);
    64         JFrame window = new JFrame();
    65         window.add(component);
     71        JPanel parent = new JPanel();
     72        parent.add(component);
    6673        component.updateLocationState();
    6774    }
Note: See TracChangeset for help on using the changeset viewer.