|
Development | .NET Compact Framework
Regression testing your Pocket PC app, a new form of torture
Written by Derek Mitchell
[author's bio]
[read 44871 times]
Edited by Derek
Page 1
Page 2
So what this about Tcl?
The test scripts contain loops
and variables as well as conditions, procedures, expressions,
file access functions and many other items. Pocket PC TestSuite
2.0 uses Tcl as a base language for test scripts. Tcl is
a simple but powerful programming language. Tcl provides
the added flexibility and power to design very sophisticated
test scripts, but in 95% of cases you are not going to need
this level of complexity.
Here are some samples that give an overview
of some of the Tcl expertise you might need:
Variables
#this is a comment line because it starts
with #
#create 2 variables
set x 40
set y 50
#click to point (x, y)
ts_click $x $y
Loops
set x 40
set y 50
#a loop, here we click 10 times increasing
y coordinate by 1
for {set i 0} {$i<10} {incr i 1} {
ts_click $x [expr $y+$i]
}
Functions
#this function clicks 10 times to the
given point
proc click10times {x y} {
for {set i 0 } {$i<10} {incr i 1} {
ts_click $x $y
ts_wait 500 #wait 0.5 second
}
}
click10times 78 45
click10times 210 200
click10times 34 100
click10times 80 80
You can read more about Tcl in the
following Tcl
tutorial or these FAQs, Tcl
FAQ 1, Tcl
FAQ 2.
Test functions
There 22 special functions (excluding
the standard Tcl functions) that you can use in your test
scripts. You can create your own functions that will perform
batch operations if needed. Here is a list of the basic
test functions:
Simulation
Simulation functions simulate user activities
like key pressing, etc.
ts_click x y - Simulates tap
(click) to the given point
ts_mousedown x y - Simulates mouse down event in
the given point
ts_mouseup x y - Simulates mouse up event in the
given point
ts_mousemove x y - Simulates mouse move event to
the given point
ts_wait mills - Delays script for mills milliseconds
ts_key keycode - Simulates pressing of the key
with the given code
ts_keydown keycode - Simulates key down even of
the key with the given code
ts_keyup keycode - Simulates key up even of the
key with the given code
ts_text yourstring - Simulates entering of the
given string
ts_run program_path arguments - Starts program
with the given path and the given arguments (arguments
are optional)
ts_cpapplet applet_id page_id - Opens Control Panel
applet with the given id (page id is optional)
Checking
These functions are used to check
results. For example if you know that in the end of your
script the program must be in a certain state you can check
this state using the following functions:
ts_getpixel x y - Returns RGB
color of the given point (for example "230 4 34")
ts_gettext x y - Returns text of the control under
the given point. You can use this function to check text
in edit control, comboboxes, etc.
ts_getfreemem - Returns available memory in bytes
ts_checkscreenrect x1 y1 x2 y2 bmp_file_name -
Checks if the screen rectangle of [(x1,y1) - (x2,y2)]
is equal to the given bitmap file
Reporting
ts_log message_string
- Writes the given string to the log file. When the test
script is finished this log file is shown to the user.
ts_messagebox message_string - Shows message box
with the given string. Use this function for debug purposes
only because it can affect the tested process.
You can access the Pocket
PC TestSuite documentation PDF here.
Last but not least - checking the
results
It is important to check the
results after testing an app. Pocket PC TestSuite 2.0 includes
a set of functions for that. Here are main usage scenarios:
- You can get free memory (using ts_getfreemem)
then simulate actions that bring the program to the initial
state - now check that free memory os has not changed.
- You have a test script and know what
the final state of the app should be after running this
script. So you create a bitmap picture (using Remote Zooming
or the ts_savescreenrect function) and check at
the end of your script that the screen is equal to this
bitmap file (using ts_checkscreenrect).
- You can check results of your script
by checking the color of some coordinates (using ts_getpixel).
- You can check the text in windows
controls (using ts_gettext).
Conclusion
All in all Pocket PC TestSuite has saved
us hours of testing. It also ensures, after making changes
to code, that we don't get too far down the road and then
discover that we 'broke' something at some point and can't
figure out when that was?
Price
Pocket PC testSuite is $200 but you
can get a 5%
discount using this code 357F8W25.
Read
about the 5% discount on Pocket PC TestSuite through DEVBUZZ.
Previous
Page
Back to .NET Compact Framework | [Article Index]
|