# HG changeset patch # User Jan Horvath # Date 1363877142 -3600 # Node ID 9b4751828cebd034e7033d25fdfb96fcb5205e74 # Parent 0e49455409619019428781f7d12886af78719810 Dynamically generate classes representing elements on the HTML @Page diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/pom.xml --- a/javaquery/api/pom.xml Sat Mar 09 16:09:35 2013 +0100 +++ b/javaquery/api/pom.xml Thu Mar 21 15:45:42 2013 +0100 @@ -73,5 +73,10 @@ ${project.version} test + + org.netbeans.modules + org-netbeans-modules-html-parser + RELEASE73 + diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/Attributes.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/Attributes.java Thu Mar 21 15:45:42 2013 +0100 @@ -0,0 +1,57 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program 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, version 2 of the License. + * + * This program 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 this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.bck2brwsr.htmlpage; + +import java.util.HashMap; +import java.util.Map; + +/** + * Temporary storing the type of attributes here. This should be implemented in HTML 5 model + * + * @author Jan Horvath + */ +public class Attributes { + + static final Map TYPES = new HashMap() { + { + // HTML Global Attributes + // id attribute is already defined in Element, don't add it again + put("accesskey", "String"); + put("class", "String"); + put("contenteditable", "Boolean"); + put("contextmenu", "String"); + put("dir", "String"); + put("draggable", "Boolean"); + put("dropzone", "String"); + put("hidden", "Boolean"); + put("lang", "String"); + put("spellcheck", "Boolean"); + put("style", "String"); + put("tabindex", "String"); + put("title", "String"); + put("translate", "Boolean"); + put("width", "Integer"); + put("height", "Integer"); + + put("value", "String"); + put("disabled", "Boolean"); + +// put("text", "String"); 'text' field is used to set innerHTML of element + } + }; +} diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/ElementGenerator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/ElementGenerator.java Thu Mar 21 15:45:42 2013 +0100 @@ -0,0 +1,175 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program 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, version 2 of the License. + * + * This program 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 this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.bck2brwsr.htmlpage; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ServiceLoader; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.Element; +import javax.tools.Diagnostic; +import javax.tools.FileObject; +import org.netbeans.modules.html.editor.lib.api.HtmlVersion; +import org.netbeans.modules.html.editor.lib.api.model.HtmlModel; +import org.netbeans.modules.html.editor.lib.api.model.HtmlModelProvider; +import org.netbeans.modules.html.editor.lib.api.model.HtmlTag; +import org.netbeans.modules.html.editor.lib.api.model.HtmlTagAttribute; + +/** + * + * @author Jan Horvath + */ +public class ElementGenerator { + + static final Map NAMING_EXCEPTIONS = new HashMap() { + { + put("img", "Image"); + put("class", "Clazz"); + } + }; + + static final String javaKeywords[] = { + "abstract", "assert", "boolean", "break", "byte", "case", + "catch", "char", "class", "const", "continue", "default", + "do", "double", "else", "extends", "false", "final", "finally", + "float", "for", "goto", "if", "implements", "import", + "instanceof", "int", "interface", "long", "native", "new", + "null", "package", "private", "protected", "public", + "return", "short", "static", "strictfp", "super", + "switch", "synchronized", "this", "throw", "throws", + "transient", "true", "try", "void", "volatile", "while" + }; + + private static Map elements = new HashMap(); + private final ProcessingEnvironment processingEnv; + private HtmlModel model = null; + + ElementGenerator(ProcessingEnvironment processingEnv) { + this.processingEnv = processingEnv; + } + + String getType(String pkg, String tag, Element e) { + String className = elements.get(tag); + if (className == null) { + className = createClass(pkg, tag, e); + elements.put(tag, className); + } + return className; + } + + private String createClass(String pkg, String tag, Element e) { + String className = className(tag); + Writer w; + try { + FileObject java = processingEnv.getFiler().createSourceFile(pkg + '.' + className, e); + w = new OutputStreamWriter(java.openOutputStream()); + try { + w.append("package " + pkg + ";\n\n"); + w.append("import org.apidesign.bck2brwsr.htmlpage.api.*;\n"); + PredefinedFields.appendImports(w, tag); + w.append("\n"); + + w.append("class ").append(className).append(" extends Element {\n\n"); + w.append(" public ").append(className).append("(String id) {\n"); + w.append(" super(id);\n"); + w.append(" }\n\n"); + for (Entry entry : getAttributes(tag).entrySet()) { + String attrName = entry.getKey(); + String attrType = entry.getValue(); + // getter + w.append(" public ").append(attrType).append(" ") + .append("get").append(className(attrName)).append("() {\n"); + w.append(" return (").append(attrType).append(")getAttribute(\"") + .append(attrName).append("\");\n"); + w.append(" }\n\n"); + // setter + w.append(" public void ") + .append("set").append(className(attrName)).append("(") + .append(attrType).append(" ").append(attributeName(attrName)).append(") {\n"); + w.append(" setAttribute(\"").append(attrName).append("\", ").append(attributeName(attrName)).append(");\n"); + w.append(" }\n\n"); + } + PredefinedFields.appendFields(w, tag); + w.append("}\n"); + } finally { + w.close(); + } + } catch (IOException ex) { + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Can't create " + className + ".java", e); + return null; + } + return className; + } + + Map getAttributes(String tagName) { + Map result = new HashMap(); + + if (model == null) { + // HtmlModelProvider modelProvider = Lookup.getDefault().lookup(HtmlModelProvider.class); + ServiceLoader hmpLoader = + ServiceLoader.load(HtmlModelProvider.class, this.getClass().getClassLoader()); + for (HtmlModelProvider htmlModelProvider : hmpLoader) { + model = htmlModelProvider.getModel(HtmlVersion.HTML5); + if (model != null) { + break; + } + } + } + + if (model == null) { + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, + "HTML 5 model provider was not found on classpath"); + return Collections.emptyMap(); + } + HtmlTag tag = model.getTag(tagName); + for (HtmlTagAttribute attr : tag.getAttributes()) { + String name = attr.getName(); + String type = Attributes.TYPES.get(name); + if (type != null) { + result.put(name, type); + } + } + + return result; + } + + private String className(String s) { + if (s.length() == 0) { + return s; + } + String name = NAMING_EXCEPTIONS.get(s.toLowerCase()); + if (name == null) { + name = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); + } + return name; + } + + private String attributeName(String s) { + if (Arrays.binarySearch(javaKeywords, s) >= 0) { + return String.format("%sAttr", s); + } + return s; + } + +} diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Sat Mar 09 16:09:35 2013 +0100 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Thu Mar 21 15:45:42 2013 +0100 @@ -78,6 +78,7 @@ String pkg = pe.getQualifiedName().toString(); ProcessPage pp; + ElementGenerator eGen = new ElementGenerator(processingEnv); try { InputStream is = openStream(pkg, p.xhtml()); pp = ProcessPage.readPage(is); @@ -105,7 +106,7 @@ } for (String id : pp.ids()) { String tag = pp.tagNameForId(id); - String type = type(tag); + String type = eGen.getType(pkg, tag, e); w.append(" ").append("public final "). append(type).append(' ').append(cnstnt(id)).append(" = new "). append(type).append("(\"").append(id).append("\");\n"); @@ -158,25 +159,6 @@ } } - private static String type(String tag) { - if (tag.equals("title")) { - return "Title"; - } - if (tag.equals("button")) { - return "Button"; - } - if (tag.equals("input")) { - return "Input"; - } - if (tag.equals("canvas")) { - return "Canvas"; - } - if (tag.equals("img")) { - return "Image"; - } - return "Element"; - } - private static String cnstnt(String id) { return id.toUpperCase(Locale.ENGLISH).replace('.', '_').replace('-', '_'); } diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PredefinedFields.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PredefinedFields.java Thu Mar 21 15:45:42 2013 +0100 @@ -0,0 +1,65 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program 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, version 2 of the License. + * + * This program 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 this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.bck2brwsr.htmlpage; + +import java.io.IOException; +import java.io.Writer; +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author Jan Horvath + */ +public class PredefinedFields { + + private static final Map IMPORTS = new HashMap() { + { + put("canvas", "import org.apidesign.bck2brwsr.core.JavaScriptBody;"); + } + }; + + private static final Map FIELDS = new HashMap() { + { + put("canvas", + " @JavaScriptBody(\n" + + " args = {\"el\"},\n" + + " body = \"var e = window.document.getElementById(el._id());\\n\"\n" + + " + \"return e.getContext('2d');\\n\")\n" + + " private native static Object getContextImpl(Canvas el);\n" + + " \n" + + " public GraphicsContext getContext() {\n" + + " return new GraphicsContext(getContextImpl(this));\n" + + " }"); + } + }; + + static void appendImports(Writer w, String tag) throws IOException { + String text = IMPORTS.get(tag.toLowerCase()); + if (text != null) { + w.append(text).append("\n"); + } + } + + static void appendFields(Writer w, String tag) throws IOException { + String text = FIELDS.get(tag.toLowerCase()); + if (text != null) { + w.append(text).append("\n"); + } + } +} diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Button.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Button.java Sat Mar 09 16:09:35 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach - * - * This program 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, version 2 of the License. - * - * This program 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 this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -/** - * - * @author Jaroslav Tulach - */ -public final class Button extends Element { - public Button(String id) { - super(id); - } - - @Override - void dontSubclass() { - } - - public void setDisabled(boolean state) { - setAttribute(this, "disabled", state); - } -} diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Canvas.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Canvas.java Sat Mar 09 16:09:35 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach - * - * This program 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, version 2 of the License. - * - * This program 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 this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -import org.apidesign.bck2brwsr.core.JavaScriptBody; -import static org.apidesign.bck2brwsr.htmlpage.api.Element.getAttribute; - -/** - * - * @author Anton Epple - */ -public class Canvas extends Element { - - public Canvas(String id) { - super(id); - } - - public void setHeight(int height) { - setAttribute(this, "height", height); - } - - public int getHeight() { - Object ret = getAttribute(this, "height"); - return (ret instanceof Number) ? ((Number)ret).intValue(): Integer.MIN_VALUE; - } - - public void setWidth(int width) { - setAttribute(this, "width", width); - } - - public int getWidth() { - Object ret = getAttribute(this, "width"); - return (ret instanceof Number) ? ((Number)ret).intValue(): Integer.MIN_VALUE; - } - - @JavaScriptBody( - args = {"el"}, - body = "var e = window.document.getElementById(el._id());\n" - + "return e.getContext('2d');\n") - private native static Object getContextImpl(Canvas el); - - public GraphicsContext getContext() { - return new GraphicsContext(getContextImpl(this)); - } - - @Override - void dontSubclass() { - } -} diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java Sat Mar 09 16:09:35 2013 +0100 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java Thu Mar 21 15:45:42 2013 +0100 @@ -37,7 +37,13 @@ return id; } - abstract void dontSubclass(); + public String getText() { + return (String)getAttribute("innerHTML"); + } + + public void setText(String text) { + setAttribute("innerHTML", text); + } @JavaScriptBody( args={"el", "property", "value"}, diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/GraphicsContext.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/GraphicsContext.java Sat Mar 09 16:09:35 2013 +0100 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/GraphicsContext.java Thu Mar 21 15:45:42 2013 +0100 @@ -27,7 +27,7 @@ Object context; - GraphicsContext(Object contextImpl) { + public GraphicsContext(Object contextImpl) { this.context = contextImpl; } @@ -113,15 +113,15 @@ @JavaScriptBody(args = {"x", "y"}, body = "this._context().scale(x,y);") public native void scale(double x, double y); - public void drawImage(Image image, double x, double y) { + public void drawImage(Element image, double x, double y) { drawImageImpl(context, Element.getElementById(image), x, y); } - public void drawImage(Image image, double x, double y, double width, double height) { + public void drawImage(Element image, double x, double y, double width, double height) { drawImageImpl(context, Element.getElementById(image), x, y, width, height); } - public void drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height) { + public void drawImage(Element image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height) { drawImageImpl(context, Element.getElementById(image), sx, sy, sWidth, sHeight, x, y, width, height); } @@ -319,12 +319,12 @@ @JavaScriptBody(args = {"context", "x0", "y0", "x1", "y1"}, body = "return context.createLinearGradient(x0,y0,x1,y1);") private native Object createLinearGradientImpl(Object context, double x0, double y0, double x1, double y1); - public Pattern createPattern(Image image, String repeat) { + public Pattern createPattern(Element image, String repeat) { return new Pattern(createPatternImpl(context, image, repeat)); } @JavaScriptBody(args = {"context", "image", "repeat"}, body = "return context.createPattern(image, repeat);") - private static native Object createPatternImpl(Object context, Image image, String repeat); + private static native Object createPatternImpl(Object context, Element image, String repeat); public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1) { return new RadialGradient(createRadialGradientImpl(context, x0, y0, r0, x1, y1, r1)); diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Image.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Image.java Sat Mar 09 16:09:35 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach - * - * This program 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, version 2 of the License. - * - * This program 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 this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -/** - * - * @author Anton Epple - */ -public class Image extends Element{ - - public Image(String id) { - super(id); - } - - - - @Override - void dontSubclass() { - } - -} diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Input.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Input.java Sat Mar 09 16:09:35 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach - * - * This program 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, version 2 of the License. - * - * This program 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 this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -/** - * - * @author Jaroslav Tulach - */ -public final class Input extends Element { - public Input(String id) { - super(id); - } - - @Override - void dontSubclass() { - } - - public void setAutocomplete(boolean state) { - setAttribute(this, "autocomplete", state); - } - - public final String getValue() { - return (String)getAttribute(this, "value"); - } - - public final void setValue(String txt) { - setAttribute(this, "value", txt); - } -} diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Title.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Title.java Sat Mar 09 16:09:35 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach - * - * This program 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, version 2 of the License. - * - * This program 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 this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -/** - * - * @author Jaroslav Tulach - */ -public class Title extends Element { - public Title(String id) { - super(id); - } - - @Override - void dontSubclass() { - } - - public final void setText(String text) { - setAttribute(this, "innerHTML", text); - } -} diff -r 0e4945540961 -r 9b4751828ceb javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/ElementGeneratorTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/ElementGeneratorTest.java Thu Mar 21 15:45:42 2013 +0100 @@ -0,0 +1,35 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program 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, version 2 of the License. + * + * This program 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 this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.bck2brwsr.htmlpage; + +import java.util.Map; +import static org.testng.Assert.*; +import org.testng.annotations.Test; + +/** + * + * @author Jan Horvath + */ +public class ElementGeneratorTest { + + @Test public void testGetAttributes() { + ElementGenerator gen = new ElementGenerator(null); + Map attrs = gen.getAttributes("input"); + assertEquals(attrs.get("width"), "Integer", "Expected type of width attribute is Integer"); + } +}