X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=test%2Fjalview%2Fgui%2FJvSwingUtilsTest.java;h=61c5c9b9b42ff08414436a6210a688d57be7c4a5;hb=edd03d6ac338c7623d72a2f9598da73dce45cb7d;hp=1a16053fbd2ddd691f383c108901ebfac15671f6;hpb=c93b9ad2ebfab4cad4608a8890132918589576be;p=jalview.git
diff --git a/test/jalview/gui/JvSwingUtilsTest.java b/test/jalview/gui/JvSwingUtilsTest.java
index 1a16053..61c5c9b 100644
--- a/test/jalview/gui/JvSwingUtilsTest.java
+++ b/test/jalview/gui/JvSwingUtilsTest.java
@@ -1,15 +1,44 @@
+/*
+ * 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.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
{
- @Test
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
+ @Test(groups = { "Functional" })
public void testGetScrollBarProportion()
{
/*
@@ -24,7 +53,7 @@ public class JvSwingUtilsTest
assertEquals(0.25f, JvSwingUtils.getScrollBarProportion(sb), 0.001f);
}
- @Test
+ @Test(groups = { "Functional" })
public void testGetScrollValueForProportion()
{
/*
@@ -38,4 +67,56 @@ public class JvSwingUtilsTest
*/
assertEquals(125, JvSwingUtils.getScrollValueForProportion(sb, 0.25f));
}
+
+ /**
+ * Test wrap tooltip where it is less than or equal to 60 characters long - no
+ * wrap should be applied
+ */
+ @Test(groups = { "Functional" })
+ public void testWrapTooltip_shortText()
+ {
+ String tip = "hello world";
+ assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip));
+ assertEquals("" + tip + "",
+ JvSwingUtils.wrapTooltip(true, tip));
+
+ tip = "012345678901234567890123456789012345678901234567890123456789"; // 60
+ assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip));
+ assertEquals("" + tip + "",
+ JvSwingUtils.wrapTooltip(true, tip));
+
+ tip = "0123456789012345678901234567890123456789012345678901234567890"; // 61
+ assertFalse(tip.equals(JvSwingUtils.wrapTooltip(false, tip)));
+ assertFalse(("" + tip + "").equals(JvSwingUtils
+ .wrapTooltip(true, tip)));
+ }
+
+ /**
+ * Test wrap tooltip where it is more than one line (separated by <br>
+ * tags) of less than or equal to 60 characters long - no wrap should be
+ * applied
+ */
+ @Test(groups = { "Functional" })
+ 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));
+ assertEquals("" + tip + "",
+ JvSwingUtils.wrapTooltip(true, tip));
+ }
+
+ /**
+ * Test wrap tooltip where it is more than 60 characters long - word break and
+ * word wrap styling should be applied
+ */
+ @Test(groups = { "Functional" })
+ 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 + "",
+ JvSwingUtils.wrapTooltip(true, tip));
+ assertEquals(expected, JvSwingUtils.wrapTooltip(false, tip));
+ }
}