X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fgui%2FJvSwingUtilsTest.java;h=d46972ad478111f0f166c3341847060567283976;hb=89783fd8b12b50270d561017d5481de089d86d70;hp=2a7f1319756946e65106c982ab742a88805d2678;hpb=52288466dd1e71946a06fd1e6ea15fa8e652c693;p=jalview.git diff --git a/test/jalview/gui/JvSwingUtilsTest.java b/test/jalview/gui/JvSwingUtilsTest.java index 2a7f131..d46972a 100644 --- a/test/jalview/gui/JvSwingUtilsTest.java +++ b/test/jalview/gui/JvSwingUtilsTest.java @@ -1,15 +1,43 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.gui; +import static org.junit.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; import javax.swing.JScrollBar; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class JvSwingUtilsTest { + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + @Test(groups = { "Functional" }) public void testGetScrollBarProportion() { @@ -58,9 +86,17 @@ public class JvSwingUtilsTest JvSwingUtils.wrapTooltip(true, tip)); tip = "0123456789012345678901234567890123456789012345678901234567890"; // 61 - assertFalse(tip.equals(JvSwingUtils.wrapTooltip(false, tip))); - assertFalse(("" + tip + "").equals(JvSwingUtils + assertTrue(tip.equals(JvSwingUtils.wrapTooltip(false, tip))); + assertTrue((JvSwingUtils.HTML_PREFIX + tip + "") + .equals(JvSwingUtils .wrapTooltip(true, tip))); + +// was: +// +// assertFalse(tip.equals(JvSwingUtils.wrapTooltip(false, tip))); +// assertFalse(("" + tip + "").equals(JvSwingUtils +// .wrapTooltip(true, tip))); + } /** @@ -72,9 +108,23 @@ public class JvSwingUtilsTest public void testWrapTooltip_multilineShortText() { String tip = "Now is the winter of our discontent
Made glorious summer by this sun of York"; - assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip)); + + // System.out.println( + // JvSwingUtils.wrapTooltip(false, "" + tip + "")); + // System.out.println(JvSwingUtils.wrapTooltip(true, tip)); + + assertEquals("" + tip + "", + JvSwingUtils.wrapTooltip(false, "" + tip + "")); assertEquals("" + tip + "", JvSwingUtils.wrapTooltip(true, tip)); + +// was: +// +// assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip)); +// assertEquals("" + tip + "", +// JvSwingUtils.wrapTooltip(true, tip)); +// + } /** @@ -85,10 +135,9 @@ public class JvSwingUtilsTest public void testWrapTooltip_longText() { String tip = "Now is the winter of our discontent made glorious summer by this sun of York"; - String expected = "

" - + tip + "

"; - assertEquals("" + expected + "", + String expected = JvSwingUtils.HTML_PREFIX + tip + ""; + assertEquals(expected, JvSwingUtils.wrapTooltip(true, tip)); - assertEquals(expected, JvSwingUtils.wrapTooltip(false, tip)); + assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip)); } }