rt/mojo/src/main/resources/archetype-resources/src/test/java/IntegrationTest.java
changeset 772 d382dacfd73f
parent 534 3cefccd50bd5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rt/mojo/src/main/resources/archetype-resources/src/test/java/IntegrationTest.java	Tue Feb 26 16:54:16 2013 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +package ${package};
     1.5 +
     1.6 +import org.apidesign.bck2brwsr.htmlpage.api.OnEvent;
     1.7 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
     1.8 +import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
     1.9 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    1.10 +import org.testng.annotations.Factory;
    1.11 +
    1.12 +/** Sometimes it is useful to run tests inside of the real browser. 
    1.13 + * To do that just annotate your method with {@link org.apidesign.bck2brwsr.vmtest.BrwsrTest}
    1.14 + * and that is it. If your code references elements on the HTML page,
    1.15 + * you can pass in an {@link org.apidesign.bck2brwsr.vmtest.HtmlFragment} which
    1.16 + * will be made available on the page before your test starts.
    1.17 + *
    1.18 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    1.19 + */
    1.20 +public class IntegrationTest {
    1.21 +    
    1.22 +    /** Write to testing code here. Use <code>assert</code> (but not TestNG's
    1.23 +     * Assert, as TestNG is not compiled with target 1.6 yet).
    1.24 +     */
    1.25 +    @HtmlFragment(
    1.26 +        "<h1 data-bind=\"text: helloMessage\">Loading Bck2Brwsr's Hello World...</h1>\n" +
    1.27 +        "Your name: <input id='input' data-bind=\"value: name, valueUpdate: 'afterkeydown'\"></input>\n" +
    1.28 +        "<button id=\"hello\">Say Hello!</button>\n" +
    1.29 +        "<p>\n" +
    1.30 +        "    <canvas id=\"canvas\" width=\"300\" height=\"50\"></canvas>\n" +
    1.31 +        "</p>\n"
    1.32 +    )
    1.33 +    @BrwsrTest
    1.34 +    public void modifyValueAssertChangeInModel() {
    1.35 +        Index m = new Index();
    1.36 +        m.setName("Joe Hacker");
    1.37 +        m.applyBindings();
    1.38 +        assert "Joe Hacker".equals(m.INPUT.getValue()) : "Value is really Joe Hacker: " + m.INPUT.getValue();
    1.39 +        m.INPUT.setValue("Happy Joe");
    1.40 +        m.triggerEvent(m.INPUT, OnEvent.CHANGE);
    1.41 +        assert "Happy Joe".equals(m.getName()) : "Name property updated to Happy Joe: " + m.getName();
    1.42 +    }
    1.43 +
    1.44 +    @Factory
    1.45 +    public static Object[] create() {
    1.46 +        return VMTest.create(IntegrationTest.class);
    1.47 +    }
    1.48 +    
    1.49 +}