X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fgui%2FJvSwingUtilsTest.java;h=8a8cba21609f6e8c9a5e457ea0fce17e8ec8a6ed;hb=c19d2a91ca05e052e3408bf5852d88eb5d0608f1;hp=1a16053fbd2ddd691f383c108901ebfac15671f6;hpb=c93b9ad2ebfab4cad4608a8890132918589576be;p=jalview.git diff --git a/test/jalview/gui/JvSwingUtilsTest.java b/test/jalview/gui/JvSwingUtilsTest.java index 1a16053..8a8cba2 100644 --- a/test/jalview/gui/JvSwingUtilsTest.java +++ b/test/jalview/gui/JvSwingUtilsTest.java @@ -1,6 +1,27 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2) + * Copyright (C) 2015 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; @@ -9,7 +30,7 @@ import org.testng.annotations.Test; public class JvSwingUtilsTest { - @Test + @Test(groups = { "Functional" }) public void testGetScrollBarProportion() { /* @@ -24,7 +45,7 @@ public class JvSwingUtilsTest assertEquals(0.25f, JvSwingUtils.getScrollBarProportion(sb), 0.001f); } - @Test + @Test(groups = { "Functional" }) public void testGetScrollValueForProportion() { /* @@ -38,4 +59,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)); + } }