| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.gui; |
| 22 |
|
|
| 23 |
|
import java.awt.Font; |
| 24 |
|
import java.io.File; |
| 25 |
|
|
| 26 |
|
import javax.swing.SwingUtilities; |
| 27 |
|
|
| 28 |
|
import org.testng.Assert; |
| 29 |
|
import org.testng.annotations.AfterMethod; |
| 30 |
|
import org.testng.annotations.BeforeClass; |
| 31 |
|
import org.testng.annotations.Test; |
| 32 |
|
|
| 33 |
|
import jalview.bin.Console; |
| 34 |
|
import jalview.bin.Jalview; |
| 35 |
|
import jalview.datamodel.AlignmentI; |
| 36 |
|
import jalview.io.DataSourceType; |
| 37 |
|
import jalview.io.FileLoader; |
| 38 |
|
import jalview.io.exceptions.ImageOutputException; |
| 39 |
|
import jalview.schemes.ColourSchemeI; |
| 40 |
|
import jalview.schemes.ColourSchemeProperty; |
| 41 |
|
import jalview.structure.StructureSelectionManager; |
| 42 |
|
|
| |
|
| 18.2% |
Uncovered Elements: 54 (66) |
Complexity: 18 |
Complexity Density: 0.37 |
|
| 43 |
|
public class ImageExporterTest |
| 44 |
|
{ |
| 45 |
|
|
| 46 |
|
String exportFile = "test/files/exported.svg"; |
| 47 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 48 |
1 |
@BeforeClass(alwaysRun = true)... |
| 49 |
|
public void setUpJvOptionPane() |
| 50 |
|
{ |
| 51 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 52 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 53 |
|
} |
| 54 |
|
|
| 55 |
|
AlignmentI al; |
| 56 |
|
|
| 57 |
|
AlignViewport testee; |
| 58 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 59 |
1 |
@BeforeClass(alwaysRun = true)... |
| 60 |
|
public static void setUpBeforeClass() throws Exception |
| 61 |
|
{ |
| 62 |
1 |
Jalview.main( |
| 63 |
|
new String[] |
| 64 |
|
{ "--nonews", "--nosplash", "--props", |
| 65 |
|
"test/jalview/testProps.jvprops" }); |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
1 |
StructureSelectionManager ssm = StructureSelectionManager |
| 71 |
|
.getStructureSelectionManager(Desktop.instance); |
| 72 |
1 |
ssm.resetAll(); |
| 73 |
|
} |
| 74 |
|
|
| |
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 75 |
1 |
@AfterMethod(alwaysRun = true)... |
| 76 |
|
public void tearDown() |
| 77 |
|
{ |
| 78 |
1 |
File exportedFile = new File(exportFile); |
| 79 |
1 |
if (exportedFile.exists()) |
| 80 |
|
{ |
| 81 |
1 |
exportedFile.delete(); |
| 82 |
|
} |
| 83 |
|
} |
| 84 |
|
|
| |
|
| 0% |
Uncovered Elements: 39 (39) |
Complexity: 8 |
Complexity Density: 0.24 |
3FAIL
|
|
| 85 |
0 |
@Test(groups = { "Functional" }, timeOut = 30000)... |
| 86 |
|
public void testExportSVG() |
| 87 |
|
{ |
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
0 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
| 92 |
|
"examples/PF03760.fa", DataSourceType.FILE); |
| 93 |
0 |
ColourSchemeI cs = ColourSchemeProperty.getColourScheme( |
| 94 |
|
af.getViewport(), af.getViewport().getAlignment(), |
| 95 |
|
"gecos-blossom"); |
| 96 |
0 |
Font f = af.alignPanel.av.getFont(); |
| 97 |
0 |
af.alignPanel.av.setFont(f.deriveFont(24f), true); |
| 98 |
|
|
| 99 |
0 |
try |
| 100 |
|
{ |
| 101 |
0 |
SwingUtilities.invokeAndWait(new Runnable() |
| 102 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 103 |
0 |
@Override... |
| 104 |
|
public void run() |
| 105 |
|
{ |
| 106 |
|
|
| 107 |
0 |
af.changeColour(cs); |
| 108 |
|
} |
| 109 |
|
}); |
| 110 |
|
} catch (Exception x) |
| 111 |
|
{ |
| 112 |
0 |
Console.trace("Interrupted whilst waiting for colorAlignFrame action", |
| 113 |
|
x); |
| 114 |
|
|
| 115 |
|
} |
| 116 |
0 |
af.setWrapFormat(true, true); |
| 117 |
|
|
| 118 |
|
|
| 119 |
0 |
waitForCalculations(af.getViewport()); |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
0 |
String filename = exportFile; |
| 127 |
0 |
File output = new File(filename); |
| 128 |
0 |
Thread exportThread = new Thread(new Runnable() |
| 129 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 130 |
0 |
@Override... |
| 131 |
|
public void run() |
| 132 |
|
{ |
| 133 |
0 |
try |
| 134 |
|
{ |
| 135 |
0 |
af.createSVG(output, "lineart"); |
| 136 |
|
} catch (ImageOutputException e) |
| 137 |
|
{ |
| 138 |
0 |
Assert.fail("An exception occurred when exporting SVG file to " |
| 139 |
|
+ filename); |
| 140 |
|
} |
| 141 |
|
} |
| 142 |
|
}); |
| 143 |
|
|
| 144 |
|
|
| 145 |
0 |
exportThread.start(); |
| 146 |
|
|
| 147 |
|
|
| 148 |
0 |
final int maxSecondsProdding = 10; |
| 149 |
0 |
final int proddingInterval = 20; |
| 150 |
0 |
SeqCanvas sc = af.alignPanel.getSeqPanel().seqCanvas; |
| 151 |
0 |
for (int i = 0; i < maxSecondsProdding * 1000 / proddingInterval; i++) |
| 152 |
|
{ |
| 153 |
0 |
if (!exportThread.isAlive()) |
| 154 |
|
{ |
| 155 |
0 |
break; |
| 156 |
|
} |
| 157 |
0 |
try |
| 158 |
|
{ |
| 159 |
0 |
Thread.sleep(proddingInterval); |
| 160 |
|
} catch (InterruptedException e) |
| 161 |
|
{ |
| 162 |
0 |
e.printStackTrace(); |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
0 |
sc.calculateWrappedGeometry(sc.getWidth(), sc.getHeight()); |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
|
| 171 |
0 |
while (exportThread.isAlive()) |
| 172 |
|
{ |
| 173 |
0 |
try |
| 174 |
|
{ |
| 175 |
0 |
Thread.sleep(500); |
| 176 |
|
} catch (InterruptedException e) |
| 177 |
|
{ |
| 178 |
0 |
e.printStackTrace(); |
| 179 |
|
} |
| 180 |
|
} |
| 181 |
|
|
| 182 |
|
|
| 183 |
0 |
try |
| 184 |
|
{ |
| 185 |
0 |
Thread.sleep(2000); |
| 186 |
|
} catch (InterruptedException e) |
| 187 |
|
{ |
| 188 |
0 |
e.printStackTrace(); |
| 189 |
|
} |
| 190 |
|
|
| 191 |
0 |
long fileSize = output.length(); |
| 192 |
0 |
long expectedMinSize = 120000 * 1024; |
| 193 |
0 |
Assert.assertTrue(fileSize > expectedMinSize, |
| 194 |
|
"Exported file size (" + fileSize |
| 195 |
|
+ ") is not as big as it should be (>" + expectedMinSize |
| 196 |
|
+ ")"); |
| 197 |
|
} |
| 198 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 199 |
0 |
private void waitForCalculations(AlignViewport viewport)... |
| 200 |
|
{ |
| 201 |
0 |
synchronized (this) |
| 202 |
|
{ |
| 203 |
0 |
do |
| 204 |
|
{ |
| 205 |
0 |
try |
| 206 |
|
{ |
| 207 |
0 |
wait(50); |
| 208 |
|
} catch (InterruptedException e) |
| 209 |
|
{ |
| 210 |
|
} |
| 211 |
0 |
} while (viewport.getCalcManager().isWorking()); |
| 212 |
|
} |
| 213 |
|
} |
| 214 |
|
|
| 215 |
|
} |