JAL-4386 Fixed failed test cases
[jalview.git] / test / jalview / bin / CommandsTest2.java
index 71452e2..aa3c834 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.bin;
 
 import java.util.Date;
@@ -26,7 +46,7 @@ public class CommandsTest2
   @BeforeClass(alwaysRun = true)
   public static void setUpBeforeClass() throws Exception
   {
-    Cache.loadProperties("test/jalview/testProps.jvprops");
+    Cache.loadProperties("test/jalview/bin/commandsTest.jvprops");
     Date oneHourFromNow = new Date(
             System.currentTimeMillis() + 3600 * 1000);
     Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", oneHourFromNow);
@@ -51,21 +71,35 @@ public class CommandsTest2
   @AfterMethod(alwaysRun = true)
   public void tearDown()
   {
-    if (Desktop.instance != null)
-      Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.closeDesktop();
   }
 
   @Test(
     groups =
-    { "Functional" },
-    dataProvider = "structureOpeningArgsParams")
+    { "Functional", "testTask1" },
+    dataProvider = "structureOpeningArgsParams",
+    singleThreaded = true)
   public void structureOpeningArgsTest(String cmdLine, int seqNum,
           int annNum, int viewerNum)
   {
     String[] args = cmdLine.split("\\s+");
 
-    Jalview.main(args);
-    AlignFrame[] afs = Desktop.getAlignFrames();
+    CommandsTest.callJalviewMain(args);
+    while (Desktop.instance != null
+            && Desktop.instance.operationsAreInProgress())
+    {
+      try
+      {
+        // sleep for slow build server to open annotations and viewer windows
+        Thread.sleep(viewerNum * 50);
+      } catch (InterruptedException e)
+      {
+        e.printStackTrace();
+      }
+    }
+    ;
+
+    AlignFrame[] afs = Desktop.getDesktopAlignFrames();
     Assert.assertNotNull(afs);
     Assert.assertTrue(afs.length > 0);
 
@@ -88,6 +122,7 @@ public class CommandsTest2
 
     AlignmentAnnotation[] aas = al.getAlignmentAnnotation();
     int visibleAnn = 0;
+    int dcount = 0;
     for (AlignmentAnnotation aa : aas)
     {
       if (aa.visible)
@@ -99,18 +134,16 @@ public class CommandsTest2
 
     if (viewerNum > -1)
     {
-      try
-      {
-        Thread.sleep(100);
-      } catch (InterruptedException e)
-      {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
-      }
       List<StructureViewerBase> openViewers = Desktop.instance
               .getStructureViewers(ap, null);
       Assert.assertNotNull(openViewers);
-      Assert.assertEquals(openViewers.size(), viewerNum,
+      int count = 0;
+      for (StructureViewerBase svb : openViewers)
+      {
+        if (svb.isVisible())
+          count++;
+      }
+      Assert.assertEquals(count, viewerNum,
               "Wrong number of structure viewers opened");
     }
   }
@@ -122,51 +155,78 @@ public class CommandsTest2
       String cmdLine,
       int seqNum,
       int annNum,
-      int viewerNum,
-      String propsFile
+      int structureViewerNum,
      */
-    return new Object[][] { { "--nonews --nosplash --debug "
-            + "--open=examples/uniref50.fa " + "--colour=gecos:flower "
-            + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
-            + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
-            + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
-        15, 7, 1 },
-        { "--nonews --nosplash --debug " + "--open=examples/uniref50.fa "
-                + "--colour=gecos:flower "
+    return new Object[][] {
+        //
+        /*
+         */
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
+                + "--colour=gecos-flower "
+                + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
+                + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
+                + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
+            15, 7, 1 },
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
+                + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
                 + "--props=test/jalview/bin/commandsTest2.jvprops2 ",
             15, 4, 1 },
-        { "--nonews --nosplash --debug " + "--open=examples/uniref50.fa "
-                + "--colour=gecos:flower "
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
+                + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
-                + "--nossannotations "
+                + "--noshowssannotations "
                 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
             15, 4, 1 },
-        { "--nonews --nosplash --debug " + "--open=examples/uniref50.fa "
-                + "--colour=gecos:flower "
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
+                + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
-                + "--noannotations "
+                + "--noshowannotations "
                 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
             15, 3, 1 },
-        { "--nonews --nosplash --debug " + "--open=examples/uniref50.fa "
-                + "--colour=gecos:flower "
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
+                + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
-                + "--noannotations " + "--nossannotations "
+                + "--noshowannotations " + "--noshowssannotations "
                 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
             15, 0, 1 },
-        { "--nonews --nosplash --debug " + "--open=examples/uniref50.fa "
-                + "--colour=gecos:flower "
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
+                + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
-                + "--noannotations " + "--nossannotations "
+                + "--noshowannotations " + "--noshowssannotations "
                 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
             15, 0, 1 },
-        { "--argfile=test/jalview/bin/commandsTest2.argfile1 ", 16, 19, 3 },
-        { "--argfile=test/jalview/bin/commandsTest2.argfile2 ", 16, 0, 2 },
+        { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile1 ",
+            16, 19, 3 },
+        { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile2 ",
+            16, 0, 2 },
+        { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
+                + "--allstructures "
+                + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
+                + "--structureviewer=none "
+                + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
+                + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",
+            16, 10, 0 },
+        { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
+                + "--allstructures "
+                + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
+                + "--noallstructures " + "--structureviewer=none "
+                + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
+                + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",
+            16, 10, 2 },
+        /*
+         */
         //
     };
   }