Created
October 7, 2011 10:40
-
-
Save jumperchen/1270002 to your computer and use it in GitHub Desktop.
an example of ZTL Scala test case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Tags(tags = "Example") | |
class ExampleTest extends ZTL4ScalaTestCase { | |
def testClick() = { | |
val zscript = { | |
<vbox> | |
Click "hello world", if you see the message change, it is ok. | |
<zscript><![CDATA[ | |
public void doCreate(Event evt) { | |
evt.target.setValue(" hello,\\n world"); | |
} | |
public void doClick(Event evt) { | |
evt.target.setValue(" I have\\n been clicked"); | |
} | |
]]></zscript> | |
<label id="l1" onCreate="doCreate(event);" onClick="doClick(event)" style="font-family: monospace; white-space: pre;"/> | |
<label id="l2" onCreate="doCreate(event);" onClick="doClick(event)" pre="true"/> | |
</vbox> | |
} | |
def executor() = { | |
var l1: Widget = engine.$f("l1"); | |
var l2: Widget = engine.$f("l2"); | |
waitResponse(); | |
var strClickBefor = getText(l1); | |
click(l1); | |
waitResponse(); | |
verifyNotEquals(strClickBefor, getText(l1)); | |
strClickBefor = getText(l2); | |
click(l2); | |
waitResponse(); | |
verifyNotEquals(strClickBefor, getText(l2)); | |
} | |
// Run syntax 1 | |
runZTL(zscript, executor); | |
// Run syntax 2 | |
/** | |
runZTL(zscript, | |
() => { | |
var l1: Widget = engine.$f("l1"); | |
var l2: Widget = engine.$f("l2"); | |
waitResponse(); | |
var strClickBefor = getText(l1); | |
click(l1); | |
waitResponse(); | |
verifyNotEquals(strClickBefor, getText(l1)); | |
strClickBefor = getText(l2); | |
click(l2); | |
waitResponse(); | |
verifyNotEquals(strClickBefor, getText(l2)); | |
} | |
); | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment