jaroslav@530: /** jaroslav@530: * Back 2 Browser Bytecode Translator jaroslav@530: * Copyright (C) 2012 Jaroslav Tulach jaroslav@530: * jaroslav@530: * This program is free software: you can redistribute it and/or modify jaroslav@530: * it under the terms of the GNU General Public License as published by jaroslav@530: * the Free Software Foundation, version 2 of the License. jaroslav@530: * jaroslav@530: * This program is distributed in the hope that it will be useful, jaroslav@530: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@530: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@530: * GNU General Public License for more details. jaroslav@530: * jaroslav@530: * You should have received a copy of the GNU General Public License jaroslav@530: * along with this program. Look for COPYING file in the top folder. jaroslav@530: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@530: */ jaroslav@530: package org.apidesign.bck2brwsr.htmlpage; jaroslav@530: jaroslav@530: import org.apidesign.bck2brwsr.htmlpage.api.ComputedProperty; jaroslav@530: import org.apidesign.bck2brwsr.htmlpage.api.OnEvent; jaroslav@530: import org.apidesign.bck2brwsr.htmlpage.api.Page; jaroslav@530: import org.apidesign.bck2brwsr.htmlpage.api.Property; jaroslav@530: import org.apidesign.bck2brwsr.vmtest.BrwsrTest; jaroslav@530: import org.apidesign.bck2brwsr.vmtest.HtmlFragment; jaroslav@530: import org.apidesign.bck2brwsr.vmtest.VMTest; jaroslav@530: import org.testng.annotations.Factory; jaroslav@530: jaroslav@530: /** jaroslav@530: * jaroslav@530: * @author Jaroslav Tulach jaroslav@530: */ jaroslav@530: @Page(xhtml="Knockout.xhtml", className="KnockoutModel", properties={ jaroslav@530: @Property(name="name", type=String.class) jaroslav@530: }) jaroslav@530: public class KnockoutTest { jaroslav@530: jaroslav@530: @HtmlFragment( jaroslav@530: "

Loading Bck2Brwsr's Hello World...

\n" + jaroslav@530: "Your name: \n" + jaroslav@530: "\n" jaroslav@530: ) jaroslav@530: @BrwsrTest public void modifyValueAssertChangeInModel() { jaroslav@530: KnockoutModel m = new KnockoutModel(); jaroslav@530: m.setName("Kukuc"); jaroslav@530: m.applyBindings(); jaroslav@530: assert "Kukuc".equals(m.INPUT.getValue()) : "Value is really kukuc: " + m.INPUT.getValue(); jaroslav@530: m.INPUT.setValue("Jardo"); jaroslav@530: m.triggerEvent(m.INPUT, OnEvent.CHANGE); jaroslav@530: assert "Jardo".equals(m.getName()) : "Name property updated: " + m.getName(); jaroslav@530: } jaroslav@530: jaroslav@530: @ComputedProperty jaroslav@530: static String helloMessage(String name) { jaroslav@530: return "Hello " + name + "!"; jaroslav@530: } jaroslav@530: jaroslav@530: @Factory jaroslav@530: public static Object[] create() { jaroslav@530: return VMTest.create(KnockoutTest.class); jaroslav@530: } jaroslav@530: }