1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.bin; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
|
25 |
|
import org.mockito.Mockito; |
26 |
|
import org.testng.annotations.AfterClass; |
27 |
|
import org.testng.annotations.BeforeMethod; |
28 |
|
import org.testng.annotations.Test; |
29 |
|
|
30 |
|
import jalview.gui.AlignFrame; |
31 |
|
import jalview.gui.Desktop; |
32 |
|
import jalview.gui.JvOptionPane; |
33 |
|
import jalview.io.DataSourceType; |
34 |
|
import jalview.io.FileLoader; |
35 |
|
import jalview.util.Platform; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
|
|
| 88.6% |
Uncovered Elements: 5 (44) |
Complexity: 10 |
Complexity Density: 0.33 |
|
52 |
|
public class HiDPISettingTest1 |
53 |
|
{ |
54 |
|
|
55 |
|
AlignFrame af = null; |
56 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
57 |
1 |
@BeforeMethod(alwaysRun = true)... |
58 |
|
public void setUp() |
59 |
|
{ |
60 |
1 |
JvOptionPane.setInteractiveMode(false); |
61 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
62 |
1 |
Cache.loadProperties("test/jalview/bin/hidpiTestProps.jvprops"); |
63 |
1 |
Jalview.main( |
64 |
|
new String[] |
65 |
|
{ "--nosplash", "--nonews", "--noquestionnaire", |
66 |
|
"--nowebservicediscovery" }); |
67 |
|
|
68 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa", |
69 |
|
DataSourceType.FILE); |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
1 |
do |
75 |
|
{ |
76 |
1 |
try |
77 |
|
{ |
78 |
1 |
Thread.sleep(50); |
79 |
|
} catch (InterruptedException x) |
80 |
|
{ |
81 |
|
} |
82 |
1 |
} while (af.getViewport().getCalcManager().isWorking()); |
83 |
|
} |
84 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
85 |
1 |
@AfterClass(alwaysRun = true)... |
86 |
|
public void tearDown() |
87 |
|
{ |
88 |
1 |
if (Desktop.instance != null) |
89 |
1 |
Desktop.instance.closeAll_actionPerformed(null); |
90 |
|
} |
91 |
|
|
|
|
| 85% |
Uncovered Elements: 3 (20) |
Complexity: 4 |
Complexity Density: 0.29 |
1PASS
|
|
92 |
1 |
@Test(groups = { "Functional" })... |
93 |
|
public void testHiDPISettingInit() |
94 |
|
{ |
95 |
1 |
String scalePropertyName = "sun.java2d.uiScale"; |
96 |
|
|
97 |
1 |
System.clearProperty(HiDPISetting.scalePropertyName); |
98 |
|
|
99 |
|
{ |
100 |
|
|
101 |
1 |
setMockScreen(1024, 768, 72); |
102 |
1 |
assertEquals(HiDPISetting.getScalePropertyArg(), null); |
103 |
|
|
104 |
|
|
105 |
1 |
setMockScreen(1200, 800, 96); |
106 |
1 |
assertEquals(HiDPISetting.getScalePropertyArg(), null); |
107 |
|
|
108 |
|
|
109 |
1 |
setMockScreen(1920, 1080, 96); |
110 |
1 |
assertEquals(HiDPISetting.getScalePropertyArg(), null); |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
1 |
setMockScreen(3180, 2160, 80); |
116 |
1 |
assertEquals(HiDPISetting.getScalePropertyArg(), |
117 |
1 |
Platform.isLinux() ? "-D" + scalePropertyName + "=2" : null); |
118 |
|
|
119 |
|
|
120 |
1 |
setMockScreen(3180, 2160, 450); |
121 |
1 |
assertEquals(HiDPISetting.getScalePropertyArg(), |
122 |
1 |
Platform.isLinux() ? "-D" + scalePropertyName + "=3" : null); |
123 |
|
|
124 |
|
|
125 |
1 |
setMockScreen(19200, 10800, 72); |
126 |
1 |
assertEquals(HiDPISetting.getScalePropertyArg(), |
127 |
1 |
Platform.isLinux() ? "-D" + scalePropertyName + "=8" : null); |
128 |
|
} |
129 |
|
} |
130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
131 |
6 |
private void setMockScreen(int width, int height, int dpi)... |
132 |
|
{ |
133 |
6 |
HiDPISetting.clear(); |
134 |
6 |
ScreenInfo mockScreenInfo = Mockito.spy(HiDPISetting.getScreenInfo()); |
135 |
6 |
Mockito.doReturn(height).when(mockScreenInfo).getScreenHeight(); |
136 |
6 |
Mockito.doReturn(width).when(mockScreenInfo).getScreenWidth(); |
137 |
6 |
Mockito.doReturn(dpi).when(mockScreenInfo).getScreenResolution(); |
138 |
6 |
HiDPISetting.setScreenInfo(mockScreenInfo); |
139 |
|
} |
140 |
|
} |