X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Futil%2FPlatformTest.java;h=8794b12d000bd861d8bd9750694cc809c2a4ca35;hb=747167089ecf8d6afc70d417f5a20352e029bd95;hp=505289492f4c1e08c763ab790d46f44600ee95ef;hpb=1ba7e2e956b0db4ca52baca4cd2fc3a4384cc826;p=jalview.git diff --git a/test/jalview/util/PlatformTest.java b/test/jalview/util/PlatformTest.java index 5052894..8794b12 100644 --- a/test/jalview/util/PlatformTest.java +++ b/test/jalview/util/PlatformTest.java @@ -20,16 +20,19 @@ */ package jalview.util; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import jalview.gui.JvOptionPane; import java.awt.Button; -import java.awt.Event; import java.awt.Toolkit; +import java.awt.event.InputEvent; import java.awt.event.MouseEvent; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -72,11 +75,11 @@ public class PlatformTest assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, 0, 0, clickCount, isPopupTrigger, buttonNo), mac)); - mods = Event.CTRL_MASK; + mods = InputEvent.CTRL_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK; assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, 0, 0, clickCount, isPopupTrigger, buttonNo), mac)); - mods = Event.META_MASK; + mods = InputEvent.META_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK; assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, 0, 0, clickCount, isPopupTrigger, buttonNo), mac)); @@ -108,15 +111,49 @@ public class PlatformTest assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, 0, 0, clickCount, isPopupTrigger, buttonNo), mac)); - mods = Event.CTRL_MASK; + mods = InputEvent.CTRL_DOWN_MASK; assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, 0, 0, clickCount, isPopupTrigger, buttonNo), mac)); - mods = Event.CTRL_MASK | Event.SHIFT_MASK | Event.ALT_MASK; + mods = InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK + | InputEvent.ALT_DOWN_MASK; clickCount = 2; buttonNo = 2; isPopupTrigger = true; assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, 0, 0, clickCount, isPopupTrigger, buttonNo), mac)); } + + @Test(groups = "Functional") + public void testPathEquals() + { + assertTrue(Platform.pathEquals(null, null)); + assertFalse(Platform.pathEquals(null, "apath")); + assertFalse(Platform.pathEquals("apath", null)); + assertFalse(Platform.pathEquals("apath", "APATH")); + assertTrue(Platform.pathEquals("apath", "apath")); + assertTrue(Platform.pathEquals("apath/a/b", "apath\\a\\b")); + } + + @Test(groups = "Functional") + public void testEscapeBackslashes() + { + assertNull(Platform.escapeBackslashes(null)); + assertEquals(Platform.escapeBackslashes("hello world"), "hello world"); + assertEquals(Platform.escapeBackslashes("hello\\world"), + "hello\\\\world"); + } + + @Test(groups = { "Functional" }) + public void getLeadingIntegerFromString() + { + Assert.assertEquals(Platform.getLeadingIntegerValue("1234abcd", -1), + 1234); + Assert.assertEquals(Platform.getLeadingIntegerValue("1234", -1), 1234); + Assert.assertEquals(Platform.getLeadingIntegerValue("abcd", -1), -1); + Assert.assertEquals(Platform.getLeadingIntegerValue("abcd1234", -1), + -1); + Assert.assertEquals(Platform.getLeadingIntegerValue("None", -1), -1); + Assert.assertEquals(Platform.getLeadingIntegerValue("Null", -1), -1); + } }