package jalview.gui; import static org.junit.Assert.assertEquals; import javax.swing.JScrollBar; import org.junit.Test; public class JvSwingUtilsTest { @Test public void testGetScrollBarProportion() { /* * orientation, value, extent (width), min, max */ JScrollBar sb = new JScrollBar(0, 125, 50, 0, 450); /* * operating range is 25 - 425 (400 wide) so value 125 is 100/400ths of this * range */ assertEquals(0.25f, JvSwingUtils.getScrollBarProportion(sb), 0.001f); } @Test public void testGetScrollValueForProportion() { /* * orientation, value, extent (width), min, max */ JScrollBar sb = new JScrollBar(0, 125, 50, 0, 450); /* * operating range is 25 - 425 (400 wide) so value 125 is a quarter of this * range */ assertEquals(125, JvSwingUtils.getScrollValueForProportion(sb, 0.25f)); } }