X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fgui%2FAlignmentPanelTest.java;h=2d7e3dc38aee2ef00869dae3f6b90140a4b9759e;hb=32a2c42a535d809dfcb48db1e8cc91bb03193f8e;hp=3ec8b4d74f54cbca9062f50591142808dedceeb4;hpb=006890b02106eb31841e6e84d75f1027434823e0;p=jalview.git diff --git a/test/jalview/gui/AlignmentPanelTest.java b/test/jalview/gui/AlignmentPanelTest.java index 3ec8b4d..2d7e3dc 100644 --- a/test/jalview/gui/AlignmentPanelTest.java +++ b/test/jalview/gui/AlignmentPanelTest.java @@ -22,6 +22,7 @@ package jalview.gui; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotEquals; +import static org.testng.Assert.assertNotNull; import java.awt.Dimension; import java.awt.Font; @@ -49,38 +50,39 @@ public class AlignmentPanelTest @BeforeMethod(alwaysRun = true) public void setUp() throws InvocationTargetException, InterruptedException { - Jalview.main(new String[] { "-nonews", "-props", - "test/jalview/testProps.jvprops" }); + Jalview.main( + new String[] + { "-nonews", "-props", "test/jalview/testProps.jvprops" }); Cache.applicationProperties.setProperty("SHOW_IDENTITY", Boolean.TRUE.toString()); af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa", DataSourceType.FILE); - + /* * ensure the panel has been repainted and so ViewportRanges set */ - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - af.repaint(); - }}); + SwingUtilities.invokeAndWait(new Runnable() + { + @Override + public void run() + { + af.repaint(); + } + }); /* * wait for Consensus thread to complete */ - synchronized (this) + do { - while (af.getViewport().getConsensusSeq() == null) + try + { + Thread.sleep(50); + } catch (InterruptedException x) { - try - { - wait(50); - } catch (InterruptedException e) - { - } } - } + } while (af.getViewport().getCalcManager().isWorking()); } /** @@ -130,8 +132,8 @@ public class AlignmentPanelTest scrollpos = 130; af.getViewport().showAllHiddenColumns(); af.alignPanel.setScrollValues(scrollpos, 5); - assertEquals(ranges.getEndRes(), af.getViewport() - .getAlignment().getWidth() - 1); + assertEquals(ranges.getEndRes(), + af.getViewport().getAlignment().getWidth() - 1); // now hide some columns, and scroll to position within // distance of the end of the alignment @@ -139,9 +141,11 @@ public class AlignmentPanelTest // columns af.getViewport().hideColumns(30, 50); af.alignPanel.setScrollValues(scrollpos, 5); - assertEquals(ranges.getEndRes(), af.getViewport() - .getAlignment().getWidth() - 1 - 21); // 21 is the number of hidden - // columns + assertEquals(ranges.getEndRes(), + af.getViewport().getAlignment().getWidth() - 1 - 21); // 21 is the + // number of + // hidden + // columns } /** @@ -171,8 +175,8 @@ public class AlignmentPanelTest } /** - * Test the variant of calculateIdWidth that only recomputes the width if it is - * not already saved in the viewport (initial value is -1) + * Test the variant of calculateIdWidth that only recomputes the width if it + * is not already saved in the viewport (initial value is -1) */ @Test(groups = "Functional") public void testCalculateIdWidth_noArgs() @@ -244,7 +248,8 @@ public class AlignmentPanelTest // Assumption ID_WIDTH_PADDING == 4 int expwidth = 4 + fmfor.stringWidth(aa.label); d = af.alignPanel.calculateIdWidth(2000); - assertEquals(d.width, expwidth); // 228 == ID_WIDTH_PADDING + pixel width of "THIS IS A VERY LONG LABEL INDEED" + assertEquals(d.width, expwidth); // 228 == ID_WIDTH_PADDING + pixel width of + // "THIS IS A VERY LONG LABEL INDEED" assertEquals(d.height, 12); /* @@ -286,4 +291,43 @@ public class AlignmentPanelTest Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.TRUE.toString()); assertEquals(115, af.alignPanel.getVisibleIdWidth(false)); } -} + + @Test(groups = "Functional") + public void testSetOverviewTitle() + { + OverviewPanel ov1 = this.af.openOverviewPanel(true); + String alignFrameTitle = af.getTitle(); + assertEquals(ov1.getTitle(), "Overview " + alignFrameTitle); + + /* + * on New View, existing overview should get " Original" added to title + * and new view's overview should get " View 1" added + */ + af.newView_actionPerformed(null); + assertEquals(ov1.getTitle(), "Overview " + alignFrameTitle + " Original"); + OverviewPanel ov2 = this.af.openOverviewPanel(true); + assertEquals(ov2.getTitle(), "Overview " + alignFrameTitle + " View 1"); + } + + @Test(groups = "Functional") + public void testSetOverviewTitle_automaticOverview() + { + Cache.setProperty("SHOW_OVERVIEW", "true"); + AlignFrame alignFrame = new FileLoader().LoadFileWaitTillLoaded( + "examples/uniref50.fa", DataSourceType.FILE); + OverviewPanel ov1 = alignFrame.alignPanel.getOverviewPanel(); + assertNotNull(ov1); + String alignFrameTitle = alignFrame.getTitle(); + assertEquals(ov1.getTitle(), "Overview " + alignFrameTitle); + + /* + * on New View, existing overview should get " Original" added to title + * and new view's automatic overview should have " View 1" added + */ + alignFrame.newView_actionPerformed(null); + assertEquals(ov1.getTitle(), "Overview " + alignFrameTitle + " Original"); + OverviewPanel ov2 = alignFrame.alignPanel.getOverviewPanel(); + assertNotNull(ov2); + assertEquals(ov2.getTitle(), "Overview " + alignFrameTitle + " View 1"); + } +} \ No newline at end of file