X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=utils%2Ftest%2FJalviewJSTest.java;h=3e08024f3aef6281f072dcf18b46ed6bd81a7a18;hb=eca4795050a0f7eca3d5dece68eaa54987cebd15;hp=0d4d708e06e52379de25f68163158899868ded14;hpb=64f2cead717701f2b3e9a6928775b1fb298fae56;p=jalview.git diff --git a/utils/test/JalviewJSTest.java b/utils/test/JalviewJSTest.java index 0d4d708..3e08024 100644 --- a/utils/test/JalviewJSTest.java +++ b/utils/test/JalviewJSTest.java @@ -1,4 +1,7 @@ package test; +import jalview.gui.JvOptionPane; +import jalview.util.JSONUtils; + import java.awt.BorderLayout; import java.awt.ComponentOrientation; import java.awt.Container; @@ -27,6 +30,8 @@ import javax.swing.SwingConstants; import javax.swing.WindowConstants; import javax.swing.border.TitledBorder; +import org.json.simple.parser.ParseException; + /** * A class with a main method entry point for ad hoc tests of JalviewJS * behaviour. The J2S transpiler should generate an html entry point for this @@ -36,7 +41,57 @@ public class JalviewJSTest extends JPanel { public static void main(String[] args) { - new JalviewJSTest().doTest4(); + new JalviewJSTest().doTest6(); + } + + void doTest6() + { + /* + * check for transpiler fix associated with JSONParser yylex.java use of charAt() + * instead of codePointAt(); moved here from PDBFTSRestClient + */ + + String s = "e"; + char c = 'c'; + char f = 'f'; + s += c | f; + int x = c & f; + int y = 2 & c; + int z = c ^ 5; + String result = s + x + y + z; + System.out.println("Expected " + "e103982102, found " + result); + try + { + Map jsonObj = (Map) JSONUtils + .parse("{\"a\":3}"); + System.out.println(jsonObj); + } catch (ParseException e) + { + e.printStackTrace(); + } + } + + /** + * Dialog message truncation + */ + void doTest5() + { + JFrame main = new JFrame(); + main.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + main.setContentPane(new JPanel()); + main.setMinimumSize(new Dimension(100, 100)); + main.pack(); + main.setVisible(true); + + /* + * like AlignFrame.delete_actionPerformed() + * except here it works fine, also in JS + */ + JvOptionPane dialog = JvOptionPane.newOptionDialog(null); + Object[] options = new Object[] { "OK", "Cancel" }; + String msg = "Deleting all sequences will close the alignment window.
Confirm deletion or Cancel."; + dialog.showDialog(msg, "", JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null, options, options[0]); + } void doTest4() @@ -67,10 +122,11 @@ public class JalviewJSTest extends JPanel System.out.println("f2 hashCode = " + f2.hashCode()); System.out.println(map.get(f2)); } + /** * Put some content in a JFrame and show it */ - void doTest() + void doTest1() { System.out.println("ab;c;".split(";")); new DecimalFormat("###,###").format((Integer) 1); @@ -231,10 +287,12 @@ private ImageIcon getImage(String name) { ImageIcon icon = new ImageIcon(getClass().getResource(name)); while(icon.getImageLoadStatus() == MediaTracker.LOADING) - try { - Thread.sleep(10); - } catch (InterruptedException e) { - } + { + try { + Thread.sleep(10); + } catch (InterruptedException e) { + } + } return icon; } }