1.1 --- a/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/ElementGeneratorTest.java Thu May 02 14:56:25 2013 +0200
1.2 +++ b/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/ElementGeneratorTest.java Mon May 06 18:21:02 2013 +0200
1.3 @@ -18,13 +18,20 @@
1.4 package org.apidesign.bck2brwsr.htmlpage;
1.5
1.6 import java.util.Map;
1.7 -import static org.testng.Assert.*;
1.8 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
1.9 +import org.apidesign.bck2brwsr.htmlpage.api.Page;
1.10 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
1.11 +import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
1.12 +import org.apidesign.bck2brwsr.vmtest.VMTest;
1.13 +import static org.testng.Assert.assertEquals;
1.14 +import org.testng.annotations.Factory;
1.15 import org.testng.annotations.Test;
1.16
1.17 /**
1.18 *
1.19 * @author Jan Horvath <jhorvath@netbeans.org>
1.20 */
1.21 +@Page(xhtml = "Elements.html")
1.22 public class ElementGeneratorTest {
1.23
1.24 @Test public void testGetAttributes() {
1.25 @@ -32,4 +39,25 @@
1.26 Map<String, String> attrs = gen.getAttributes("input");
1.27 assertEquals(attrs.get("width"), "Integer", "Expected type of width attribute is Integer");
1.28 }
1.29 +
1.30 + @HtmlFragment(
1.31 + "<span id='mySpan'>"
1.32 + + "</span>\n"
1.33 + )
1.34 + @BrwsrTest public void testInnerHTML() {
1.35 + Elements e = new Elements();
1.36 + e.mySpan.setText("<span id='inserted'>inserted text</span>");
1.37 + String in = getInnerHTML("inserted");
1.38 + assert "inserted text".equals(in) : "Inserted element was not found";
1.39 + }
1.40 +
1.41 + @JavaScriptBody(args = { "id" }, body =
1.42 + "var e = window.document.getElementById(id);\n "
1.43 + + "return e.innerHTML;"
1.44 + )
1.45 + private static native String getInnerHTML(String id);
1.46 +
1.47 + @Factory public static Object[] create() {
1.48 + return VMTest.create(ElementGeneratorTest.class);
1.49 + }
1.50 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/javaquery/api/src/test/resources/org/apidesign/bck2brwsr/htmlpage/Elements.html Mon May 06 18:21:02 2013 +0200
2.3 @@ -0,0 +1,31 @@
2.4 +<?xml version="1.0" encoding="UTF-8"?>
2.5 +<!--
2.6 +
2.7 + Back 2 Browser Bytecode Translator
2.8 + Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
2.9 +
2.10 + This program is free software: you can redistribute it and/or modify
2.11 + it under the terms of the GNU General Public License as published by
2.12 + the Free Software Foundation, version 2 of the License.
2.13 +
2.14 + This program is distributed in the hope that it will be useful,
2.15 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2.16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.17 + GNU General Public License for more details.
2.18 +
2.19 + You should have received a copy of the GNU General Public License
2.20 + along with this program. Look for COPYING file in the top folder.
2.21 + If not, see http://opensource.org/licenses/GPL-2.0.
2.22 +
2.23 +-->
2.24 +<!DOCTYPE html>
2.25 +<html xmlns="http://www.w3.org/1999/xhtml">
2.26 + <head>
2.27 + <title>Elements</title>
2.28 + </head>
2.29 + <body>
2.30 + <span id="mySpan">
2.31 + empty
2.32 + </span>
2.33 + </body>
2.34 +</html>