JAL-4397 Test all fixed on linux. Given leeway to some tests, platform dependent...
[jalview.git] / test / jalview / gui / AnnotationLabelsTest2.java
index e8fa9f1..54c6f34 100644 (file)
@@ -43,6 +43,8 @@ import jalview.structure.StructureImportSettings.TFType;
 
 public class AnnotationLabelsTest2
 {
+  private static double scaling;
+
   @BeforeClass(alwaysRun = true)
   public static void setUpBeforeClass() throws Exception
   {
@@ -55,6 +57,8 @@ public class AnnotationLabelsTest2
      */
     Cache.loadProperties("test/jalview/io/testProps.jvprops");
     Jalview.main(new String[] { "--nonews", "--nosplash", });
+
+    scaling = JvSwingUtilsTest.getScaling(Desktop.instance);
   }
 
   @AfterMethod(alwaysRun = true)
@@ -87,14 +91,15 @@ public class AnnotationLabelsTest2
     groups =
     { "Functional", "testTask1" },
     dataProvider = "openFilesWithIdWidthChanges")
-  public void testIdWidthChanges(String alignmentFilename, int idWidth1min,
-          int idWidth1max, int manualWidth, String structureFilename,
-          String paeFilename, boolean secondaryStructureView,
-          TFType temperatureFactorType, ViewerType viewerType,
-          int idWidth2min, int idWidth2max)
+  public void testIdWidthChanges(String alignmentFilename, boolean wrap,
+          int idWidth1min, int idWidth1max, int manualWidth,
+          String structureFilename, String paeFilename,
+          boolean secondaryStructureView, TFType temperatureFactorType,
+          ViewerType viewerType, int idWidth2min, int idWidth2max)
   {
     AlignFrame af = new FileLoader()
             .LoadFileWaitTillLoaded(alignmentFilename, DataSourceType.FILE);
+
     try
     {
       Thread.sleep(200); // to allow alignment annotations to open
@@ -110,8 +115,19 @@ public class AnnotationLabelsTest2
     idWidth = av.getIdWidth();
     assertTrue(idWidth > idWidth1min,
             "idWidth (" + idWidth + ") is not greater than " + idWidth1min);
-    assertTrue(idWidth < idWidth1max, "idWidth (" + idWidth
-            + ") is not less wide than" + idWidth1max);
+    assertTrue(idWidth < idWidth1max,
+            "idWidth (" + idWidth + ") is not narrower than" + idWidth1max);
+
+    // set wrap
+    if (wrap)
+    {
+      af.setWrapFormat(true, false);
+      idWidth = av.getIdWidth();
+      assertTrue(idWidth > idWidth1min, "After wrap idWidth (" + idWidth
+              + ") is not greater than " + idWidth1min);
+      assertTrue(idWidth < idWidth1max, "After wrap idWidth (" + idWidth
+              + ") is not narrower than" + idWidth1max);
+    }
 
     AlignmentI al = av.getAlignment();
     SequenceI s = al.getSequenceAt(0);
@@ -134,18 +150,19 @@ public class AnnotationLabelsTest2
       e.printStackTrace();
     }
 
+    // idWidth = ap.getIdPanel().getWidth();
     idWidth = av.getIdWidth();
-    assertTrue(idWidth > idWidth2min,
+    assertTrue(idWidth >= idWidth2min,
             "idWidth (" + idWidth + ") is not greater than " + idWidth2min);
-    assertTrue(idWidth < idWidth2max, "idWidth (" + idWidth
-            + ") is not less wide than" + idWidth2max);
+    assertTrue(idWidth <= idWidth2max,
+            "idWidth (" + idWidth + ") is not narrower than" + idWidth2max);
   }
 
   @Test(
     groups =
     { "Functional", "testTask1" },
     dataProvider = "openFilesWithIdWidthChanges")
-  public void testIdWidthNoChanges(String alignmentFilename,
+  public void testIdWidthNoChanges(String alignmentFilename, boolean wrap,
           int idWidth1min, int idWidth1max, int manualWidth,
           String structureFilename, String paeFilename,
           boolean secondaryStructureView, TFType temperatureFactorType,
@@ -164,12 +181,11 @@ public class AnnotationLabelsTest2
     AlignViewport av = af.getCurrentView();
 
     int idWidth = 0;
-
     idWidth = av.getIdWidth();
     assertTrue(idWidth > idWidth1min,
             "idWidth (" + idWidth + ") is not greater than " + idWidth1min);
-    assertTrue(idWidth < idWidth1max, "idWidth (" + idWidth
-            + ") is not less wide than" + idWidth1max);
+    assertTrue(idWidth < idWidth1max,
+            "idWidth (" + idWidth + ") is not narrower than" + idWidth1max);
 
     AlignmentI al = av.getAlignment();
     SequenceI s = al.getSequenceAt(0);
@@ -207,6 +223,7 @@ public class AnnotationLabelsTest2
   {
     /*
       String alignmentFilename,
+      boolean wrap,
       int idWidth1min,
       int idWidth1max,
       int manualWidth, // ignored by testIdWidthChanges()
@@ -218,18 +235,23 @@ public class AnnotationLabelsTest2
       int idWidth2min,
       int idWidth2max,
      */
+    int idWidth2min = scaling == 1.0 ? 114 : 108;
+    int idWidth2max = scaling == 1.0 ? 114 : 114; // was 130
+
     return new Object[][] {
         //
         /*
          */
-        {
-            //
-            "./test/files/annotation_label_width/sample.a2m", 50, 70, 100,
+        { "./test/files/annotation_label_width/sample.a2m", false, 50, 70,
+            100,
             "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
             "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json",
-            true, TFType.PLDDT, null, 115, 130
-        //
-        },
+            true, TFType.PLDDT, null, idWidth2min, idWidth2max },
+        { "./test/files/annotation_label_width/sample.a2m", true, 50, 70,
+            100,
+            "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
+            "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json",
+            true, TFType.PLDDT, null, idWidth2min, idWidth2max },
         /*
          */
     };