author | Jan Horvath <jan.horvath@oracle.com> |
Mon, 06 May 2013 16:41:31 +0200 | |
branch | elements |
changeset 1079 | 24b95d90955a |
parent 866 | 9b4751828ceb |
permissions | -rw-r--r-- |
jan@866 | 1 |
/** |
jan@866 | 2 |
* Back 2 Browser Bytecode Translator |
jan@866 | 3 |
* Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jan@866 | 4 |
* |
jan@866 | 5 |
* This program is free software: you can redistribute it and/or modify |
jan@866 | 6 |
* it under the terms of the GNU General Public License as published by |
jan@866 | 7 |
* the Free Software Foundation, version 2 of the License. |
jan@866 | 8 |
* |
jan@866 | 9 |
* This program is distributed in the hope that it will be useful, |
jan@866 | 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
jan@866 | 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
jan@866 | 12 |
* GNU General Public License for more details. |
jan@866 | 13 |
* |
jan@866 | 14 |
* You should have received a copy of the GNU General Public License |
jan@866 | 15 |
* along with this program. Look for COPYING file in the top folder. |
jan@866 | 16 |
* If not, see http://opensource.org/licenses/GPL-2.0. |
jan@866 | 17 |
*/ |
jan@866 | 18 |
package org.apidesign.bck2brwsr.htmlpage; |
jan@866 | 19 |
|
jan@866 | 20 |
import java.util.Map; |
jan@1079 | 21 |
import org.apidesign.bck2brwsr.core.JavaScriptBody; |
jan@1079 | 22 |
import org.apidesign.bck2brwsr.htmlpage.api.Page; |
jan@1079 | 23 |
import org.apidesign.bck2brwsr.vmtest.BrwsrTest; |
jan@1079 | 24 |
import org.apidesign.bck2brwsr.vmtest.HtmlFragment; |
jan@1079 | 25 |
import org.apidesign.bck2brwsr.vmtest.VMTest; |
jan@1079 | 26 |
import static org.testng.Assert.assertEquals; |
jan@1079 | 27 |
import org.testng.annotations.Factory; |
jan@866 | 28 |
import org.testng.annotations.Test; |
jan@866 | 29 |
|
jan@866 | 30 |
/** |
jan@866 | 31 |
* |
jan@866 | 32 |
* @author Jan Horvath <jhorvath@netbeans.org> |
jan@866 | 33 |
*/ |
jan@1079 | 34 |
@Page(xhtml = "Elements.html") |
jan@866 | 35 |
public class ElementGeneratorTest { |
jan@866 | 36 |
|
jan@866 | 37 |
@Test public void testGetAttributes() { |
jan@866 | 38 |
ElementGenerator gen = new ElementGenerator(null); |
jan@866 | 39 |
Map<String, String> attrs = gen.getAttributes("input"); |
jan@866 | 40 |
assertEquals(attrs.get("width"), "Integer", "Expected type of width attribute is Integer"); |
jan@866 | 41 |
} |
jan@1079 | 42 |
|
jan@1079 | 43 |
@HtmlFragment( |
jan@1079 | 44 |
"<span id='mySpan'>" |
jan@1079 | 45 |
+ "</span>\n" |
jan@1079 | 46 |
) |
jan@1079 | 47 |
@BrwsrTest public void testInnerHTML() { |
jan@1079 | 48 |
Elements e = new Elements(); |
jan@1079 | 49 |
e.mySpan.setText("<span id='inserted'>inserted text</span>"); |
jan@1079 | 50 |
String in = getInnerHTML("inserted"); |
jan@1079 | 51 |
assert "inserted text".equals(in) : "Inserted element was not found"; |
jan@1079 | 52 |
} |
jan@1079 | 53 |
|
jan@1079 | 54 |
@JavaScriptBody(args = { "id" }, body = |
jan@1079 | 55 |
"var e = window.document.getElementById(id);\n " |
jan@1079 | 56 |
+ "return e.innerHTML;" |
jan@1079 | 57 |
) |
jan@1079 | 58 |
private static native String getInnerHTML(String id); |
jan@1079 | 59 |
|
jan@1079 | 60 |
@Factory public static Object[] create() { |
jan@1079 | 61 |
return VMTest.create(ElementGeneratorTest.class); |
jan@1079 | 62 |
} |
jan@866 | 63 |
} |