import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
+import java.awt.event.MouseEvent;
import java.lang.reflect.InvocationTargetException;
import javax.swing.SwingUtilities;
* width for onscreen rendering is IDPanel width
*/
int w = af.alignPanel.getVisibleIdWidth(true);
- assertEquals(w, af.alignPanel.getIdPanel().getWidth());
+ int actual = af.alignPanel.getIdPanel().getWidth();
+ assertEquals(w, actual);
assertEquals(w, 115);
// manually adjust
af.viewport.setIdWidth(200);
+ // fake mouse drag sets manuallyAdjusted to true (0,0 not moving mouse)
+ MouseEvent drag = new MouseEvent(af.alignPanel,
+ MouseEvent.MOUSE_DRAGGED, System.currentTimeMillis(), 0, 0, 0,
+ MouseEvent.BUTTON1, false);
+ af.alignPanel.idwidthAdjuster.mouseDragged(drag);
+ af.alignPanel.paintComponent(af.alignPanel.getGraphics());
w = af.alignPanel.calculateIdWidth().width;
assertTrue(
af.alignPanel.getIdPanel().getIdCanvas().isManuallyAdjusted());
- assertEquals(w, af.alignPanel.getIdPanel().getWidth());
+ actual = af.alignPanel.getIdPanel().getWidth();
+ assertEquals(w, actual);
af.viewport.setIdWidth(-1);
af.alignPanel.getIdPanel().getIdCanvas().setManuallyAdjusted(false);
w = af.alignPanel.calculateIdWidth().width;
+ af.alignPanel.paintComponent(af.alignPanel.getGraphics());
- assertEquals(w, af.alignPanel.getIdPanel().getWidth());
+ actual = af.alignPanel.getIdPanel().getWidth();
+ assertEquals(w, actual);
- assertNotEquals(w, 115);
+ // setting a negative IdWidth and then running calculateIdWidth resets width
+ // to optimal id width
+ assertEquals(w, 115);
}
@Test(groups = "Functional")