JAL-1805 test envirionment separation
[jalview.git] / test / jalview / gui / JvSwingUtilsTest.java
1 package jalview.gui;
2
3 import static org.testng.AssertJUnit.assertEquals;
4
5 import javax.swing.JScrollBar;
6
7 import org.testng.annotations.Test;
8
9 public class JvSwingUtilsTest
10 {
11
12   @Test(groups ={ "Functional" })
13   public void testGetScrollBarProportion()
14   {
15     /*
16      * orientation, value, extent (width), min, max
17      */
18     JScrollBar sb = new JScrollBar(0, 125, 50, 0, 450);
19
20     /*
21      * operating range is 25 - 425 (400 wide) so value 125 is 100/400ths of this
22      * range
23      */
24     assertEquals(0.25f, JvSwingUtils.getScrollBarProportion(sb), 0.001f);
25   }
26
27   @Test(groups ={ "Functional" })
28   public void testGetScrollValueForProportion()
29   {
30     /*
31      * orientation, value, extent (width), min, max
32      */
33     JScrollBar sb = new JScrollBar(0, 125, 50, 0, 450);
34
35     /*
36      * operating range is 25 - 425 (400 wide) so value 125 is a quarter of this
37      * range
38      */
39     assertEquals(125, JvSwingUtils.getScrollValueForProportion(sb, 0.25f));
40   }
41 }