package jalview.gui;
import static org.testng.Assert.assertEquals;
-
-import jalview.bin.Cache;
-import jalview.bin.Jalview;
-import jalview.datamodel.AlignmentI;
-import jalview.io.DataSourceType;
-import jalview.io.FileLoader;
-import jalview.util.Platform;
-import jalview.viewmodel.ViewportRanges;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
import java.awt.Font;
import java.awt.FontMetrics;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import jalview.bin.Cache;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
+import jalview.io.DataSourceType;
+import jalview.io.FileLoader;
+import jalview.util.Platform;
+import jalview.viewmodel.ViewportRanges;
import junit.extensions.PA;
public class SeqCanvasTest
@BeforeClass(alwaysRun = true)
public void setUp()
{
- Jalview.setInteractive(false);
+ Cache.loadProperties(null);
Cache.initLogger();
+ Desktop.getInstance().setVisible(false);
}
/**
* Test the method that computes wrapped width in residues, height of wrapped
* widths in pixels, and the number of widths visible
*/
- @Test(groups = "Functional", priority = 0)
+ @Test(groups = "Functional")
public void testCalculateWrappedGeometry_noAnnotations()
{
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/uniref50.fa", DataSourceType.FILE);
+
AlignViewport av = af.getViewport();
AlignmentI al = av.getAlignment();
assertEquals(al.getWidth(), 157);
* Test the method that computes wrapped width in residues, height of wrapped
* widths in pixels, and the number of widths visible
*/
- @Test(groups = "Functional", priority = 1)
+ @Test(groups = "Functional")
public void testCalculateWrappedGeometry_withAnnotations()
{
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
* endSeq should be unchanged, but the vertical repeat height should include
* all sequences.
*/
- @Test(groups = "Functional", priority = 2)
+ @Test(groups = "Functional")
public void testCalculateWrappedGeometry_fromScrolled()
{
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/uniref50.fa", DataSourceType.FILE);
+ //
+ System.out.println("ap dim = " + af.alignPanel.getSize());
+ System.out.println("seqpan dim = " + af.alignPanel.getSeqPanel().getSize());
+ System.out.println("seqcan dim = " + af.alignPanel.getSeqPanel().seqCanvas.getSize());
+
+
AlignViewport av = af.getViewport();
AlignmentI al = av.getAlignment();
assertEquals(al.getWidth(), 157);
assertEquals(al.getHeight(), 15);
ViewportRanges ranges = av.getRanges();
- System.out.println(av.getRanges() + " just before setting end to 3");
+ System.out.println(ranges + " before setting to 3");
ranges.setStartEndSeq(0, 3);
- System.out.println(av.getRanges() + " just after setting end to 3");
+ int endSeq = ranges.getEndSeq();
+ System.out.println(ranges + " after setting to 3");
av.setShowAnnotation(false);
av.setScaleAboveWrapped(true);
int canvasWidth = 400;
int canvasHeight = 300;
testee.calculateWrappedGeometry(canvasWidth, canvasHeight);
- System.out.println(ranges + " just before assert");
- assertEquals(ranges.getEndSeq(), 3); // unchanged
+ System.out.println(ranges);
+ assertEquals(ranges.getEndSeq(), endSeq); // unchanged
int repeatingHeight = (int) PA.getValue(testee,
"wrappedRepeatHeightPx");
int h = charHeight * (2 + al.getHeight());
assertEquals(repeatingHeight, h);
}
+ @Test(groups = "Functional")
+ public void testClear_HighlightAndSelection()
+ {
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/uniref50.fa", DataSourceType.FILE);
+ AlignViewport av = af.getViewport();
+ SearchResultsI highlight = new SearchResults();
+ highlight.addResult(
+ av.getAlignment().getSequenceAt(1).getDatasetSequence(), 50,
+ 80);
+ af.alignPanel.highlightSearchResults(highlight);
+ af.avc.markHighlightedColumns(false, false, false);
+ assertNotNull(av.getSearchResults(),
+ "No highlight was created on alignment");
+ assertFalse(av.getColumnSelection().isEmpty(),
+ "No selection was created from highlight");
+ af.deselectAllSequenceMenuItem_actionPerformed(null);
+ assertTrue(av.getColumnSelection().isEmpty(),
+ "No Selection should be present after deselecting all.");
+ assertNull(av.getSearchResults(),
+ "No higlighted search results should be present after deselecting all.");
+ }
}