DrawablePanel extends JPanel { @Override public void setBounds(Rectangle bounds) { super.setBounds(bounds); getDrawable().setBounds(bounds); } DrawablePanel(Drawable drawable); Drawable getDrawable(); @Override void setBounds(Rectangle bounds); @Override void setBounds(int x, int y, int width, int height); @Override Dimension getPreferredSize(); @Override Dimension getMinimumSize(); boolean isAntialiased(); void setAntialiased(boolean antialiased);  }
@Test public void testBounds() { Rectangle bounds; bounds = panel.getBounds(); assertEquals(0.0, bounds.getX(), DELTA); assertEquals(0.0, bounds.getY(), DELTA); assertEquals(0.0, bounds.getWidth(), DELTA); assertEquals(0.0, bounds.getHeight(), DELTA); assertEquals(bounds.getX(), panel.getX(), DELTA); assertEquals(bounds.getY(), panel.getY(), DELTA); assertEquals(bounds.getWidth(), panel.getWidth(), DELTA); assertEquals(bounds.getHeight(), panel.getHeight(), DELTA); panel.setBounds(new Rectangle(1, 2, 10, 20)); bounds = panel.getBounds(); assertEquals( 1.0, bounds.getX(), DELTA); assertEquals( 2.0, bounds.getY(), DELTA); assertEquals(10.0, bounds.getWidth(), DELTA); assertEquals(20.0, bounds.getHeight(), DELTA); panel.setBounds(3, 4, 30, 40); bounds = panel.getBounds(); assertEquals( 3.0, bounds.getX(), DELTA); assertEquals( 4.0, bounds.getY(), DELTA); assertEquals(30.0, bounds.getWidth(), DELTA); assertEquals(40.0, bounds.getHeight(), DELTA); }
@Test public void testDraw() { BufferedImage image = createTestImage(); panel.setBounds(0, 0, image.getWidth(), image.getHeight()); panel.paint(image.getGraphics()); assertNotEmpty(image); }