JAL-1738 JAL-345 trivial tests for relocated SearchResultsI ref on AlignViewportI
authorJim Procter <jprocter@issues.jalview.org>
Tue, 1 Nov 2016 16:32:09 +0000 (16:32 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 1 Nov 2016 16:32:09 +0000 (16:32 +0000)
test/jalview/gui/AlignViewportTest.java

index 00c52ed..dfe0e68 100644 (file)
@@ -35,6 +35,8 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.PDBEntry.Type;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceI;
 import jalview.io.FileLoader;
@@ -347,4 +349,28 @@ public class AlignViewportTest
     af.getViewport().setGlobalColourScheme(cs);
     assertFalse(cs.conservationApplied());
   }
+
+  @Test(groups = { "Functional" })
+  public void testSetGetHasSearchResults()
+  {
+    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+            "examples/uniref50.fa", FormatAdapter.FILE);
+    SearchResultsI sr = new SearchResults();
+    SequenceI s1 = af.getViewport().getAlignment().getSequenceAt(0);
+
+    // create arbitrary range on first sequence
+    sr.addResult(s1, s1.getStart() + 10, s1.getStart() + 15);
+
+    // test set
+    af.getViewport().setSearchResults(sr);
+    // has -> true
+    assertTrue(af.getViewport().hasSearchResults());
+    // get == original
+    assertEquals(sr, af.getViewport().getSearchResults());
+
+    // set(null) results in has -> false
+
+    af.getViewport().setSearchResults(null);
+    assertFalse(af.getViewport().hasSearchResults());
+  }
 }