javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/Bck2BrwsrKnockoutTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 24 Apr 2013 20:22:19 +0200
branchmodel
changeset 1018 49eb825c87b7
child 1019 814e4be6a104
permissions -rw-r--r--
javaquery.api is now implementation of net.java.html.json API
jaroslav@1018
     1
/**
jaroslav@1018
     2
 * Back 2 Browser Bytecode Translator
jaroslav@1018
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@1018
     4
 *
jaroslav@1018
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@1018
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@1018
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@1018
     8
 *
jaroslav@1018
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@1018
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@1018
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@1018
    12
 * GNU General Public License for more details.
jaroslav@1018
    13
 *
jaroslav@1018
    14
 * You should have received a copy of the GNU General Public License
jaroslav@1018
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@1018
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@1018
    17
 */
jaroslav@1018
    18
package org.apidesign.bck2brwsr.htmlpage;
jaroslav@1018
    19
jaroslav@1018
    20
import java.util.Map;
jaroslav@1018
    21
import net.java.html.json.Context;
jaroslav@1018
    22
import org.apidesign.bck2brwsr.core.JavaScriptBody;
jaroslav@1018
    23
import org.apidesign.bck2brwsr.vmtest.VMTest;
jaroslav@1018
    24
import org.apidesign.html.json.tck.KnockoutTCK;
jaroslav@1018
    25
import org.openide.util.lookup.ServiceProvider;
jaroslav@1018
    26
import org.testng.annotations.Factory;
jaroslav@1018
    27
jaroslav@1018
    28
/**
jaroslav@1018
    29
 *
jaroslav@1018
    30
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@1018
    31
 */
jaroslav@1018
    32
@ServiceProvider(service = KnockoutTCK.class)
jaroslav@1018
    33
public final class Bck2BrwsrKnockoutTest extends KnockoutTCK {
jaroslav@1018
    34
    @Factory public static Object[] create() {
jaroslav@1018
    35
        return VMTest.create(testClasses());
jaroslav@1018
    36
    }
jaroslav@1018
    37
    
jaroslav@1018
    38
    @Override
jaroslav@1018
    39
    public Context createContext() {
jaroslav@1018
    40
        return BrwsrCntxt.DEFAULT;
jaroslav@1018
    41
    }
jaroslav@1018
    42
jaroslav@1018
    43
jaroslav@1018
    44
    
jaroslav@1018
    45
    @Override
jaroslav@1018
    46
    public Object createJSON(Map<String, Object> values) {
jaroslav@1018
    47
        Object json = createJSON();
jaroslav@1018
    48
        
jaroslav@1018
    49
        for (Map.Entry<String, Object> entry : values.entrySet()) {
jaroslav@1018
    50
            putValue(json, entry.getKey(), entry.getValue());
jaroslav@1018
    51
        }
jaroslav@1018
    52
        return json;
jaroslav@1018
    53
    }
jaroslav@1018
    54
jaroslav@1018
    55
    @JavaScriptBody(args = {}, body = "return new Object();")
jaroslav@1018
    56
    private static native Object createJSON();
jaroslav@1018
    57
jaroslav@1018
    58
    @JavaScriptBody(args = { "json", "key", "value" }, body = "json[key] = value;")
jaroslav@1018
    59
    private static native void putValue(Object json, String key, Object value);
jaroslav@1018
    60
}