@SuppressWarnings("serial")
@Test
public void testRepaintManager() {
final AtomicReference<JComponent> reference = new AtomicReference<JComponent>();
GlassPanelRepaintManager repaintManager = new GlassPanelRepaintManager() {
@Override
void addDirtyRegionToSuperRepaintManager(JComponent c, int x, int y, int w, int h) {
reference.set(c);
}
};
// Test control manifestation and its glass panel
JPanel controlPanel = new JPanel();
ControlWrapper controlWrapper = new ControlWrapper(controlPanel);
repaintManager.addDirtyRegion(controlPanel, 0, 0, 0, 0);
Assert.assertSame(reference.get(), controlWrapper.getGlassPanel());
// Test view manifestation and its glass panel
View manifestation = new View() {
@Override
public AbstractComponent getManifestedComponent() {
return Mockito.mock(AbstractComponent.class);
}
};
repaintManager.addDirtyRegion(manifestation, 0, 0, 0, 0);
Assert.assertSame(reference.get(), manifestation);
// Test other unrelated JComponent
JComponent widget = Mockito.mock(JComponent.class);
repaintManager.addDirtyRegion(widget, 0, 0, 0, 0);
Assert.assertSame(reference.get(), widget);
}