6 import org.testng.Assert;
7 import org.testng.annotations.AfterClass;
8 import org.testng.annotations.AfterMethod;
9 import org.testng.annotations.BeforeClass;
10 import org.testng.annotations.DataProvider;
11 import org.testng.annotations.Test;
13 import jalview.api.AlignViewportI;
14 import jalview.datamodel.AlignmentAnnotation;
15 import jalview.datamodel.AlignmentI;
16 import jalview.datamodel.SequenceI;
17 import jalview.gui.AlignFrame;
18 import jalview.gui.AlignmentPanel;
19 import jalview.gui.Desktop;
20 import jalview.gui.JvOptionPane;
21 import jalview.gui.StructureViewerBase;
24 public class CommandsTest2
26 @BeforeClass(alwaysRun = true)
27 public static void setUpBeforeClass() throws Exception
29 Cache.loadProperties("test/jalview/bin/commandsTest.jvprops");
30 Date oneHourFromNow = new Date(
31 System.currentTimeMillis() + 3600 * 1000);
32 Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", oneHourFromNow);
33 if (Desktop.instance != null)
34 Desktop.instance.closeAll_actionPerformed(null);
38 @AfterClass(alwaysRun = true)
39 public static void resetProps()
41 Cache.loadProperties("test/jalview/testProps.jvprops");
44 @BeforeClass(alwaysRun = true)
45 public void setUpJvOptionPane()
47 JvOptionPane.setInteractiveMode(false);
48 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
51 @AfterMethod(alwaysRun = true)
52 public void tearDown()
54 if (Desktop.instance != null)
55 Desktop.instance.closeAll_actionPerformed(null);
61 dataProvider = "structureOpeningArgsParams")
62 public void structureOpeningArgsTest(String cmdLine, int seqNum,
63 int annNum, int viewerNum)
65 String[] args = cmdLine.split("\\s+");
68 AlignFrame[] afs = Desktop.getAlignFrames();
69 Assert.assertNotNull(afs);
70 Assert.assertTrue(afs.length > 0);
72 AlignFrame af = afs[0];
73 Assert.assertNotNull(af);
75 AlignmentPanel ap = af.alignPanel;
76 Assert.assertNotNull(ap);
78 AlignmentI al = ap.getAlignment();
79 Assert.assertNotNull(al);
81 List<SequenceI> seqs = al.getSequences();
82 Assert.assertNotNull(seqs);
84 Assert.assertEquals(seqs.size(), seqNum, "Wrong number of sequences");
86 AlignViewportI av = ap.getAlignViewport();
87 Assert.assertNotNull(av);
89 AlignmentAnnotation[] aas = al.getAlignmentAnnotation();
91 for (AlignmentAnnotation aa : aas)
97 Assert.assertEquals(visibleAnn, annNum,
98 "Wrong number of visible annotations");
104 // sleep for slow build server to open viewer window
106 } catch (InterruptedException e)
110 List<StructureViewerBase> openViewers = Desktop.instance
111 .getStructureViewers(ap, null);
112 Assert.assertNotNull(openViewers);
115 for (StructureViewerBase svb : openViewers)
117 System.err.println("##### DIAGNOSIS: annotation " + dcount
118 + " is called '" + svb.getName() + "'");
122 Assert.assertEquals(count, viewerNum,
123 "Wrong number of structure viewers opened");
127 @DataProvider(name = "structureOpeningArgsParams")
128 public Object[][] structureOpeningArgsParams()
137 return new Object[][] {
141 { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
142 + "--colour=gecos:flower "
143 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
144 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
145 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
147 { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
148 + "--colour=gecos:flower "
149 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
150 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
151 + "--props=test/jalview/bin/commandsTest2.jvprops2 ",
153 { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
154 + "--colour=gecos:flower "
155 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
156 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
157 + "--nossannotations "
158 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
160 { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
161 + "--colour=gecos:flower "
162 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
163 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
165 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
167 { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
168 + "--colour=gecos:flower "
169 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
170 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
171 + "--noannotations " + "--nossannotations "
172 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
174 { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
175 + "--colour=gecos:flower "
176 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
177 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
178 + "--noannotations " + "--nossannotations "
179 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
181 { "--argfile=test/jalview/bin/commandsTest2.argfile1 ", 16, 19, 3 },
182 { "--argfile=test/jalview/bin/commandsTest2.argfile2 ", 16, 0, 2 },