jan@866: /** jan@866: * Back 2 Browser Bytecode Translator jan@866: * Copyright (C) 2012 Jaroslav Tulach jan@866: * jan@866: * This program is free software: you can redistribute it and/or modify jan@866: * it under the terms of the GNU General Public License as published by jan@866: * the Free Software Foundation, version 2 of the License. jan@866: * jan@866: * This program is distributed in the hope that it will be useful, jan@866: * but WITHOUT ANY WARRANTY; without even the implied warranty of jan@866: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jan@866: * GNU General Public License for more details. jan@866: * jan@866: * You should have received a copy of the GNU General Public License jan@866: * along with this program. Look for COPYING file in the top folder. jan@866: * If not, see http://opensource.org/licenses/GPL-2.0. jan@866: */ jan@866: package org.apidesign.bck2brwsr.htmlpage; jan@866: jan@866: import java.util.Map; jan@1079: import org.apidesign.bck2brwsr.core.JavaScriptBody; jan@1079: import org.apidesign.bck2brwsr.htmlpage.api.Page; jan@1079: import org.apidesign.bck2brwsr.vmtest.BrwsrTest; jan@1079: import org.apidesign.bck2brwsr.vmtest.HtmlFragment; jan@1079: import org.apidesign.bck2brwsr.vmtest.VMTest; jan@1079: import static org.testng.Assert.assertEquals; jan@1079: import org.testng.annotations.Factory; jan@866: import org.testng.annotations.Test; jan@866: jan@866: /** jan@866: * jan@866: * @author Jan Horvath jan@866: */ jan@1079: @Page(xhtml = "Elements.html") jan@866: public class ElementGeneratorTest { jan@866: jan@866: @Test public void testGetAttributes() { jan@866: ElementGenerator gen = new ElementGenerator(null); jan@866: Map attrs = gen.getAttributes("input"); jan@866: assertEquals(attrs.get("width"), "Integer", "Expected type of width attribute is Integer"); jan@866: } jan@1079: jan@1079: @HtmlFragment( jan@1079: "" jan@1079: + "\n" jan@1079: ) jan@1079: @BrwsrTest public void testInnerHTML() { jan@1079: Elements e = new Elements(); jan@1079: e.mySpan.setText("inserted text"); jan@1079: String in = getInnerHTML("inserted"); jan@1079: assert "inserted text".equals(in) : "Inserted element was not found"; jan@1079: } jan@1079: jan@1079: @JavaScriptBody(args = { "id" }, body = jan@1079: "var e = window.document.getElementById(id);\n " jan@1079: + "return e.innerHTML;" jan@1079: ) jan@1079: private static native String getInnerHTML(String id); jan@1079: jan@1079: @Factory public static Object[] create() { jan@1079: return VMTest.create(ElementGeneratorTest.class); jan@1079: } jan@866: }