JAL-4290 Fix image comparison between gui and headless output. Images are now the...
[jalview.git] / test / jalview / bin / CommandsTest.java
index 80354f9..7ca4e55 100644 (file)
@@ -185,10 +185,10 @@ public class CommandsTest
           throws IOException
   {
     cleanupFiles(filenames);
-    String[] args = (cmdLine + "").split("\\s+");
+    String[] args = (cmdLine).split("\\s+");
     try
     {
-      callJalviewMain(args);
+      callJalviewMain(args, true);
       Commands cmds = Jalview.getInstance().getCommands();
       Assert.assertNotNull(cmds);
       verifyIncreasingSize(cmdLine, filenames);
@@ -198,7 +198,7 @@ public class CommandsTest
               x);
     } finally
     {
-      // cleanupFiles(filenames);
+      cleanupFiles(filenames);
       tearDown();
     }
   }
@@ -229,14 +229,12 @@ public class CommandsTest
           timeOut -= 25;
         }
       }
-      /*
-       *  larger margin between IDs and alignment/annotations when in --gui mode
-       *  
-      verifyOrderedFileSet(cmdLines[0] + " vs " + cmdLines[1], filenames, false);
-       */
+
+      verifyOrderedFileSet(cmdLines[0] + " vs " + cmdLines[1], filenames,
+              false);
 
       verifySimilarEnoughImages(cmdLines[0] + " vs " + cmdLines[1],
-              filenames, 0.6f, 0f);
+              filenames, 0f, 0f);
     } catch (Exception x)
     {
       Assert.fail("Unexpected exception during structureImageOutputTest",
@@ -361,19 +359,19 @@ public class CommandsTest
     Assert.assertTrue(max_h > 0,
             "Maximum height is not positive (" + max_h + ")");
     // tolerance
-    Assert.assertTrue(100 * (max_w - min_w) / min_w < w_tolerance_pc,
+    Assert.assertTrue(100 * (max_w - min_w) / min_w <= w_tolerance_pc,
             "Width variation (" + (max_w - min_w)
-                    + " not within tolerance of minimum width (" + min_w
-                    + ")");
+                    + " not within tolerance (" + w_tolerance_pc
+                    + "%) of minimum width (" + min_w + ")");
     if (max_w != min_w)
     {
       System.out.println("Widths within tolerance (" + w_tolerance_pc
               + "%), min_w=" + min_w + " < max_w=" + max_w);
     }
-    Assert.assertTrue(100 * (max_h - min_h) / min_h < w_tolerance_pc,
+    Assert.assertTrue(100 * (max_h - min_h) / min_h <= h_tolerance_pc,
             "Height variation (" + (max_h - min_h)
-                    + " not within tolerance of minimum height (" + min_h
-                    + ")");
+                    + " not within tolerance (" + h_tolerance_pc
+                    + "%) of minimum height (" + min_h + ")");
     if (max_h != min_h)
     {
       System.out.println("Heights within tolerance (" + h_tolerance_pc
@@ -454,56 +452,60 @@ public class CommandsTest
     return new Object[][] {
         //
         /*
+                */
         { "--gui --nonews --nosplash --open=./examples/test_fab41.result/sample.a2m "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
-                + "--structureimage=" + testfiles + "/structureimage1.png "
+                + "--structureimage=" + testfiles
+                + "/structureimage0-1.png "
                 + "--open=./examples/test_fab41.result/sample.a2m "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
                 + "--structureimage=" + testfiles
-                + "/structureimage2.png --scale=1.5 "
+                + "/structureimage0-2.png --scale=1.5 "
                 + "--open=./examples/test_fab41.result/sample.a2m "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
                 + "--structureimage=" + testfiles
-                + "/structureimage3.png --scale=2.0 ",
+                + "/structureimage0-3.png --scale=2.0 ",
             new String[]
-            { testfiles + "/structureimage1.png",
-                testfiles + "/structureimage2.png",
-                testfiles + "/structureimage3.png" } },
+            { testfiles + "/structureimage0-1.png",
+                testfiles + "/structureimage0-2.png",
+                testfiles + "/structureimage0-3.png" } },
         { "--headless --noquit --open=./examples/test_fab41.result/sample.a2m "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
-                + "--structureimage=" + testfiles + "/structureimage1.png "
+                + "--structureimage=" + testfiles
+                + "/structureimage1-1.png "
                 + "--open=./examples/test_fab41.result/sample.a2m "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
                 + "--structureimage=" + testfiles
-                + "/structureimage2.png --scale=1.5 "
+                + "/structureimage1-2.png --scale=1.5 "
                 + "--open=./examples/test_fab41.result/sample.a2m "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
                 + "--structureimage=" + testfiles
-                + "/structureimage3.png --scale=2.0 ",
+                + "/structureimage1-3.png --scale=2.0 ",
             new String[]
-            { testfiles + "/structureimage1.png",
-                testfiles + "/structureimage2.png",
-                testfiles + "/structureimage3.png" } },
-                */
+            { testfiles + "/structureimage1-1.png",
+                testfiles + "/structureimage1-2.png",
+                testfiles + "/structureimage1-3.png" } },
         { "--gui --nonews --nosplash --open examples/1gaq.txt --append ./examples/3W5V.pdb "
                 + "--structure examples/1gaq.txt --seqid \"1GAQ|A\" "
                 + "--structureimage " + testfiles
-                + "/1gaq.png --structure examples/3W5V.pdb "
+                + "/structureimage2-1gaq.png --structure examples/3W5V.pdb "
                 + "--seqid \"3W5V|A\" --structureimage " + testfiles
-                + "/3w5v.png --overwrite",
+                + "/structureimage2-3w5v.png --overwrite",
 
             new String[]
-            { testfiles + "/1gaq.png", testfiles + "/3w5v.png" } },
-        /*
+            { testfiles + "/structureimage2-3w5v.png",
+                testfiles + "/structureimage2-1gaq.png", } },
         { "--headless --noquit --open ./examples/1gaq.txt --append ./examples/3W5V.pdb "
                 + "--structure examples/1gaq.txt --seqid \"1GAQ|A\" "
                 + "--structureimage " + testfiles
-                + "/1gaq.png --structure examples/3W5V.pdb "
+                + "/structureimage3-1gaq.png --structure examples/3W5V.pdb "
                 + "--seqid \"3W5V|A\" --structureimage " + testfiles
-                + "/3w5v.png --overwrite",
-        
+                + "/structureimage3-3w5v.png --overwrite",
+
             new String[]
-            { testfiles + "/1gaq.png", testfiles + "/3w5v.png" } }
+            { testfiles + "/structureimage3-3w5v.png",
+                testfiles + "/structureimage3-1gaq.png", } }
+        /*
                 */
         //
     };