3 import static org.testng.AssertJUnit.assertEquals;
4 import org.testng.annotations.Test;
5 import javax.swing.JScrollBar;
7 public class JvSwingUtilsTest
11 public void testGetScrollBarProportion()
14 * orientation, value, extent (width), min, max
16 JScrollBar sb = new JScrollBar(0, 125, 50, 0, 450);
19 * operating range is 25 - 425 (400 wide) so value 125 is 100/400ths of this
22 assertEquals(0.25f, JvSwingUtils.getScrollBarProportion(sb), 0.001f);
26 public void testGetScrollValueForProportion()
29 * orientation, value, extent (width), min, max
31 JScrollBar sb = new JScrollBar(0, 125, 50, 0, 450);
34 * operating range is 25 - 425 (400 wide) so value 125 is a quarter of this
37 assertEquals(125, JvSwingUtils.getScrollValueForProportion(sb, 0.25f));