javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/Bck2BrwsrKnockoutTest.java
2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
18 package org.apidesign.bck2brwsr.htmlpage;
21 import net.java.html.json.Context;
22 import org.apidesign.bck2brwsr.core.JavaScriptBody;
23 import org.apidesign.bck2brwsr.vmtest.VMTest;
24 import org.apidesign.html.json.tck.KnockoutTCK;
25 import org.openide.util.lookup.ServiceProvider;
26 import org.testng.annotations.Factory;
30 * @author Jaroslav Tulach <jtulach@netbeans.org>
32 @ServiceProvider(service = KnockoutTCK.class)
33 public final class Bck2BrwsrKnockoutTest extends KnockoutTCK {
34 @Factory public static Object[] create() {
35 return VMTest.newTests().
36 withClasses(testClasses()).
37 withLaunchers("bck2brwsr").
42 public Context createContext() {
43 return BrwsrCntxt.DEFAULT;
49 public Object createJSON(Map<String, Object> values) {
50 Object json = createJSON();
52 for (Map.Entry<String, Object> entry : values.entrySet()) {
53 putValue(json, entry.getKey(), entry.getValue());
58 @JavaScriptBody(args = {}, body = "return new Object();")
59 private static native Object createJSON();
61 @JavaScriptBody(args = { "json", "key", "value" }, body = "json[key] = value;")
62 private static native void putValue(Object json, String key, Object value);
65 public Object executeScript(String script, Object[] arguments) {
66 return execScript(script, arguments);
69 @JavaScriptBody(args = { "s", "args" }, body =
70 "var f = new Function(s); return f.apply(null, args);"
72 private static native Object execScript(String s, Object[] arguments);