https://public.kitware.com/Wiki/api.php?action=feedcontributions&user=Barre&feedformat=atomKitwarePublic - User contributions [en]2024-03-28T16:15:38ZUser contributionsMediaWiki 1.38.6https://public.kitware.com/Wiki/index.php?title=ParaView/PCL_Plugin/Download_And_Build_Instructions&diff=52715ParaView/PCL Plugin/Download And Build Instructions2013-05-16T13:17:59Z<p>Barre: /* Stage 2: Download and build PCL */</p>
<hr />
<div>== Introduction ==<br />
<br />
This page details the minimum commands required to download and build the PCL Plugin for ParaView. We assume basic knowledge of cmake and the usual Unix build process. For detailed instructions on how to build ParaView from source, we refer to [http://paraview.org/Wiki/ParaView:Build_And_Install].<br />
<br />
== Download ==<br />
<br />
The PCL Plugin for ParaView source (v1.0) can be downloaded from [[Media:PointCloudLibraryPlugin-v1.0.tar.gz|here]].<br />
<br />
== Build Instructions ==<br />
<br />
We propose a '''three-stage build process''' to compile and run the PCL plugin for ParaView: 1) ''Building a vanilla ParaView'', 2) ''Building PCL (with ParaView's VTK)'' and 3) ''Building the PCL plugin''. While other strategies are possible, we suggest to follow this process (for now) to ensure that both PCL and ParaView use the same VTK version.<br />
<br />
====Stage 1: Download and install ParaView====<br />
<br />
Download the ParaView 3.14.1 source tarball from [http://www.paraview.org/paraview/resources/software.php] and follow the [http://paraview.org/Wiki/ParaView:Build_And_Install build instructions] to compile ParaView. First, unpack the tarball, i.e., <br />
<br />
$ tar xvfz ParaView-3.14.1-Source.tar.gz<br />
$ cd ParaView-3.14.1-Source<br />
<br />
Then, create a <tt>Build</tt> directory and call <tt>ccmake</tt> to enter a graphical user interface for changing cmake variables. Alternatively, you can also set the variables on the command line.<br />
<br />
$ mkdir Build<br />
$ cd Build <br />
$ ccmake ..<br />
<br />
'''Note''': Make sure that <tt>BUILD_SHARED_LIBS</tt> is set to <tt>ON</tt> (default is <tt>OFF</tt>). Hitting 'c' followed by 'g' will configure and generate all files for the build process. Running <br />
<br />
$ make<br />
<br />
will build ParaView as well as all the submodules (such as VTK). Optionally, you can specify <tt>-jN</tt>, e.g., <tt> make -j4</tt> to speed up the compilation process by using more cores.<br />
<br />
==== Stage 2: Download and build PCL====<br />
<br />
Once we have build a vanilla ParaView, we can build PCL against ParaView's VTK version. Currently, we support PCL 1.5.1, but we are working on support for their latest SVN trunk. For detailed instructions on how to obtain PCL, we refer to PCL's [http://pointclouds.org/downloads/source.html installation instructions] for compiling from source (MacOSX users may consider [http://www.pcl-users.org/Problems-compiling-from-source-on-Mac-OS-X-Lion-td3862799.html this page] if they encounter compilation errors).<br />
<br />
For convenience, we repeat the basic commands: First unpack the tarball, enter the directory and create a <tt>Build</tt> subdirectory, i.e., <br />
<br />
$ tar xvjpf PCL-1.5.1-Source.tar.bz2<br />
$ cd PCL-1.5.1-Source<br />
$ mkdir Build<br />
$ cd Build<br />
<br />
Then, run <tt>ccmake</tt> and make sure that the <tt>VTK_DIR</tt> variable is set to<br />
<br />
VTK_DIR <FullPathToParaView>/ParaView-3.14.1-Source/Build/VTK<br />
<br />
where <tt>FullPathToParaView</tt> is the full path to the directory where you unpacked ParaView. After changing any other cmake variables, run<br />
<br />
$ make<br />
<br />
to build PCL.<br />
<br />
==== Stage 3: Building the PCL Plugin ====<br />
<br />
Now that everything is set up, we are ready to build the plugin. First, download the tarball (see above) and unpack it, i.e.,<br />
<br />
$ tar xvfz PointCloudLibraryPlugin-v1.0.tar.gz<br />
<br />
Then, create a <tt>Build</tt> directory and run <tt>ccmake</tt>, i.e., <br />
<br />
$ cd PointCloudLibraryPlugin-v1.0<br />
$ mkdir Build<br />
$ cd Build<br />
$ ccmake ..<br />
<br />
Make sure to set the <tt>ParaView_DIR</tt> and <tt>PCL_DIR</tt> cmake variables to<br />
<br />
$ PCL_DIR <FullPathToPCLSOurce>/PCL-1.5.1-Source/Build<br />
$ ParaView_DIR <FullPathToParaViewSource>/ParaView-3.14.1-Source/Build<br />
<br />
Hit 'c' and 'g' to configure and generate. Alternatively, you can set all on the <br />
command line by<br />
<br />
$ cmake -DParaView_DIR=<...> -DPCL_DIR=<...> ..<br />
<br />
Running <br />
<br />
$ make <br />
<br />
will eventuall compile the plugin and make it available for use within ParaView.<br />
<br />
=== Importing the PCL plugin in ParaView ===<br />
<br />
Now that we have built the plugin, we are ready to import it in ParaView. First, start ParaView<br />
<br />
$ cd <FullPathToParaViewSource>/ParaView-3.14.1-Source/Build<br />
$ bin/paraview<br />
<br />
Then, go to '''Tools/Manage Plugins'''. Press the '''Load New...''' button and navigate to ParaView's <tt>ParaView/Build/bin</tt> directory. Navigate to the <tt>Build/bin</tt> directory where you unpacked the plugin and select '''libvtkPCLFilters.so''' to load. You might also want to enable ''Auto Load'' so that the plugin gets automatically loaded. You should now be ready to use PCL algorithms in ParaView.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=Git&diff=42521Git2011-08-26T19:31:24Z<p>Barre: </p>
<hr />
<div>Placeholder for future Git information.<br />
See<br />
* [[Git/Download]]<br />
* [[Git/Hooks]]<br />
* [[Git/Publish]]<br />
* [[Git/Resources]]<br />
* [[Git/WorkflowPrimer]]<br />
* [[Git/Workflow]]<br />
** [[Git/Workflow/Topic]]<br />
*** [[Git/Workflow/Topic/Conflicts]]<br />
** [[Git/Workflow/Stage]]<br />
* [[Git/Trouble]]<br />
* [[VTK/Git]]<br />
* [[VTK/Git/Simple]]<br />
* [[VTK/Working With Git]]<br />
* [[ITK/Git]]<br />
* [[ITK/Git/TipsAndTricks]]<br />
* [[ITK/Git/Download]]<br />
* [[ITK/Git/Account]]<br />
* [[ParaView/Git]]<br />
* [[ParaView/Git/Simple]]<br />
* [[ParaView/Gerrit]]<br />
* [[CMake/Git]]<br />
* [http://www.vtk.org/Wiki/images/8/81/GitVTKCheatSheet.pdf Git VTK Cheat Sheet]</div>Barrehttps://public.kitware.com/Wiki/index.php?title=Git/Workflow&diff=42520Git/Workflow2011-08-26T19:31:00Z<p>Barre: </p>
<hr />
<div>This is a placeholder for pages related to Git workflow documentation.<br />
See<br />
* [[Git/Workflow/Topic]]<br />
** [[Git/Workflow/Topic/Conflicts]]<br />
* [[Git/Workflow/Stage]]</div>Barrehttps://public.kitware.com/Wiki/index.php?title=Git/Download&diff=42518Git/Download2011-08-26T18:15:27Z<p>Barre: /* MSysGit */</p>
<hr />
<div>==Generic==<br />
<br />
Visit the main Git [http://www.git-scm.com/download download site].<br />
<br />
==Windows==<br />
<br />
Git comes in two flavors on Windows:<br />
<br />
* A Windows native application installer<br />
* A Cygwin package<br />
<br />
Choose one and stick with it.<br />
They do not get along well in a given work tree on disk<br />
(the repository formats are compatible but the "stat cache" of the work tree is not unless <code>core.filemode</code> is <code>false</code>).<br />
<br />
===MSysGit===<br />
<br />
Download the "Full installer for official Git" from [http://code.google.com/p/msysgit/downloads/list here]. You want to download the file that is named something like<br />
Git-1.7.6-preview20110708.exe<br />
''If you notice that the filename has changed (because a new version was released or something similar), please update this wiki!''<br />
<br />
Run the installer. When prompted, choose to ''not'' modify the <code>PATH</code> and choose the <code>core.autocrlf=true</code> option.<br />
Launch the "Git Bash" tool to get a command line shell with Git.<br />
<br />
===Cygwin===<br />
<br />
Install packages:<br />
<br />
* '''git''': Git command-line tool<br />
* '''gitk''': Graphical history browser<br />
* '''git-completion''': Bash shell completion rules<br />
<br />
Launch a Cygwin command prompt to get a command line shell with Git.<br />
<br />
==Mac==<br />
<br />
===OS X Installer===<br />
<br />
Download an installer from [http://code.google.com/p/git-osx-installer/ here].<br />
<br />
===MacPorts===<br />
<br />
Enter these commands:<br />
<br />
$ sudo port selfupdate<br />
$ sudo port install git-core +doc<br />
<br />
==Linux==<br />
<br />
Popular Linux distributions already come with packages for Git.<br />
Typically the packages are called:<br />
<br />
* '''git-core''': Git command-line tool<br />
* '''git-doc''': Git documentation<br />
* '''gitk''': Graphical history browser</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KwGrid:Welcome&diff=15952KwGrid:Welcome2009-07-13T17:21:40Z<p>Barre: </p>
<hr />
<div>{{:kwGrid:Template/Header}}<br />
Welcome to the '''kwGrid''' Public Wiki.<br />
<br />
{| width="100%" border="0" cellspacing="0" cellpadding="3"<br />
|-<br />
| width="60" | [[Image:kwGridAnnouncementsNavIcon.png|Announcements]]<br />
| width="30%" | [[kwGrid:Announcements|Announcements]]<br><small>Latest news & updates.<br> <br />
| width="60" | [[Image:kwGridDescriptionNavIcon.png|Description]]<br />
| width="30%" | [[kwGrid:Description|Description]]<br><small>Find out more about this project, our vision and goals.</small><br />
| width="60" | &nbsp;<br />
| width="30%" | &nbsp;<br />
|- bgcolor="#F9F9F9"<br />
| [[Image:kwGridTeamNavIcon.png|Team]]<br />
| [[kwGrid:Team|Team]]<br><small>Learn more about the team and how to contact us.</small><br />
| [[Image:kwGridPartnersNavIcon.png|Partners]]<br />
| [[kwGrid:Partners|Partners]]<br><small>Meet our partners, Argonne National Lab and Ohio State University.</small><br />
| [[Image:kwGridInfrastructureNavIcon.png|Infrastructure]]<br />
| [[kwGrid:Infrastructure|Infrastructure]]<br><small>Take a peak at the infrastructure used to develop and test the project.</small><br />
|-<br />
| [[Image:kwGridStatusNavIcon.png|Status]]<br />
| [[kwGrid:Status|Status]]<br><small>Check the roadmap and the progress of the project.</small><br />
| [[Image:kwGridDownloadNavIcon.png|Download]]<br />
| [[kwGrid:Download|Download]]<br><small>Get the software, stable releases or CVS checkouts.</small><br />
| [[Image:kwGridDocumentationNavIcon.png|Documentation]]<br />
| [[kwGrid:Doc|Documentation]]<br><small>Browse our notes, FAQ's, tutorials, API's and papers.</small><br />
|- bgcolor="#F9F9F9"<br />
| [[Image:kwGridLinksNavIcon.png|Links]]<br />
| [[kwGrid:Links|Links]]<br><small>Follow links to more Grid material: books, notes, FAQ's, tutorials, softwares, API's and papers.</small><br />
| [[Image:kwGridSuggestionsNavIcon.png|Suggestions]]<br />
| [[kwGrid:Suggestions|Suggestions]]<br><small>Share your feedback, suggestions or comments.</small><br />
| &nbsp;<br />
| &nbsp;<br />
|-<br />
| [[Image:kwGridPrivateNavIcon.png|Private]]<br />
| [[kwGrid:Private/Welcome|Private]]<br><small>Access the restricted part of this site.</small><br />
| &nbsp;<br />
| &nbsp;<br />
| &nbsp;<br />
| &nbsp;<br />
|}<br />
{{:kwGrid:Template/Note Box|message=Pardon our dust while we are populating this site. Feel free to edit or contribute too (Feb 2005).}}<br />
<br />
{{:kwGrid:Template/Footer}}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KwGrid:Template/Header&diff=15951KwGrid:Template/Header2009-07-13T17:21:28Z<p>Barre: Removing all content from page</p>
<hr />
<div></div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForSlicer3&diff=14344KWWidgets/GUI Testing/Squish/SquishForSlicer32009-01-02T23:12:05Z<p>Barre: /* Add Squish tests to CTest lists */</p>
<hr />
<div>=Goals=<br />
<br />
The goal here is to add Squish tests to Slicer3, the same was some were added to KWWidgets. If you have not checked [[KWWidgets/GUI_Testing/Squish/SquishForKWWidgets|Squish with KWWidgets]] or [[KWWidgets/GUI_Testing/Squish|GUI Testing with Squish]], please do so before you adding Squish tests to Slicer3.<br />
<br />
{{:kwGrid:Template/Warning Box|message=Squish *must* be built with the same Tcl/Tk libraries that Slicer3 is using. Squish won't launch Slicer3 properly otherwise.}}<br />
<br />
The code presented in the next few sections has not been commited to Slicer3 yet, but can be used as a starting point.<br />
<br />
=Files=<br />
Modify the following files in the Slicer3 source directory:<br />
<br />
*<tt>Slicer3/CMake/SlicerMacros.cmake</tt>: define the Slicer3_ADD_Squish_TEST macro<br />
<pre><br />
# Slicer3_ADD_Squish_TEST<br />
<br />
macro(slicer3_add_squish_test<br />
test_name<br />
squish_AUT_name<br />
squish_test_case_path<br />
slicerScriptFile<br />
)<br />
<br />
# Try to find the full path to the test executable<br />
<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_get_full_path_to_executable(${squish_AUT_name} exe_path)<br />
<br />
KWWidgets_ADD_Squish_TEST(<br />
"${test_name}"<br />
"${exe_path}"<br />
"${squish_test_case_path}"<br />
"${slicerENV}"<br />
"${slicerPathsScript}"<br />
"--test-mode --script ${slicerScriptFile}"<br />
)<br />
<br />
SET_TESTS_PROPERTIES(${test_name}<br />
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED;ERROR;FATAL")<br />
<br />
endmacro(slicer3_add_squish_test)<br />
</pre><br />
<br />
=Usage=<br />
==Create Squish test suites==<br />
Create a new Squish test suite under <tt>Slicer3/Applications/GUI/Testing/Squish</tt> with the Squish IDE to instrument the <tt>bin/Slicer3-real</tt> executable. Since Squish is not able to record the file name of an Open File Dialog at the moment (an issue being discussed with FrogLogic), we need to write a Tcl script that will load a scene and a few volume(s) for us. Here is a simple example of such a script, <tt>LoadSimpleScene.tcl</tt>:<br />
<br />
<pre><br />
<br />
update<br />
$::slicer3::MRMLScene SetURL $::Slicer3_HOME/share/MRML/Testing/volScene.mrml<br />
$::slicer3::MRMLScene Connect<br />
update<br />
<br />
</pre><br />
<br />
Now copy this <tt>LoadSimpleScene.tcl</tt> file to <tt>Slicer3/Applications/GUI/Testing</tt>, go to "Test Suite -> Settings..." in the Squish IDE and modify the arguments of the AUT as follow: <tt>--test-mode --script ../../Slicer3/Applications/GUI/Testing/LoadSimpleScene.tcl</tt>. This will instruct Slicer3 to automatically run the script and open the corresponding scene when launched from Squish. Note: the <tt>--test-mode</tt> option is used to <tt>NoSplash=true</tt> and <tt>RegistryLevel=0</tt>.<br />
<br />
[[Image:SlicerSquishSettings.png| Squish settings for launch Slicer3]]<br />
<br />
==Add Squish tests to CTest lists==<br />
<br />
Add the following code to the <tt>CMakeLists.txt</tt> file under <tt>Slicer3/Applications/GUI/Testing</tt> so that Squish test suites stored in the same directory are automatically detected and the corresponding CMake tests added. The <tt>LoadSimpleScene.tcl</tt> script presented above is passed to Squish tests automatically. This is however just a simple example describing how to add a Squish test to Slicer; different Tcl scripts need to be created to cover different scenarios with different datasets; the following CMake script should be modified accordingly.<br />
<br />
<pre><br />
include("${KWWidgets_CMAKE_DIR}/FindSquish.cmake")<br />
<br />
if(SQUISH_FOUND)<br />
<br />
include("${Slicer3_CMAKE_DIR}/Slicer3Macros.cmake")<br />
<br />
file(GLOB SquishTestSuites ${Slicer3_SOURCE_DIR}/Applications/GUI/Testing/Squish/* suite_*)<br />
<br />
foreach(SquishTestSuite ${SquishTestSuites})<br />
if(IS_DIRECTORY ${SquishTestSuite})<br />
<br />
string(REGEX MATCH ".+suite_(.*)" tmp_suite_name ${SquishTestSuite})<br />
set(squish_suite_name ${CMAKE_MATCH_1}) <br />
<br />
file(GLOB SquishTests ${SquishTestSuite}/* tst_*)<br />
foreach(SquishTest ${SquishTests})<br />
if(IS_DIRECTORY ${SquishTest})<br />
<br />
string(REGEX MATCH ".+(tst_(.*))" tmp_test_name ${SquishTest})<br />
set(squish_test_name "${CMAKE_MATCH_1}") <br />
set(slicer_squish_test_name "Squish_${squish_suite_name}_${CMAKE_MATCH_2}") <br />
<br />
# message(STATUS "squish_test_name='${squish_test_name}'")<br />
# message(STATUS "slicer_squish_test_name='${slicer_squish_test_name}'")<br />
<br />
slicer3_add_squish_test(<br />
${slicer_squish_test_name} "${EXECUTABLE_OUTPUT_PATH}/Slicer3-real" <br />
"${SquishTestSuite}/${squish_test_name}"<br />
"${Slicer3_SOURCE_DIR}/Applications/GUI/Testing/LoadSimpleScene.tcl") <br />
<br />
endif(IS_DIRECTORY ${SquishTest})<br />
endforeach(SquishTest)<br />
endif(IS_DIRECTORY ${SquishTestSuite})<br />
endforeach(SquishTestSuite)<br />
<br />
endif(SQUISH_FOUND)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* [[KWWidgets/GUI_Testing/Squish/SquishForKWWidgets#Squish| Squish issues with KWWidgets]]<br />
==Slicer3==<br />
* Screenshot to create baseline images and validate the Squish image-data-processing tests.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForSlicer3&diff=14343KWWidgets/GUI Testing/Squish/SquishForSlicer32009-01-02T22:42:24Z<p>Barre: /* Use */</p>
<hr />
<div>=Goals=<br />
<br />
The goal here is to add Squish tests to Slicer3, the same was some were added to KWWidgets. If you have not checked [[KWWidgets/GUI_Testing/Squish/SquishForKWWidgets|Squish with KWWidgets]] or [[KWWidgets/GUI_Testing/Squish|GUI Testing with Squish]], please do so before you adding Squish tests to Slicer3.<br />
<br />
{{:kwGrid:Template/Warning Box|message=Squish *must* be built with the same Tcl/Tk libraries that Slicer3 is using. Squish won't launch Slicer3 properly otherwise.}}<br />
<br />
The code presented in the next few sections has not been commited to Slicer3 yet, but can be used as a starting point.<br />
<br />
=Files=<br />
Modify the following files in the Slicer3 source directory:<br />
<br />
*<tt>Slicer3/CMake/SlicerMacros.cmake</tt>: define the Slicer3_ADD_Squish_TEST macro<br />
<pre><br />
# Slicer3_ADD_Squish_TEST<br />
<br />
macro(slicer3_add_squish_test<br />
test_name<br />
squish_AUT_name<br />
squish_test_case_path<br />
slicerScriptFile<br />
)<br />
<br />
# Try to find the full path to the test executable<br />
<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_get_full_path_to_executable(${squish_AUT_name} exe_path)<br />
<br />
KWWidgets_ADD_Squish_TEST(<br />
"${test_name}"<br />
"${exe_path}"<br />
"${squish_test_case_path}"<br />
"${slicerENV}"<br />
"${slicerPathsScript}"<br />
"--test-mode --script ${slicerScriptFile}"<br />
)<br />
<br />
SET_TESTS_PROPERTIES(${test_name}<br />
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED;ERROR;FATAL")<br />
<br />
endmacro(slicer3_add_squish_test)<br />
</pre><br />
<br />
=Usage=<br />
==Create Squish test suites==<br />
Create a new Squish test suite under <tt>Slicer3/Applications/GUI/Testing/Squish</tt> with the Squish IDE to instrument the <tt>bin/Slicer3-real</tt> executable. Since Squish is not able to record the file name of an Open File Dialog at the moment (an issue being discussed with FrogLogic), we need to write a Tcl script that will load a scene and a few volume(s) for us. Here is a simple example of such a script, <tt>LoadSimpleScene.tcl</tt>:<br />
<br />
<pre><br />
<br />
update<br />
$::slicer3::MRMLScene SetURL $::Slicer3_HOME/share/MRML/Testing/volScene.mrml<br />
$::slicer3::MRMLScene Connect<br />
update<br />
<br />
</pre><br />
<br />
Now copy this <tt>LoadSimpleScene.tcl</tt> file to <tt>Slicer3/Applications/GUI/Testing</tt>, go to "Test Suite -> Settings..." in the Squish IDE and modify the arguments of the AUT as follow: <tt>--test-mode --script ../../Slicer3/Applications/GUI/Testing/LoadSimpleScene.tcl</tt>. This will instruct Slicer3 to automatically run the script and open the corresponding scene when launched from Squish. Note: the <tt>--test-mode</tt> option is used to <tt>NoSplash=true</tt> and <tt>RegistryLevel=0</tt>.<br />
<br />
[[Image:SlicerSquishSettings.png| Squish settings for launch Slicer3]]<br />
<br />
==Add Squish tests to CTest lists==<br />
Add the following to the CMakeLists.txt file under Slicer3/Applications/GUI/Testing, and here the LoadSimpleScene.tcl will then be passed to Squish tests as a AUT-start-script. NOTE: This is just a very simple example of adding a Squish test for Slicer, and for a full comprehensive GUI testing, there should be a lot of AUT-start-scripts (similar to the LoadSimpleScene.tcl) to cover all the data-loading scenarios with different datasets, and the following CMake script should be modified accordingly.<br />
<br />
<pre><br />
<br />
include("${KWWidgets_CMAKE_DIR}/FindSquish.cmake")<br />
<br />
if(SQUISH_FOUND)<br />
<br />
include("${Slicer3_CMAKE_DIR}/Slicer3Macros.cmake")<br />
<br />
file(GLOB SquishTestSuites ${Slicer3_SOURCE_DIR}/Applications/GUI/Testing/Squish/* suite_*)<br />
<br />
foreach(SquishTestSuite ${SquishTestSuites})<br />
if(IS_DIRECTORY ${SquishTestSuite})<br />
<br />
string(REGEX MATCH ".+suite_(.*)" tmp_suite_name ${SquishTestSuite})<br />
set(squish_suite_name ${CMAKE_MATCH_1}) <br />
<br />
file(GLOB SquishTests ${SquishTestSuite}/* tst_*)<br />
foreach(SquishTest ${SquishTests})<br />
if(IS_DIRECTORY ${SquishTest})<br />
<br />
string(REGEX MATCH ".+(tst_(.*))" tmp_test_name ${SquishTest})<br />
set(squish_test_name "${CMAKE_MATCH_1}") <br />
set(slicer_squish_test_name "Squish_${squish_suite_name}_${CMAKE_MATCH_2}") <br />
<br />
# message(STATUS "squish_test_name='${squish_test_name}'")<br />
# message(STATUS "slicer_squish_test_name='${slicer_squish_test_name}'")<br />
<br />
slicer3_add_squish_test(<br />
${slicer_squish_test_name} "${EXECUTABLE_OUTPUT_PATH}/Slicer3-real" <br />
"${SquishTestSuite}/${squish_test_name}"<br />
"${Slicer3_SOURCE_DIR}/Applications/GUI/Testing/LoadSimpleScene.tcl") <br />
<br />
endif(IS_DIRECTORY ${SquishTest})<br />
endforeach(SquishTest)<br />
endif(IS_DIRECTORY ${SquishTestSuite})<br />
endforeach(SquishTestSuite)<br />
<br />
endif(SQUISH_FOUND)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* [[KWWidgets/GUI_Testing/Squish/SquishForKWWidgets#Squish| Squish issues with KWWidgets]]<br />
==Slicer3==<br />
* Screenshot to create baseline images and validate the Squish image-data-processing tests.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForSlicer3&diff=14342KWWidgets/GUI Testing/Squish/SquishForSlicer32009-01-02T22:14:40Z<p>Barre: /* Files */</p>
<hr />
<div>=Goals=<br />
<br />
The goal here is to add Squish tests to Slicer3, the same was some were added to KWWidgets. If you have not checked [[KWWidgets/GUI_Testing/Squish/SquishForKWWidgets|Squish with KWWidgets]] or [[KWWidgets/GUI_Testing/Squish|GUI Testing with Squish]], please do so before you adding Squish tests to Slicer3.<br />
<br />
{{:kwGrid:Template/Warning Box|message=Squish *must* be built with the same Tcl/Tk libraries that Slicer3 is using. Squish won't launch Slicer3 properly otherwise.}}<br />
<br />
The code presented in the next few sections has not been commited to Slicer3 yet, but can be used as a starting point.<br />
<br />
=Files=<br />
Modify the following files in the Slicer3 source directory:<br />
<br />
*<tt>Slicer3/CMake/SlicerMacros.cmake</tt>: define the Slicer3_ADD_Squish_TEST macro<br />
<pre><br />
# Slicer3_ADD_Squish_TEST<br />
<br />
macro(slicer3_add_squish_test<br />
test_name<br />
squish_AUT_name<br />
squish_test_case_path<br />
slicerScriptFile<br />
)<br />
<br />
# Try to find the full path to the test executable<br />
<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_get_full_path_to_executable(${squish_AUT_name} exe_path)<br />
<br />
KWWidgets_ADD_Squish_TEST(<br />
"${test_name}"<br />
"${exe_path}"<br />
"${squish_test_case_path}"<br />
"${slicerENV}"<br />
"${slicerPathsScript}"<br />
"--test-mode --script ${slicerScriptFile}"<br />
)<br />
<br />
SET_TESTS_PROPERTIES(${test_name}<br />
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED;ERROR;FATAL")<br />
<br />
endmacro(slicer3_add_squish_test)<br />
</pre><br />
<br />
=Use=<br />
==Create Squish test suites==<br />
Create a new Squish test suite under Slicer3/Applications/GUI/Testing/Squish with the Squish IDE. Because Squish is currently not recording the file name of an open file dialog, so it normally can not play back the "open-file" properly (We are currently discussing with Squish support on how to address this issue), but as a workaround, we can write a tcl script to load a scene with volume(s) when invoking Slicer3 from Squish. Here is a simple example of the tcl script, LoadSimpleScene.tcl:<br />
<br />
<pre><br />
<br />
update<br />
$::slicer3::MRMLScene SetURL $::Slicer3_HOME/share/MRML/Testing/volScene.mrml<br />
$::slicer3::MRMLScene Connect<br />
update<br />
<br />
</pre><br />
<br />
Now add this LoadSimpleScene.tcl file to Slicer3/Applications/GUI/Testing, and change the Setting of the test suite to use this script (--test-mode --script ../../Slicer3/Applications/GUI/Testing/LoadSimpleScene.tcl), so that Slicer3 will automatically run the script and open the scene when launched from Squish. The "--test-mode" is to set "NoSplash=true" and "RegistryLevel=0".<br />
<br />
[[Image:SlicerSquishSettings.png| Squish settings for launch Slicer3]]<br />
<br />
==Add Squish tests to CTest lists==<br />
Add the following to the CMakeLists.txt file under Slicer3/Applications/GUI/Testing, and here the LoadSimpleScene.tcl will then be passed to Squish tests as a AUT-start-script. NOTE: This is just a very simple example of adding a Squish test for Slicer, and for a full comprehensive GUI testing, there should be a lot of AUT-start-scripts (similar to the LoadSimpleScene.tcl) to cover all the data-loading scenarios with different datasets, and the following CMake script should be modified accordingly.<br />
<br />
<pre><br />
<br />
include("${KWWidgets_CMAKE_DIR}/FindSquish.cmake")<br />
<br />
if(SQUISH_FOUND)<br />
<br />
include("${Slicer3_CMAKE_DIR}/Slicer3Macros.cmake")<br />
<br />
file(GLOB SquishTestSuites ${Slicer3_SOURCE_DIR}/Applications/GUI/Testing/Squish/* suite_*)<br />
<br />
foreach(SquishTestSuite ${SquishTestSuites})<br />
if(IS_DIRECTORY ${SquishTestSuite})<br />
<br />
string(REGEX MATCH ".+suite_(.*)" tmp_suite_name ${SquishTestSuite})<br />
set(squish_suite_name ${CMAKE_MATCH_1}) <br />
<br />
file(GLOB SquishTests ${SquishTestSuite}/* tst_*)<br />
foreach(SquishTest ${SquishTests})<br />
if(IS_DIRECTORY ${SquishTest})<br />
<br />
string(REGEX MATCH ".+(tst_(.*))" tmp_test_name ${SquishTest})<br />
set(squish_test_name "${CMAKE_MATCH_1}") <br />
set(slicer_squish_test_name "Squish_${squish_suite_name}_${CMAKE_MATCH_2}") <br />
<br />
# message(STATUS "squish_test_name='${squish_test_name}'")<br />
# message(STATUS "slicer_squish_test_name='${slicer_squish_test_name}'")<br />
<br />
slicer3_add_squish_test(<br />
${slicer_squish_test_name} "${EXECUTABLE_OUTPUT_PATH}/Slicer3-real" <br />
"${SquishTestSuite}/${squish_test_name}"<br />
"${Slicer3_SOURCE_DIR}/Applications/GUI/Testing/LoadSimpleScene.tcl") <br />
<br />
endif(IS_DIRECTORY ${SquishTest})<br />
endforeach(SquishTest)<br />
endif(IS_DIRECTORY ${SquishTestSuite})<br />
endforeach(SquishTestSuite)<br />
<br />
endif(SQUISH_FOUND)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* [[KWWidgets/GUI_Testing/Squish/SquishForKWWidgets#Squish| Squish issues with KWWidgets]]<br />
==Slicer3==<br />
* Screenshot to create baseline images and validate the Squish image-data-processing tests.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForSlicer3&diff=14341KWWidgets/GUI Testing/Squish/SquishForSlicer32009-01-02T22:13:31Z<p>Barre: /* Goals */</p>
<hr />
<div>=Goals=<br />
<br />
The goal here is to add Squish tests to Slicer3, the same was some were added to KWWidgets. If you have not checked [[KWWidgets/GUI_Testing/Squish/SquishForKWWidgets|Squish with KWWidgets]] or [[KWWidgets/GUI_Testing/Squish|GUI Testing with Squish]], please do so before you adding Squish tests to Slicer3.<br />
<br />
{{:kwGrid:Template/Warning Box|message=Squish *must* be built with the same Tcl/Tk libraries that Slicer3 is using. Squish won't launch Slicer3 properly otherwise.}}<br />
<br />
The code presented in the next few sections has not been commited to Slicer3 yet, but can be used as a starting point.<br />
<br />
=Files=<br />
Modify this file under Slicer3/CMake directory:<br />
<br />
*SlicerMacros.cmake: define Slicer3_ADD_Squish_TEST macro<br />
<pre><br />
# Slicer3_ADD_Squish_TEST<br />
<br />
macro(slicer3_add_squish_test<br />
test_name<br />
squish_AUT_name<br />
squish_test_case_path<br />
slicerScriptFile<br />
)<br />
<br />
# Try to find the full path to the test executable<br />
<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_get_full_path_to_executable(${squish_AUT_name} exe_path)<br />
<br />
KWWidgets_ADD_Squish_TEST(<br />
"${test_name}"<br />
"${exe_path}"<br />
"${squish_test_case_path}"<br />
"${slicerENV}"<br />
"${slicerPathsScript}"<br />
"--test-mode --script ${slicerScriptFile}"<br />
)<br />
<br />
SET_TESTS_PROPERTIES(${test_name}<br />
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED;ERROR;FATAL")<br />
<br />
endmacro(slicer3_add_squish_test)<br />
</pre><br />
<br />
=Use=<br />
==Create Squish test suites==<br />
Create a new Squish test suite under Slicer3/Applications/GUI/Testing/Squish with the Squish IDE. Because Squish is currently not recording the file name of an open file dialog, so it normally can not play back the "open-file" properly (We are currently discussing with Squish support on how to address this issue), but as a workaround, we can write a tcl script to load a scene with volume(s) when invoking Slicer3 from Squish. Here is a simple example of the tcl script, LoadSimpleScene.tcl:<br />
<br />
<pre><br />
<br />
update<br />
$::slicer3::MRMLScene SetURL $::Slicer3_HOME/share/MRML/Testing/volScene.mrml<br />
$::slicer3::MRMLScene Connect<br />
update<br />
<br />
</pre><br />
<br />
Now add this LoadSimpleScene.tcl file to Slicer3/Applications/GUI/Testing, and change the Setting of the test suite to use this script (--test-mode --script ../../Slicer3/Applications/GUI/Testing/LoadSimpleScene.tcl), so that Slicer3 will automatically run the script and open the scene when launched from Squish. The "--test-mode" is to set "NoSplash=true" and "RegistryLevel=0".<br />
<br />
[[Image:SlicerSquishSettings.png| Squish settings for launch Slicer3]]<br />
<br />
==Add Squish tests to CTest lists==<br />
Add the following to the CMakeLists.txt file under Slicer3/Applications/GUI/Testing, and here the LoadSimpleScene.tcl will then be passed to Squish tests as a AUT-start-script. NOTE: This is just a very simple example of adding a Squish test for Slicer, and for a full comprehensive GUI testing, there should be a lot of AUT-start-scripts (similar to the LoadSimpleScene.tcl) to cover all the data-loading scenarios with different datasets, and the following CMake script should be modified accordingly.<br />
<br />
<pre><br />
<br />
include("${KWWidgets_CMAKE_DIR}/FindSquish.cmake")<br />
<br />
if(SQUISH_FOUND)<br />
<br />
include("${Slicer3_CMAKE_DIR}/Slicer3Macros.cmake")<br />
<br />
file(GLOB SquishTestSuites ${Slicer3_SOURCE_DIR}/Applications/GUI/Testing/Squish/* suite_*)<br />
<br />
foreach(SquishTestSuite ${SquishTestSuites})<br />
if(IS_DIRECTORY ${SquishTestSuite})<br />
<br />
string(REGEX MATCH ".+suite_(.*)" tmp_suite_name ${SquishTestSuite})<br />
set(squish_suite_name ${CMAKE_MATCH_1}) <br />
<br />
file(GLOB SquishTests ${SquishTestSuite}/* tst_*)<br />
foreach(SquishTest ${SquishTests})<br />
if(IS_DIRECTORY ${SquishTest})<br />
<br />
string(REGEX MATCH ".+(tst_(.*))" tmp_test_name ${SquishTest})<br />
set(squish_test_name "${CMAKE_MATCH_1}") <br />
set(slicer_squish_test_name "Squish_${squish_suite_name}_${CMAKE_MATCH_2}") <br />
<br />
# message(STATUS "squish_test_name='${squish_test_name}'")<br />
# message(STATUS "slicer_squish_test_name='${slicer_squish_test_name}'")<br />
<br />
slicer3_add_squish_test(<br />
${slicer_squish_test_name} "${EXECUTABLE_OUTPUT_PATH}/Slicer3-real" <br />
"${SquishTestSuite}/${squish_test_name}"<br />
"${Slicer3_SOURCE_DIR}/Applications/GUI/Testing/LoadSimpleScene.tcl") <br />
<br />
endif(IS_DIRECTORY ${SquishTest})<br />
endforeach(SquishTest)<br />
endif(IS_DIRECTORY ${SquishTestSuite})<br />
endforeach(SquishTestSuite)<br />
<br />
endif(SQUISH_FOUND)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* [[KWWidgets/GUI_Testing/Squish/SquishForKWWidgets#Squish| Squish issues with KWWidgets]]<br />
==Slicer3==<br />
* Screenshot to create baseline images and validate the Squish image-data-processing tests.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14340KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T21:26:47Z<p>Barre: /* Usage */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Usage=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet demonstrates how to add a Squish test to one of the KWWidgets C++ example: <tt>Examples/Cxx/Callbacks</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests; make sure Squish is found by pointing KWWidgets to the appropriate <tt>SQUISH_INSTALL_DIR</tt> directory. The test itself was created from Squish, and saved to <tt>Examples/Cxx/Callbacks/Testing/Squish/suite_KWWCallbacksExample/tst_ScrollScale</tt>.<br />
<br />
<pre><br />
find_package(Squish)<br />
[...]<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
[...]<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME <br />
"${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWCallbacksExample/tst_ScrollScale")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-${PROJECT_NAME}Squish ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
The following command will list all the Squish-enabled tests available in KWWidgets:<br />
<pre><br />
barre@ubuntu804desktop:~/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug$ ctest -N -R Squish<br />
Start processing tests<br />
Test project /home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug<br />
7/ 24 Testing KWWidgets-CallbacksSquish <br />
9/ 24 Testing KWWidgets-HelloWorldSquish <br />
11/ 24 Testing KWWidgets-WidgetsTourSquish <br />
13/ 24 Testing KWWidgets-WindowWithPanelsSqui<br />
15/ 24 Testing KWWidgets-WizardDialogSquish <br />
17/ 24 Testing KWWidgets-MedicalImageViewerSq<br />
19/ 24 Testing KWWidgets-PolygonalObjectViewe<br />
</pre><br />
<br />
And here is how one would launch the Squish test for the Callbacks example, in verbose (-V) mode:<br />
<pre><br />
barre@ubuntu804desktop:~/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug$ ctest -R CallbacksSquish -V<br />
[...]<br />
/home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug/Examples/Cxx/Callbacks<br />
7/ 24 Testing KWWidgets-CallbacksSquish <br />
Test command: /usr/local/bin/cmake -V -VV --test ...<br />
/home/barre/src/KWWidgets-HEAD/CMake/KWWidgetsSquishTestScript.cmake<br />
Test timeout computed to be: 1500<br />
-- squish_aut='/home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug/bin/KWCallbacksExample'<br />
-- squish_aut_args=''<br />
-- squish_server_executable='/home/barre/build/squish-20081218-tk-src/bin/squishserver'<br />
-- squish_client_executable='/home/barre/build/squish-20081218-tk-src/bin/squishrunner'<br />
-- squish_libqtdir =''<br />
-- squish_test_case='/home/barre/src/KWWidgets-...Testing/Squish/suite_KWWCallbacksExample/tst_ScrollScale'<br />
-- squish_wrapper='Tk'<br />
-- squish_env_vars=''<br />
-- squish_aut_script='/home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug/bin/KWWidgetsSetupPaths.sh'<br />
-- The_sh_torun='/home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug/CMake/SquishRunTestCase.sh'<br />
Starting the squish server.../home/barre/build/squish-20081218-tk-src/bin/squishserver --daemon<br />
Running the test case.../home/barre/build/squish-20081218-tk-src/bin/squishrunner --testcase<br />
/home/barre/src/KWWidgets-HEAD/Examples/Cxx/Callbacks/Testing/Squish/suite_KWWCallbacksExample/tst_ScrollScale <br />
--wrapper Tk --aut /home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug/bin/KWCallbacksExample <br />
* This is an EVALUATION version of Squish. *<br />
RUNNERID: 151590003<br />
AUTID: 151590004<br />
AUTHOST: 127.0.0.1<br />
AUTPORT: 4322<br />
RUNNERID: 151590003<br />
application registered 151590004<br />
Initializing AUT context ...2009-01-02T16:15:37 START <br />
Start 'tst_ScrollScale' Test 'tst_ScrollScale' started<br />
... done.<br />
2009-01-02T16:15:39 PASS /mnt/hgfs/src/kitware/KWWidgets/KWWidgets-HEAD/...<br />
VP1: Object property comparison of<br />
':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3...vtkKWMyWidget0.vtkKWScale0.getvalue' <br />
passed'32.0' and '32.0' are equal (VP1)<br />
2009-01-02T16:15:41 END End 'tst_ScrollScale' End of test 'tst_ScrollScale'<br />
*******************************************************<br />
Summary:<br />
Number of Test Cases: 1<br />
Number of Tests: 1<br />
Number of Errors: 0<br />
Number of Fatals: 0<br />
Number of Fails: 0<br />
Number of Passes: 1<br />
Number of Expected Fails: 0<br />
Number of Unexpected Passes: 0<br />
Number of Warnings: 0<br />
*******************************************************<br />
Stopping the squish server.../home/barre/build/squish-20081218-tk-src/bin/squishserver --stop<br />
Attempting to shut down server at port 4322<br />
Done<br />
-- Process completed<br />
Passed<br />
[...]<br />
The following tests passed:<br />
KWWidgets-CallbacksSquish<br />
<br />
100% tests passed, 0 tests failed out of 1 <br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events at the application and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
{{:kwGrid:Template/Note Box|message=FrogLogic is aware of this issue, and they will try to address it in the next Squish release. In the meantime, one workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.}}<br />
* Similar to the <tt>vtkKWMenuButton</tt>, too many mouse move events are recorded and played back when performing a mouse "drag" over a render window.<br />
* Squish sends events to the AUT (Application Under Testing) asynchronously during playback; it does not know if the events are actually processed or not, i.e. how long it will actually take the application to react to each event on a computer different than the one that was used to create the test itself.<br />
* Events from secondary toplevel dialogs are not recorded yet. For example, in WidgetsTourExample, select MultiColumnList from the left panel and double click on the color button: this will launch a color-picker dialog, which is KWWidgets's own color dialog. Squish does not seem to be able to record any of the mouse event coming from this toplevel dialog.<br />
* Squish does not record/track the file name from a file dialog, since it just records the mouse events without knowledge of the semantics of the widget. The same is true for the color-picker-dialog, as reported previously.<br />
<br />
==KWWidgets==<br />
* In order to validate tests that operate on image data, a KWWidgets application needs to be able to grab a screenshot of its VTK render windows, so that baseline images can be created and compared at the end of a Squish test, for validation purposes. This shouldn't be too hard to add since most of VTK is tested that way.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14339KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T21:25:39Z<p>Barre: /* Usage */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Usage=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet demonstrates how to add a Squish test to one of the KWWidgets C++ example: <tt>Examples/Cxx/Callbacks</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests; make sure Squish is found by pointing KWWidgets to the appropriate <tt>SQUISH_INSTALL_DIR</tt> directory. The test itself was created from Squish, and saved to <tt>Examples/Cxx/Callbacks/Testing/Squish/suite_KWWCallbacksExample/tst_ScrollScale</tt>.<br />
<br />
<pre><br />
find_package(Squish)<br />
[...]<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
[...]<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME <br />
"${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWCallbacksExample/tst_ScrollScale")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-${PROJECT_NAME}Squish ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
The following command will list all the Squish-enabled tests available in KWWidgets:<br />
<pre><br />
barre@ubuntu804desktop:~/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug$ ctest -N -R Squish<br />
Start processing tests<br />
Test project /home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug<br />
7/ 24 Testing KWWidgets-CallbacksSquish <br />
9/ 24 Testing KWWidgets-HelloWorldSquish <br />
11/ 24 Testing KWWidgets-WidgetsTourSquish <br />
13/ 24 Testing KWWidgets-WindowWithPanelsSqui<br />
15/ 24 Testing KWWidgets-WizardDialogSquish <br />
17/ 24 Testing KWWidgets-MedicalImageViewerSq<br />
19/ 24 Testing KWWidgets-PolygonalObjectViewe<br />
</pre><br />
<br />
And here is how one would launch the Squish test for the Callbacks example:<br />
<pre><br />
barre@ubuntu804desktop:~/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug$ ctest -R CallbacksSquish -V<br />
[...]<br />
/home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug/Examples/Cxx/Callbacks<br />
7/ 24 Testing KWWidgets-CallbacksSquish <br />
Test command: /usr/local/bin/cmake -V -VV --test ...<br />
/home/barre/src/KWWidgets-HEAD/CMake/KWWidgetsSquishTestScript.cmake<br />
Test timeout computed to be: 1500<br />
-- squish_aut='/home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug/bin/KWCallbacksExample'<br />
-- squish_aut_args=''<br />
-- squish_server_executable='/home/barre/build/squish-20081218-tk-src/bin/squishserver'<br />
-- squish_client_executable='/home/barre/build/squish-20081218-tk-src/bin/squishrunner'<br />
-- squish_libqtdir =''<br />
-- squish_test_case='/home/barre/src/KWWidgets-...Testing/Squish/suite_KWWCallbacksExample/tst_ScrollScale'<br />
-- squish_wrapper='Tk'<br />
-- squish_env_vars=''<br />
-- squish_aut_script='/home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug/bin/KWWidgetsSetupPaths.sh'<br />
-- The_sh_torun='/home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug/CMake/SquishRunTestCase.sh'<br />
Starting the squish server.../home/barre/build/squish-20081218-tk-src/bin/squishserver --daemon<br />
Running the test case.../home/barre/build/squish-20081218-tk-src/bin/squishrunner --testcase<br />
/home/barre/src/KWWidgets-HEAD/Examples/Cxx/Callbacks/Testing/Squish/suite_KWWCallbacksExample/tst_ScrollScale <br />
--wrapper Tk --aut /home/barre/build/KWWidgets-HEAD-VTK-5-2-tcl85-debug/bin/KWCallbacksExample <br />
* This is an EVALUATION version of Squish. *<br />
RUNNERID: 151590003<br />
AUTID: 151590004<br />
AUTHOST: 127.0.0.1<br />
AUTPORT: 4322<br />
RUNNERID: 151590003<br />
application registered 151590004<br />
Initializing AUT context ...2009-01-02T16:15:37 START <br />
Start 'tst_ScrollScale' Test 'tst_ScrollScale' started<br />
... done.<br />
2009-01-02T16:15:39 PASS /mnt/hgfs/src/kitware/KWWidgets/KWWidgets-HEAD/...<br />
VP1: Object property comparison of<br />
':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3...vtkKWMyWidget0.vtkKWScale0.getvalue' <br />
passed'32.0' and '32.0' are equal (VP1)<br />
2009-01-02T16:15:41 END End 'tst_ScrollScale' End of test 'tst_ScrollScale'<br />
*******************************************************<br />
Summary:<br />
Number of Test Cases: 1<br />
Number of Tests: 1<br />
Number of Errors: 0<br />
Number of Fatals: 0<br />
Number of Fails: 0<br />
Number of Passes: 1<br />
Number of Expected Fails: 0<br />
Number of Unexpected Passes: 0<br />
Number of Warnings: 0<br />
*******************************************************<br />
Stopping the squish server.../home/barre/build/squish-20081218-tk-src/bin/squishserver --stop<br />
Attempting to shut down server at port 4322<br />
Done<br />
-- Process completed<br />
Passed<br />
[...]<br />
The following tests passed:<br />
KWWidgets-CallbacksSquish<br />
<br />
100% tests passed, 0 tests failed out of 1 <br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events at the application and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
{{:kwGrid:Template/Note Box|message=FrogLogic is aware of this issue, and they will try to address it in the next Squish release. In the meantime, one workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.}}<br />
* Similar to the <tt>vtkKWMenuButton</tt>, too many mouse move events are recorded and played back when performing a mouse "drag" over a render window.<br />
* Squish sends events to the AUT (Application Under Testing) asynchronously during playback; it does not know if the events are actually processed or not, i.e. how long it will actually take the application to react to each event on a computer different than the one that was used to create the test itself.<br />
* Events from secondary toplevel dialogs are not recorded yet. For example, in WidgetsTourExample, select MultiColumnList from the left panel and double click on the color button: this will launch a color-picker dialog, which is KWWidgets's own color dialog. Squish does not seem to be able to record any of the mouse event coming from this toplevel dialog.<br />
* Squish does not record/track the file name from a file dialog, since it just records the mouse events without knowledge of the semantics of the widget. The same is true for the color-picker-dialog, as reported previously.<br />
<br />
==KWWidgets==<br />
* In order to validate tests that operate on image data, a KWWidgets application needs to be able to grab a screenshot of its VTK render windows, so that baseline images can be created and compared at the end of a Squish test, for validation purposes. This shouldn't be too hard to add since most of VTK is tested that way.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14338KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T21:12:06Z<p>Barre: /* KWWidgets */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Usage=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet shows how to add a Squish test to one of KWWidgets' C++ example: <tt>Examples/Cxx/WidgetsTour</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests. Make sure Squish is found by pointing KWWidgets to the appropriate SQUISH_INSTALL_DIR directory. The test itself was created from Squish, and saved to <tt>Examples/Cxx/WidgetsTour/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets</tt>.<br />
<br />
<pre><br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events at the application and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
{{:kwGrid:Template/Note Box|message=FrogLogic is aware of this issue, and they will try to address it in the next Squish release. In the meantime, one workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.}}<br />
* Similar to the <tt>vtkKWMenuButton</tt>, too many mouse move events are recorded and played back when performing a mouse "drag" over a render window.<br />
* Squish sends events to the AUT (Application Under Testing) asynchronously during playback; it does not know if the events are actually processed or not, i.e. how long it will actually take the application to react to each event on a computer different than the one that was used to create the test itself.<br />
* Events from secondary toplevel dialogs are not recorded yet. For example, in WidgetsTourExample, select MultiColumnList from the left panel and double click on the color button: this will launch a color-picker dialog, which is KWWidgets's own color dialog. Squish does not seem to be able to record any of the mouse event coming from this toplevel dialog.<br />
* Squish does not record/track the file name from a file dialog, since it just records the mouse events without knowledge of the semantics of the widget. The same is true for the color-picker-dialog, as reported previously.<br />
<br />
==KWWidgets==<br />
* In order to validate tests that operate on image data, a KWWidgets application needs to be able to grab a screenshot of its VTK render windows, so that baseline images can be created and compared at the end of a Squish test, for validation purposes. This shouldn't be too hard to add since most of VTK is tested that way.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14337KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T21:10:20Z<p>Barre: /* Squish */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Usage=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet shows how to add a Squish test to one of KWWidgets' C++ example: <tt>Examples/Cxx/WidgetsTour</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests. Make sure Squish is found by pointing KWWidgets to the appropriate SQUISH_INSTALL_DIR directory. The test itself was created from Squish, and saved to <tt>Examples/Cxx/WidgetsTour/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets</tt>.<br />
<br />
<pre><br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events at the application and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
{{:kwGrid:Template/Note Box|message=FrogLogic is aware of this issue, and they will try to address it in the next Squish release. In the meantime, one workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.}}<br />
* Similar to the <tt>vtkKWMenuButton</tt>, too many mouse move events are recorded and played back when performing a mouse "drag" over a render window.<br />
* Squish sends events to the AUT (Application Under Testing) asynchronously during playback; it does not know if the events are actually processed or not, i.e. how long it will actually take the application to react to each event on a computer different than the one that was used to create the test itself.<br />
* Events from secondary toplevel dialogs are not recorded yet. For example, in WidgetsTourExample, select MultiColumnList from the left panel and double click on the color button: this will launch a color-picker dialog, which is KWWidgets's own color dialog. Squish does not seem to be able to record any of the mouse event coming from this toplevel dialog.<br />
* Squish does not record/track the file name from a file dialog, since it just records the mouse events without knowledge of the semantics of the widget. The same is true for the color-picker-dialog, as reported previously.<br />
<br />
==KWWidgets==<br />
* In order to validate tests that operate on image data, a KWWidgets application needs to be able to grab a screenshot of the render window or render windows, so that baseline images can be created and compared with the squish test results, for validation purposes.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14336KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T21:09:02Z<p>Barre: /* Use */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Usage=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet shows how to add a Squish test to one of KWWidgets' C++ example: <tt>Examples/Cxx/WidgetsTour</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests. Make sure Squish is found by pointing KWWidgets to the appropriate SQUISH_INSTALL_DIR directory. The test itself was created from Squish, and saved to <tt>Examples/Cxx/WidgetsTour/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets</tt>.<br />
<br />
<pre><br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
{{:kwGrid:Template/Note Box|message=FrogLogic is aware of this issue, and they will try to address it in the next Squish release. In the meantime, one workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.}}<br />
* Similar to the <tt>vtkKWMenuButton</tt>, too many mouse move events are recorded and played back when performing a mouse "drag" over the render window.<br />
* Squish sends events to the AUT (Application Under Testing) asynchronously during playback; it does not know if the events are actually processed or not, i.e. how long it will actually take the application to react to each event on a computer different than the one that was used to create the test itself.<br />
* Events from secondary toplevel dialogs are not recorded yet. For example, in WidgetsTourExample, select MultiColumnList from the left panel and double click on the color button: this will launch a color-picker dialog, which is KWWidgets's own color dialog. Squish does not seem to be able to record any of the mouse event coming from this toplevel dialog.<br />
* Squish does not record/track the file name from a file dialog, since it just records the mouse events without knowledge of the semantics of the widget. The same is true for the color-picker-dialog, as reported previously.<br />
<br />
==KWWidgets==<br />
* In order to validate tests that operate on image data, a KWWidgets application needs to be able to grab a screenshot of the render window or render windows, so that baseline images can be created and compared with the squish test results, for validation purposes.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14335KWWidgets/GUI Testing/Squish2009-01-02T21:07:32Z<p>Barre: /* TODO */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
"--with-pydir=/usr/share/python"<br />
<br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. An IMPORTANT note for building/running Squish is, you have to build Squish with the the same version of Tcl/Tk used by the AUT (Application Under Test) , because it doesn't work if Squish and its AUT(KWWidgets or Slicer) are built with different versions of Tcl/Tk. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>). Also, you will need to install libxss-dev package if it is not installed. <br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's shorten the <tt>snooze</tt> command to 1 second, since it is now the last statement (or remove it altogether).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. Note the contents of the "Test Log" tab in the "Output" panel at the bottom:<br />
<pre><br />
START Fri Nov 7 17:11:24 2008 Start 'tst_Test1' (Passes: 0, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
END Fri Nov 7 17:11:25 2008 End 'tst_Test1'<br />
End of test 'tst_Test1' <br />
</pre><br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkExecuteTestCase.png|thumb|left|175px|Execute Test Case]]<br />
|}<br />
<br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity (in our case, the scale widget).<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *after* the <tt>invoke scrollTo</tt> command line, say on the <tt>snooze</tt> command line, for example (you can manually type such statement if you removed it previously, just like if you were editing Tcl code). Click in the gray column immediately to the left of the line, where its number is displayed, to insert a breakpoint.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu bar. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu bar, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu bar. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the specific command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it). You may also remove the <tt>snooze</tt> statement, or move it before <tt>test vp</tt>.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result. The Verification Point passed, yes!<br />
<pre><br />
START Fri Nov 7 17:33:16 2008 Start 'tst_Test1' (Passes: 1, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
PASS Fri Nov 7 17:33:17 2008 /home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:4: VP1:<br />
Object property comparison of :KWCallbacksExample.vtkKWWindow0.[...]vtkKWScale0.getvalue' passed<br />
'50.0' and '50.0' are equal (VP1) <br />
END Fri Nov 7 17:33:18 2008 End 'tst_Test1' <br />
End of test 'tst_Test1' <br />
</pre><br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}<br />
<br />
===Run the Test Case on the command-line===<br />
A whole test suite or individual test cases can be run from the command-line, thus allowing them to be part of nightly regression dashboards. <br />
<br />
* Make sure the [http://www.froglogic.com/download/book/rg-cmdline.html#rgc-squishrunner Squish Server] is running:<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ bin/squishserver &<br />
</pre><br />
* Pass the test suite to the [http://www.froglogic.com/download/book/rg-cmdline.html#rgc-squishrunner Squish Runner] executable:<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ bin/squishrunner --testsuite ~/tmp/kww_test/suite_kwcallbacksexample/<br />
2008-11-07T17:42:40 START Start 'suite_kwcallbacksexample' Test 'suite_kwcallbacksexample' started<br />
Debug: Client thread created, sock: 8<br />
Debug: Connection established from 127.0.0.1<br />
RUNNERID: 247170001<br />
AUTID: 247170002<br />
AUTHOST: 127.0.0.1<br />
AUTPORT: 4322<br />
RUNNERID: 247170001<br />
Debug: Client thread created, sock: 9<br />
Debug: Connection established from 127.0.0.1<br />
application registered 247170002<br />
Initializing AUT context ...<br />
2008-11-07T17:42:41 START_TEST_CASE Start 'tst_Test1' Test Case 'tst_Test1' started<br />
... done.<br />
2008-11-07T17:42:42 PASS /home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:4:<br />
VP1: Object property comparison of ':KWCallbacksExample.vtkKWWindow0.[...].vtkKWScale0.getvalue' passed<br />
'50.0' and '50.0' are equal (VP1)<br />
2008-11-07T17:42:43 END_TEST_CASE End 'tst_Test1' End of test case 'tst_Test1'<br />
2008-11-07T17:42:44 END End 'suite_kwcallbacksexample' End of test 'suite_kwcallbacksexample'<br />
*******************************************************<br />
Summary:<br />
Number of Test Cases: 1<br />
Number of Tests: 1<br />
Number of Errors: 0<br />
Number of Fatals: 0<br />
Number of Fails: 0<br />
Number of Passes: 1<br />
Number of Expected Fails: 0<br />
Number of Unexpected Passes: 0<br />
Number of Warnings: 0<br />
*******************************************************<br />
</pre><br />
* If VTK_DEBUG_LEAKS was turned ON, you may notice some debug leaks. This seems to happen when the AUT is terminated by closing the window directly (wrong signal maybe?). The test will still pass though. One workaround is to use select "File|Exit" in the AUT's menu bar, which will exercise the menu bar at the same time!<br />
<br />
==Using Squish with KWWidgets==<br />
*[[KWWidgets/GUI_Testing/Squish/SquishForKWWidgets| Squish with KWWidgets]]<br />
*[[KWWidgets/GUI_Testing/Squish/SquishForSlicer3| Squish with Slicer3]]</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14334KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T21:06:03Z<p>Barre: /* Use */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Use=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet shows how to add a Squish test to one of KWWidgets' C++ example: <tt>Examples/Cxx/WidgetsTour</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests. Make sure Squish is found by pointing KWWidgets to the appropriate SQUISH_INSTALL_DIR directory. The test itself was created from Squish, and saved to <tt>Examples/Cxx/WidgetsTour/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets</tt>.<br />
<br />
<pre><br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
{{:kwGrid:Template/Note Box|message=FrogLogic is aware of this issue, and they will try to address it in the next Squish release. In the meantime, one workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.}}<br />
* Similar to the <tt>vtkKWMenuButton</tt>, too many mouse move events are recorded and played back when performing a mouse "drag" over the render window.<br />
* Squish sends events to the AUT (Application Under Testing) asynchronously during playback; it does not know if the events are actually processed or not, i.e. how long it will actually take the application to react to each event on a computer different than the one that was used to create the test itself.<br />
* Events from secondary toplevel dialogs are not recorded yet. For example, in WidgetsTourExample, select MultiColumnList from the left panel and double click on the color button: this will launch a color-picker dialog, which is KWWidgets's own color dialog. Squish does not seem to be able to record any of the mouse event coming from this toplevel dialog.<br />
* Squish does not record/track the file name from a file dialog, since it just records the mouse events without knowledge of the semantics of the widget. The same is true for the color-picker-dialog, as reported previously.<br />
<br />
==KWWidgets==<br />
* In order to validate tests that operate on image data, a KWWidgets application needs to be able to grab a screenshot of the render window or render windows, so that baseline images can be created and compared with the squish test results, for validation purposes.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14333KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T19:09:31Z<p>Barre: /* Use */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Use=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet shows how to add a Squish test to one of KWWidgets' C++ example: <tt>Examples/Cxx/WidgetsTour</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests. Make sure Squish is found by pointing KWWidgets to the appropriate SQUISH_INSTALL_DIR directory.<br />
<br />
<pre><br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
{{:kwGrid:Template/Note Box|message=FrogLogic is aware of this issue, and they will try to address it in the next Squish release. In the meantime, one workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.}}<br />
* Similar to the <tt>vtkKWMenuButton</tt>, too many mouse move events are recorded and played back when performing a mouse "drag" over the render window.<br />
* Squish sends events to the AUT (Application Under Testing) asynchronously during playback; it does not know if the events are actually processed or not, i.e. how long it will actually take the application to react to each event on a computer different than the one that was used to create the test itself.<br />
* Events from secondary toplevel dialogs are not recorded yet. For example, in WidgetsTourExample, select MultiColumnList from the left panel and double click on the color button: this will launch a color-picker dialog, which is KWWidgets's own color dialog. Squish does not seem to be able to record any of the mouse event coming from this toplevel dialog.<br />
* Squish does not record/track the file name from a file dialog, since it just records the mouse events without knowledge of the semantics of the widget. The same is true for the color-picker-dialog, as reported previously.<br />
<br />
==KWWidgets==<br />
* In order to validate tests that operate on image data, a KWWidgets application needs to be able to grab a screenshot of the render window or render windows, so that baseline images can be created and compared with the squish test results, for validation purposes.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14332KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T19:06:21Z<p>Barre: /* Squish */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Use=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet shows how to add a Squish test to one of KWWidgets' C++ example: <tt>Examples/Cxx/WidgetsTour</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests.<br />
<br />
<pre><br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
{{:kwGrid:Template/Note Box|message=FrogLogic is aware of this issue, and they will try to address it in the next Squish release. In the meantime, one workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.}}<br />
* Similar to the <tt>vtkKWMenuButton</tt>, too many mouse move events are recorded and played back when performing a mouse "drag" over the render window.<br />
* Squish sends events to the AUT (Application Under Testing) asynchronously during playback; it does not know if the events are actually processed or not, i.e. how long it will actually take the application to react to each event on a computer different than the one that was used to create the test itself.<br />
* Events from secondary toplevel dialogs are not recorded yet. For example, in WidgetsTourExample, select MultiColumnList from the left panel and double click on the color button: this will launch a color-picker dialog, which is KWWidgets's own color dialog. Squish does not seem to be able to record any of the mouse event coming from this toplevel dialog.<br />
* Squish does not record/track the file name from a file dialog, since it just records the mouse events without knowledge of the semantics of the widget. The same is true for the color-picker-dialog, as reported previously.<br />
<br />
==KWWidgets==<br />
* In order to validate tests that operate on image data, a KWWidgets application needs to be able to grab a screenshot of the render window or render windows, so that baseline images can be created and compared with the squish test results, for validation purposes.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14331KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T18:58:04Z<p>Barre: /* KWWidgets */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Use=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet shows how to add a Squish test to one of KWWidgets' C++ example: <tt>Examples/Cxx/WidgetsTour</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests.<br />
<br />
<pre><br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
{{:kwGrid:Template/Note Box|message=FrogLogic is aware of this issue, and they will try to address it in the next Squish release. In the meantime, one workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.}}<br />
* Similar to the <tt>vtkKWMenuButton</tt>, too many mouse move events are recorded and played back when performing a mouse "drag" over the render window.<br />
* The 'asynchronous way' of sending events while playing back a Squish test, ie, Squish will just send events it recorded without checking whether the sent events are processed or not.<br />
* Events from secondary toplevel dialogs are not recorded. For example, in WidgetsTourExample, select MultiColumnList from the left panel and double click on the color button: this will launch a color-picker dialog, which is KWWidgets's own color dialog. Squish does not seem to be able to record any of the mouse event on this color-picker-dialog.<br />
* Squish does not record the file name from a file dialog, because it just records the mouse events without knowledge of the internals of the widget. The same is true for the color-picker-dialog, as reported previously: Squish is not "recording" the color, instead, it just records the mouse events.<br />
<br />
==KWWidgets==<br />
* In order to validate tests that operate on image data, a KWWidgets application needs to be able to grab a screenshot of the render window or render windows, so that baseline images can be created and compared with the squish test results, for validation purposes.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14330KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T18:56:33Z<p>Barre: /* Squish */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Use=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet shows how to add a Squish test to one of KWWidgets' C++ example: <tt>Examples/Cxx/WidgetsTour</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests.<br />
<br />
<pre><br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
{{:kwGrid:Template/Note Box|message=FrogLogic is aware of this issue, and they will try to address it in the next Squish release. In the meantime, one workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.}}<br />
* Similar to the <tt>vtkKWMenuButton</tt>, too many mouse move events are recorded and played back when performing a mouse "drag" over the render window.<br />
* The 'asynchronous way' of sending events while playing back a Squish test, ie, Squish will just send events it recorded without checking whether the sent events are processed or not.<br />
* Events from secondary toplevel dialogs are not recorded. For example, in WidgetsTourExample, select MultiColumnList from the left panel and double click on the color button: this will launch a color-picker dialog, which is KWWidgets's own color dialog. Squish does not seem to be able to record any of the mouse event on this color-picker-dialog.<br />
* Squish does not record the file name from a file dialog, because it just records the mouse events without knowledge of the internals of the widget. The same is true for the color-picker-dialog, as reported previously: Squish is not "recording" the color, instead, it just records the mouse events.<br />
<br />
==KWWidgets==<br />
* In order to validate Squish tests that process image data, KWWidgets Application needs to be able to easily grab a screenshot of the render window or render windows, so that baseline images can be created, and compared with the squish test results, as a validation of the tests</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14329KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T18:52:29Z<p>Barre: /* Squish */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Use=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet shows how to add a Squish test to one of KWWidgets' C++ example: <tt>Examples/Cxx/WidgetsTour</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests.<br />
<br />
<pre><br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not handle the <tt>vtkKWMenuButton</tt> widget properly. The replay sequence is sending too many mouse motion events and it takes a long time to playback the corresponding "picking a menu entry" action. <br />
Squish is aware of this, and they will try to address this issue in the next release. <br />
In the meantime, the workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.<br />
* Similar to the vtkKWMenuButton, there are two many mouse move events are recorded and played back when you do a mouse 'drag" on the render window.<br />
* The 'asynchronous way' of sending events while playing back a Squish test, ie, Squish will just send events it recorded without checking whether the sent events are processed or not.<br />
* The events from secondary dialogs are not recorded. For example, in WidgetsTourExample, select MultiColumnList from left panel, double click on the color button, which will launch a color-picker dialog, which is our own dialog with own own composite color-picker widget. Squish seems not be able to record any of the mouse event on this color-picker-dialog.<br />
* Squish does not record the file name from a file dialog, because it just records the mouse events without knowing the underneath widget. The same is true for the color-picker-dialog, Squish is not recording the color, instead, it just records the mouse events.<br />
<br />
==KWWidgets==<br />
* In order to validate Squish tests that process image data, KWWidgets Application needs to be able to easily grab a screenshot of the render window or render windows, so that baseline images can be created, and compared with the squish test results, as a validation of the tests</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14328KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T18:50:19Z<p>Barre: /* Use */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Use=<br />
<br />
The following <tt>CMakeLists.txt</tt> snippet shows how to add a Squish test to one of KWWidgets' C++ example: <tt>Examples/Cxx/WidgetsTour</tt>. The <tt>KWWidgets_USE_Squish</tt> option should be turned to ON for KWWidgets to add the corresponding tests.<br />
<br />
<pre><br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_USE_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not work with vtkKWMenuButton properly. The replay is sending too many mouse motion events, so that it will take a long time to playback "picking a menu entry". <br />
Squish is aware of this, and they will try to address this issue in the next release. <br />
In the meantime, the workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.<br />
* Similar to the vtkKWMenuButton, there are two many mouse move events are recorded and played back when you do a mouse 'drag" on the render window.<br />
* The 'asynchronous way' of sending events while playing back a Squish test, ie, Squish will just send events it recorded without checking whether the sent events are processed or not.<br />
* The events from secondary dialogs are not recorded. For example, in WidgetsTourExample, select MultiColumnList from left panel, double click on the color button, which will launch a color-picker dialog, which is our own dialog with own own composite color-picker widget. Squish seems not be able to record any of the mouse event on this color-picker-dialog.<br />
* Squish does not record the file name from a file dialog, because it just records the mouse events without knowing the underneath widget. The same is true for the color-picker-dialog, Squish is not recording the color, instead, it just records the mouse events.<br />
<br />
==KWWidgets==<br />
* In order to validate Squish tests that process image data, KWWidgets Application needs to be able to easily grab a screenshot of the render window or render windows, so that baseline images can be created, and compared with the squish test results, as a validation of the tests</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14327KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T18:33:55Z<p>Barre: /* Files */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the <tt>KWWidgets/CMake</tt> directory. Most of them were adapted from Brad Davis' scripts.<br />
*<tt>FindSquish.cmake</tt>: locates Squish and sets SQUISH_FOUND.<br />
{{:kwGrid:Template/Warning Box|message=The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.}}<br />
*<tt>KWWidgetsSquishTestScript.cmake</tt>: implements a Squish testing sequence (start Squish server, run test, stop Squish server, etc.). <br />
*<tt>SquishRunTestCase.sh</tt>: The shell script launched by <tt>KWWidgetsSquishTestScript.cmake</tt> to run the testing sequence.<br />
<br />
The <tt>KWWidgets_ADD_Squish_TEST macro</tt> is defined in <tt>KWWidgetsTestingMacro.cmake</tt>:<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Use=<br />
<br />
The following CMakeLists.txt file shows how to add a Squish test to a KWWidgets Cxx Example project, for example, Examples/Cxx/WidgetsTour . <br />
A "KWWidgets_TEST_WITH_Squish" option is added to KWWidgets CMakeLists.txt, and by default it is OFF, so you have to turn it ON to add squish tests, given SQUISH_FOUND is true.<br />
<br />
<pre><br />
<br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_TEST_WITH_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_TEST_WITH_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not work with vtkKWMenuButton properly. The replay is sending too many mouse motion events, so that it will take a long time to playback "picking a menu entry". <br />
Squish is aware of this, and they will try to address this issue in the next release. <br />
In the meantime, the workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.<br />
* Similar to the vtkKWMenuButton, there are two many mouse move events are recorded and played back when you do a mouse 'drag" on the render window.<br />
* The 'asynchronous way' of sending events while playing back a Squish test, ie, Squish will just send events it recorded without checking whether the sent events are processed or not.<br />
* The events from secondary dialogs are not recorded. For example, in WidgetsTourExample, select MultiColumnList from left panel, double click on the color button, which will launch a color-picker dialog, which is our own dialog with own own composite color-picker widget. Squish seems not be able to record any of the mouse event on this color-picker-dialog.<br />
* Squish does not record the file name from a file dialog, because it just records the mouse events without knowing the underneath widget. The same is true for the color-picker-dialog, Squish is not recording the color, instead, it just records the mouse events.<br />
<br />
==KWWidgets==<br />
* In order to validate Squish tests that process image data, KWWidgets Application needs to be able to easily grab a screenshot of the render window or render windows, so that baseline images can be created, and compared with the squish test results, as a validation of the tests</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish/SquishForKWWidgets&diff=14326KWWidgets/GUI Testing/Squish/SquishForKWWidgets2009-01-02T18:10:22Z<p>Barre: /* Files */</p>
<hr />
<div>=Goals=<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner). <br />
* Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
<br />
=Files=<br />
The following files were added to the KWWidgets/CMake directory.<br />
*FindSquish.cmake: locates Squish and sets SQUISH_FOUND. (This script is written by Brad Davis)<br />
NOTE: The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, <br />
the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.<br />
*KWWidgetsSquishTestScript.cmake: implements Squish testing sequence (start server, run test, stop server, by invoking SquishRunTestCase.sh). <br />
(This script is based on the SquishTestScript.cmake written by Brad Davis)<br />
*SquishRunTestCase.sh: The actual shell script to be launched by KWWidgetsSquishTestScript.cmake. (This shell script is written by Brad Davis)<br />
* KWWidgets_ADD_Squish_TEST macro is defined in KWWidgetsTestingMacro.cmake.<br />
<br />
<pre><br />
# KWWidgets_ADD_Squish_TEST<br />
<br />
macro(KWWidgets_ADD_Squish_TEST <br />
test_name<br />
squish_AUT_full_path<br />
squish_test_case_path<br />
aut_env<br />
aut_path_script<br />
aut_args<br />
)<br />
<br />
set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")<br />
<br />
# Can only handle "Tk"<br />
set(squish_script_wrapper "Tk")<br />
<br />
ADD_TEST(${test_name}<br />
${CMAKE_COMMAND} -V -VV --test<br />
"-Dsquish_aut:STRING=${squish_AUT_full_path}"<br />
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"<br />
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"<br />
"-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"<br />
"-Dsquish_test_case:STRING=${squish_test_case_path}"<br />
"-Dsquish_env_vars:STRING=${aut_env}"<br />
"-Dsquish_wrapper:STRING=${squish_script_wrapper}"<br />
"-Dsquish_aut_script:STRING=${aut_path_script}"<br />
"-Dsquish_shell_script:STRING=${kwwSquishShellScript}"<br />
"-Dsquish_aut_args:STRING=${aut_args}"<br />
-P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"<br />
${ARGN})<br />
<br />
endmacro(KWWidgets_ADD_Squish_TEST)<br />
</pre><br />
<br />
=Use=<br />
<br />
The following CMakeLists.txt file shows how to add a Squish test to a KWWidgets Cxx Example project, for example, Examples/Cxx/WidgetsTour . <br />
A "KWWidgets_TEST_WITH_Squish" option is added to KWWidgets CMakeLists.txt, and by default it is OFF, so you have to turn it ON to add squish tests, given SQUISH_FOUND is true.<br />
<br />
<pre><br />
<br />
find_package(Squish)<br />
<br />
if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")<br />
kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})<br />
<br />
if(KWWidgets_TEST_WITH_Squish AND SQUISH_FOUND)<br />
set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")<br />
kwwidgets_add_squish_test_from_c_example(<br />
KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}") <br />
endif(KWWidgets_TEST_WITH_Squish AND SQUISH_FOUND)<br />
<br />
endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)<br />
<br />
</pre><br />
<br />
=Known Issues=<br />
==Squish==<br />
* Squish does not work with vtkKWMenuButton properly. The replay is sending too many mouse motion events, so that it will take a long time to playback "picking a menu entry". <br />
Squish is aware of this, and they will try to address this issue in the next release. <br />
In the meantime, the workaround is to manually remove most of the motionEvents (except the last one) from the squish test script.<br />
* Similar to the vtkKWMenuButton, there are two many mouse move events are recorded and played back when you do a mouse 'drag" on the render window.<br />
* The 'asynchronous way' of sending events while playing back a Squish test, ie, Squish will just send events it recorded without checking whether the sent events are processed or not.<br />
* The events from secondary dialogs are not recorded. For example, in WidgetsTourExample, select MultiColumnList from left panel, double click on the color button, which will launch a color-picker dialog, which is our own dialog with own own composite color-picker widget. Squish seems not be able to record any of the mouse event on this color-picker-dialog.<br />
* Squish does not record the file name from a file dialog, because it just records the mouse events without knowing the underneath widget. The same is true for the color-picker-dialog, Squish is not recording the color, instead, it just records the mouse events.<br />
<br />
==KWWidgets==<br />
* In order to validate Squish tests that process image data, KWWidgets Application needs to be able to easily grab a screenshot of the render window or render windows, so that baseline images can be created, and compared with the squish test results, as a validation of the tests</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14048KWWidgets/GUI Testing/Squish2008-11-07T23:03:08Z<p>Barre: /* Run the Test Case on the command-line */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's shorten the <tt>snooze</tt> command to 1 second, since it is now the last statement (or remove it altogether).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. Note the contents of the "Test Log" tab in the "Output" panel at the bottom:<br />
<pre><br />
START Fri Nov 7 17:11:24 2008 Start 'tst_Test1' (Passes: 0, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
END Fri Nov 7 17:11:25 2008 End 'tst_Test1'<br />
End of test 'tst_Test1' <br />
</pre><br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkExecuteTestCase.png|thumb|left|175px|Execute Test Case]]<br />
|}<br />
<br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity (in our case, the scale widget).<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *after* the <tt>invoke scrollTo</tt> command line, say on the <tt>snooze</tt> command line, for example (you can manually type such statement if you removed it previously, just like if you were editing Tcl code). Click in the gray column immediately to the left of the line, where its number is displayed, to insert a breakpoint.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu bar. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu bar, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu bar. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the specific command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it). You may also remove the <tt>snooze</tt> statement, or move it before <tt>test vp</tt>.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result. The Verification Point passed, yes!<br />
<pre><br />
START Fri Nov 7 17:33:16 2008 Start 'tst_Test1' (Passes: 1, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
PASS Fri Nov 7 17:33:17 2008 /home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:4: VP1:<br />
Object property comparison of :KWCallbacksExample.vtkKWWindow0.[...]vtkKWScale0.getvalue' passed<br />
'50.0' and '50.0' are equal (VP1) <br />
END Fri Nov 7 17:33:18 2008 End 'tst_Test1' <br />
End of test 'tst_Test1' <br />
</pre><br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}<br />
<br />
===Run the Test Case on the command-line===<br />
A whole test suite or individual test cases can be run from the command-line, thus allowing them to be part of nightly regression dashboards. <br />
<br />
* Make sure the [http://www.froglogic.com/download/book/rg-cmdline.html#rgc-squishrunner Squish Server] is running:<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ bin/squishserver &<br />
</pre><br />
* Pass the test suite to the [http://www.froglogic.com/download/book/rg-cmdline.html#rgc-squishrunner Squish Runner] executable:<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ bin/squishrunner --testsuite ~/tmp/kww_test/suite_kwcallbacksexample/<br />
2008-11-07T17:42:40 START Start 'suite_kwcallbacksexample' Test 'suite_kwcallbacksexample' started<br />
Debug: Client thread created, sock: 8<br />
Debug: Connection established from 127.0.0.1<br />
RUNNERID: 247170001<br />
AUTID: 247170002<br />
AUTHOST: 127.0.0.1<br />
AUTPORT: 4322<br />
RUNNERID: 247170001<br />
Debug: Client thread created, sock: 9<br />
Debug: Connection established from 127.0.0.1<br />
application registered 247170002<br />
Initializing AUT context ...<br />
2008-11-07T17:42:41 START_TEST_CASE Start 'tst_Test1' Test Case 'tst_Test1' started<br />
... done.<br />
2008-11-07T17:42:42 PASS /home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:4:<br />
VP1: Object property comparison of ':KWCallbacksExample.vtkKWWindow0.[...].vtkKWScale0.getvalue' passed<br />
'50.0' and '50.0' are equal (VP1)<br />
2008-11-07T17:42:43 END_TEST_CASE End 'tst_Test1' End of test case 'tst_Test1'<br />
2008-11-07T17:42:44 END End 'suite_kwcallbacksexample' End of test 'suite_kwcallbacksexample'<br />
*******************************************************<br />
Summary:<br />
Number of Test Cases: 1<br />
Number of Tests: 1<br />
Number of Errors: 0<br />
Number of Fatals: 0<br />
Number of Fails: 0<br />
Number of Passes: 1<br />
Number of Expected Fails: 0<br />
Number of Unexpected Passes: 0<br />
Number of Warnings: 0<br />
*******************************************************<br />
</pre><br />
* If VTK_DEBUG_LEAKS was turned ON, you may notice some debug leaks. This seems to happen when the AUT is terminated by closing the window directly (wrong signal maybe?). The test will still pass though. One workaround is to use select "File|Exit" in the AUT's menu bar, which will exercise the menu bar at the same time!<br />
<br />
==TODO==<br />
<br />
* Create a CMake module to find Squish on the system (paths to Squish server and Squish runner),<br />
* Create CMake macros that will start/stop the server (contact Brad Davis),<br />
* Create CMake macros that will run a test by invoking the runner and parsing its output,<br />
* Invoke the Squish module when configuring/building KWWidgets,<br />
* If Squish is found, add the above test to the KWCallbacks example, so that it is executed nightly. The contents of <tt>~/tmp/kww_test/suite_kwcallbacksexample/</tt> should probably be copied to KWWidgets/Examples/Cxx/Callbacks/Testing/Squish.<br />
* Create new suites to test every single KWWidgets core widget (in the WidgetsTour for example). It is likely that some will require adjustments from our side our Froglogic's side.<br />
* Create new suites for Slicer3.</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14047KWWidgets/GUI Testing/Squish2008-11-07T22:56:19Z<p>Barre: /* Run the Test Case on the command-line */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's shorten the <tt>snooze</tt> command to 1 second, since it is now the last statement (or remove it altogether).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. Note the contents of the "Test Log" tab in the "Output" panel at the bottom:<br />
<pre><br />
START Fri Nov 7 17:11:24 2008 Start 'tst_Test1' (Passes: 0, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
END Fri Nov 7 17:11:25 2008 End 'tst_Test1'<br />
End of test 'tst_Test1' <br />
</pre><br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkExecuteTestCase.png|thumb|left|175px|Execute Test Case]]<br />
|}<br />
<br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity (in our case, the scale widget).<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *after* the <tt>invoke scrollTo</tt> command line, say on the <tt>snooze</tt> command line, for example (you can manually type such statement if you removed it previously, just like if you were editing Tcl code). Click in the gray column immediately to the left of the line, where its number is displayed, to insert a breakpoint.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu bar. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu bar, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu bar. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the specific command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it). You may also remove the <tt>snooze</tt> statement, or move it before <tt>test vp</tt>.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result. The Verification Point passed, yes!<br />
<pre><br />
START Fri Nov 7 17:33:16 2008 Start 'tst_Test1' (Passes: 1, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
PASS Fri Nov 7 17:33:17 2008 /home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:4: VP1:<br />
Object property comparison of :KWCallbacksExample.vtkKWWindow0.[...]vtkKWScale0.getvalue' passed<br />
'50.0' and '50.0' are equal (VP1) <br />
END Fri Nov 7 17:33:18 2008 End 'tst_Test1' <br />
End of test 'tst_Test1' <br />
</pre><br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}<br />
<br />
===Run the Test Case on the command-line===<br />
A whole test suite or individual test cases can be run from the command-line, thus allowing them to be part of nightly regression dashboards. <br />
<br />
* Make sure the [http://www.froglogic.com/download/book/rg-cmdline.html#rgc-squishrunner Squish Server] is running:<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ bin/squishserver &<br />
</pre><br />
* Pass the test suite to the [http://www.froglogic.com/download/book/rg-cmdline.html#rgc-squishrunner Squish Runner] executable:<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ bin/squishrunner --testsuite ~/tmp/kww_test/suite_kwcallbacksexample/<br />
2008-11-07T17:42:40 START Start 'suite_kwcallbacksexample' Test 'suite_kwcallbacksexample' started<br />
Debug: Client thread created, sock: 8<br />
Debug: Connection established from 127.0.0.1<br />
RUNNERID: 247170001<br />
AUTID: 247170002<br />
AUTHOST: 127.0.0.1<br />
AUTPORT: 4322<br />
RUNNERID: 247170001<br />
Debug: Client thread created, sock: 9<br />
Debug: Connection established from 127.0.0.1<br />
application registered 247170002<br />
Initializing AUT context ...<br />
2008-11-07T17:42:41 START_TEST_CASE Start 'tst_Test1' Test Case 'tst_Test1' started<br />
... done.<br />
2008-11-07T17:42:42 PASS /home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:4:<br />
VP1: Object property comparison of ':KWCallbacksExample.vtkKWWindow0.[...].vtkKWScale0.getvalue' passed<br />
'50.0' and '50.0' are equal (VP1)<br />
2008-11-07T17:42:43 END_TEST_CASE End 'tst_Test1' End of test case 'tst_Test1'<br />
2008-11-07T17:42:44 END End 'suite_kwcallbacksexample' End of test 'suite_kwcallbacksexample'<br />
*******************************************************<br />
Summary:<br />
Number of Test Cases: 1<br />
Number of Tests: 1<br />
Number of Errors: 0<br />
Number of Fatals: 0<br />
Number of Fails: 0<br />
Number of Passes: 1<br />
Number of Expected Fails: 0<br />
Number of Unexpected Passes: 0<br />
Number of Warnings: 0<br />
*******************************************************<br />
</pre><br />
* If VTK_DEBUG_LEAKS was turned ON, you may notice some debug leaks. This seems to happen when the AUT is terminated by closing the window directly (wrong signal maybe?). The test will still pass though. One workaround is to use select "File|Exit" in the AUT's menu bar, which will exercise the menu bar at the same time!</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14046KWWidgets/GUI Testing/Squish2008-11-07T22:50:42Z<p>Barre: /* Validate the Test Case */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's shorten the <tt>snooze</tt> command to 1 second, since it is now the last statement (or remove it altogether).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. Note the contents of the "Test Log" tab in the "Output" panel at the bottom:<br />
<pre><br />
START Fri Nov 7 17:11:24 2008 Start 'tst_Test1' (Passes: 0, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
END Fri Nov 7 17:11:25 2008 End 'tst_Test1'<br />
End of test 'tst_Test1' <br />
</pre><br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkExecuteTestCase.png|thumb|left|175px|Execute Test Case]]<br />
|}<br />
<br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity (in our case, the scale widget).<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *after* the <tt>invoke scrollTo</tt> command line, say on the <tt>snooze</tt> command line, for example (you can manually type such statement if you removed it previously, just like if you were editing Tcl code). Click in the gray column immediately to the left of the line, where its number is displayed, to insert a breakpoint.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu bar. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu bar, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu bar. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the specific command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it). You may also remove the <tt>snooze</tt> statement, or move it before <tt>test vp</tt>.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result. The Verification Point passed, yes!<br />
<pre><br />
START Fri Nov 7 17:33:16 2008 Start 'tst_Test1' (Passes: 1, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
PASS Fri Nov 7 17:33:17 2008 /home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:4: VP1:<br />
Object property comparison of :KWCallbacksExample.vtkKWWindow0.[...]vtkKWScale0.getvalue' passed<br />
'50.0' and '50.0' are equal (VP1) <br />
END Fri Nov 7 17:33:18 2008 End 'tst_Test1' <br />
End of test 'tst_Test1' <br />
</pre><br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}<br />
<br />
===Run the Test Case on the command-line===<br />
A whole test suite or individual test cases can be run from the command-line, thus allowing them to be part of nightly regression dashboards. <br />
<br />
* Make sure the Squish Server is running:<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ bin/squishserver &<br />
</pre><br />
* Pass the test suite to the Squish Runner executable:<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ bin/squishrunner --testsuite ~/tmp/kww_test/suite_kwcallbacksexample/<br />
2008-11-07T17:42:40 START Start 'suite_kwcallbacksexample' Test 'suite_kwcallbacksexample' started<br />
Debug: Client thread created, sock: 8<br />
Debug: Connection established from 127.0.0.1<br />
RUNNERID: 247170001<br />
AUTID: 247170002<br />
AUTHOST: 127.0.0.1<br />
AUTPORT: 4322<br />
RUNNERID: 247170001<br />
Debug: Client thread created, sock: 9<br />
Debug: Connection established from 127.0.0.1<br />
application registered 247170002<br />
Initializing AUT context ...<br />
2008-11-07T17:42:41 START_TEST_CASE Start 'tst_Test1' Test Case 'tst_Test1' started<br />
... done.<br />
2008-11-07T17:42:42 PASS /home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:4:<br />
VP1: Object property comparison of ':KWCallbacksExample.vtkKWWindow0.[...].vtkKWScale0.getvalue' passed<br />
'50.0' and '50.0' are equal (VP1)<br />
2008-11-07T17:42:43 END_TEST_CASE End 'tst_Test1' End of test case 'tst_Test1'<br />
2008-11-07T17:42:44 END End 'suite_kwcallbacksexample' End of test 'suite_kwcallbacksexample'<br />
*******************************************************<br />
Summary:<br />
Number of Test Cases: 1<br />
Number of Tests: 1<br />
Number of Errors: 0<br />
Number of Fatals: 0<br />
Number of Fails: 0<br />
Number of Passes: 1<br />
Number of Expected Fails: 0<br />
Number of Unexpected Passes: 0<br />
Number of Warnings: 0<br />
*******************************************************<br />
</pre><br />
* If VTK_DEBUG_LEAKS was turned ON, you may notice some debug leaks. This seems to happen when the AUT is terminated by closing the window directly (wrong signal maybe?). The test will still pass though. One workaround is to use select "File|Exit" in the AUT's menu bar, which will exercise the menu bar at the same time!</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14045KWWidgets/GUI Testing/Squish2008-11-07T22:38:02Z<p>Barre: /* Validate the Test Case */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's shorten the <tt>snooze</tt> command to 1 second, since it is now the last statement (or remove it altogether).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. Note the contents of the "Test Log" tab in the "Output" panel at the bottom:<br />
<pre><br />
START Fri Nov 7 17:11:24 2008 Start 'tst_Test1' (Passes: 0, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
END Fri Nov 7 17:11:25 2008 End 'tst_Test1'<br />
End of test 'tst_Test1' <br />
</pre><br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkExecuteTestCase.png|thumb|left|175px|Execute Test Case]]<br />
|}<br />
<br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity (in our case, the scale widget).<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *after* the <tt>invoke scrollTo</tt> command line, say on the <tt>snooze</tt> command line, for example (you can manually type such statement if you removed it previously, just like if you were editing Tcl code). Click in the gray column immediately to the left of the line, where its number is displayed, to insert a breakpoint.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu bar. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu bar, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu bar. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the specific command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it). You may also remove the <tt>snooze</tt> statement, or move it before <tt>test vp</tt>.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result. The Verification Point passed, yes!<br />
<pre><br />
START Fri Nov 7 17:33:16 2008 Start 'tst_Test1' (Passes: 1, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
PASS Fri Nov 7 17:33:17 2008 /home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:4: VP1:<br />
Object property comparison of :KWCallbacksExample.vtkKWWindow0.[...]vtkKWScale0.getvalue' passed<br />
'50.0' and '50.0' are equal (VP1) <br />
END Fri Nov 7 17:33:18 2008 End 'tst_Test1' <br />
End of test 'tst_Test1' <br />
</pre><br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=File:KWWSquishTkVerificationPointPassed.png&diff=14044File:KWWSquishTkVerificationPointPassed.png2008-11-07T22:37:51Z<p>Barre: uploaded a new version of "Image:KWWSquishTkVerificationPointPassed.png"</p>
<hr />
<div>{{KWWidgets/Template/Categories}}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14043KWWidgets/GUI Testing/Squish2008-11-07T22:33:29Z<p>Barre: /* Insert a Verification Point */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's shorten the <tt>snooze</tt> command to 1 second, since it is now the last statement (or remove it altogether).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. Note the contents of the "Test Log" tab in the "Output" panel at the bottom:<br />
<pre><br />
START Fri Nov 7 17:11:24 2008 Start 'tst_Test1' (Passes: 0, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
END Fri Nov 7 17:11:25 2008 End 'tst_Test1'<br />
End of test 'tst_Test1' <br />
</pre><br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkExecuteTestCase.png|thumb|left|175px|Execute Test Case]]<br />
|}<br />
<br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity (in our case, the scale widget).<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *after* the <tt>invoke scrollTo</tt> command line, say on the <tt>snooze</tt> command line, for example (you can manually type such statement if you removed it previously, just like if you were editing Tcl code). Click in the gray column immediately to the left of the line, where its number is displayed, to insert a breakpoint.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu bar. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu bar, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu bar. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the specific command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it). You may also remove the <tt>snooze</tt> statement, or move it before <tt>test vp</tt>.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=File:KWWSquishTkVerificationPointInserted.png&diff=14042File:KWWSquishTkVerificationPointInserted.png2008-11-07T22:33:23Z<p>Barre: uploaded a new version of "Image:KWWSquishTkVerificationPointInserted.png"</p>
<hr />
<div>{{KWWidgets/Template/Categories}}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=File:KWWSquishTkChooseVerificationPointProperty.png&diff=14041File:KWWSquishTkChooseVerificationPointProperty.png2008-11-07T22:33:09Z<p>Barre: uploaded a new version of "Image:KWWSquishTkChooseVerificationPointProperty.png"</p>
<hr />
<div>{{KWWidgets/Template/Categories}}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=File:KWWSquishTkStoppedAtBreakpoint.png&diff=14040File:KWWSquishTkStoppedAtBreakpoint.png2008-11-07T22:32:40Z<p>Barre: uploaded a new version of "Image:KWWSquishTkStoppedAtBreakpoint.png"</p>
<hr />
<div>{{KWWidgets/Template/Categories}}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=File:KWWSquishTkInsertBreakpoint.png&diff=14039File:KWWSquishTkInsertBreakpoint.png2008-11-07T22:32:08Z<p>Barre: uploaded a new version of "Image:KWWSquishTkInsertBreakpoint.png"</p>
<hr />
<div>{{KWWidgets/Template/Categories}}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14038KWWidgets/GUI Testing/Squish2008-11-07T22:25:13Z<p>Barre: /* Insert a Verification Point */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's shorten the <tt>snooze</tt> command to 1 second, since it is now the last statement (or remove it altogether).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. Note the contents of the "Test Log" tab in the "Output" panel at the bottom:<br />
<pre><br />
START Fri Nov 7 17:11:24 2008 Start 'tst_Test1' (Passes: 0, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
END Fri Nov 7 17:11:25 2008 End 'tst_Test1'<br />
End of test 'tst_Test1' <br />
</pre><br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkExecuteTestCase.png|thumb|left|175px|Execute Test Case]]<br />
|}<br />
<br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity.<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *after* the <tt>invoke scrollTo</tt> command line, say on the <tt>snooze</tt> command line, for example (you can manually type such statement if you removed it previously, just like if you were editing Tcl code). Click in the gray column immediately to the left of the line, where its number is displayed, to insert a breakpoint.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14037KWWidgets/GUI Testing/Squish2008-11-07T22:23:51Z<p>Barre: /* Record the Test Case */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's shorten the <tt>snooze</tt> command to 1 second, since it is now the last statement (or remove it altogether).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. Note the contents of the "Test Log" tab in the "Output" panel at the bottom:<br />
<pre><br />
START Fri Nov 7 17:11:24 2008 Start 'tst_Test1' (Passes: 0, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
END Fri Nov 7 17:11:25 2008 End 'tst_Test1'<br />
End of test 'tst_Test1' <br />
</pre><br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkExecuteTestCase.png|thumb|left|175px|Execute Test Case]]<br />
|}<br />
<br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity.<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *after* the <tt>invoke scrollTo</tt> command line, say on the <tt>snooze</tt> command line for example. Click in the gray column immediately to the left of the line, where its number is displayed, to insert a breakpoint.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14036KWWidgets/GUI Testing/Squish2008-11-07T22:22:44Z<p>Barre: /* Insert a Verification Point */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's remove (or shorten) the <tt>snooze</tt> statement as well.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. Note the contents of the "Test Log" tab in the "Output" panel at the bottom:<br />
<pre><br />
START Fri Nov 7 17:11:24 2008 Start 'tst_Test1' (Passes: 0, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
END Fri Nov 7 17:11:25 2008 End 'tst_Test1'<br />
End of test 'tst_Test1' <br />
</pre><br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkExecuteTestCase.png|thumb|left|175px|Execute Test Case]]<br />
|}<br />
<br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity.<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *after* the <tt>invoke scrollTo</tt> command line, say on the <tt>snooze</tt> command line for example. Click in the gray column immediately to the left of the line, where its number is displayed, to insert a breakpoint.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14035KWWidgets/GUI Testing/Squish2008-11-07T22:15:34Z<p>Barre: /* Execute the Test Case */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's remove (or shorten) the <tt>snooze</tt> statement as well.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. Note the contents of the "Test Log" tab in the "Output" panel at the bottom:<br />
<pre><br />
START Fri Nov 7 17:11:24 2008 Start 'tst_Test1' (Passes: 0, Fails: 0, Fatals: 0, Errors: 0, Warnings: 0)<br />
END Fri Nov 7 17:11:25 2008 End 'tst_Test1'<br />
End of test 'tst_Test1' <br />
</pre><br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkExecuteTestCase.png|thumb|left|175px|Execute Test Case]]<br />
|}<br />
<br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity.<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *below* the <tt>snooze</tt> command line by clicking in the gray column immediately to the left of the line, where its number is displayed.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=File:KWWSquishTkExecuteTestCase.png&diff=14034File:KWWSquishTkExecuteTestCase.png2008-11-07T22:13:00Z<p>Barre: </p>
<hr />
<div>{{KWWidgets/Template/Categories}}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=File:KWWSquishTkExecuteTestCase.png&diff=14033File:KWWSquishTkExecuteTestCase.png2008-11-07T22:12:53Z<p>Barre: </p>
<hr />
<div></div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14032KWWidgets/GUI Testing/Squish2008-11-07T22:12:05Z<p>Barre: /* Record the Test Case */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly. Let's remove (or shorten) the <tt>snooze</tt> statement as well.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. <br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity.<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *below* the <tt>snooze</tt> command line by clicking in the gray column immediately to the left of the line, where its number is displayed.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14031KWWidgets/GUI Testing/Squish2008-11-07T22:09:41Z<p>Barre: /* Record the Test Case */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...", or select "Test Suite|Record..." in the main menu bar. Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, the script <tt>test,tcl</tt> has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen (here, our scale widget). The widget name itself is quite long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke</tt> is a Squish command that will act on a widget. Its first parameter, <tt>scrollTo</tt> , will scroll the scale slider to its new value, 50.0 (displayed as 50000). <br />
*# <tt>snooze 12.5</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that will close a specific window. It is not clear at this point what Squish is closing; one would have expected <tt>:KWCallbacksExample.vtkKWWindow0</tt>, but this might be the first widget that is being deleted in the whole application instead. In any cases, this line can be ignored and deleted; the application will still exit properly.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. <br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity.<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *below* the <tt>snooze</tt> command line by clicking in the gray column immediately to the left of the line, where its number is displayed.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=File:KWWSquishTkTestCaseRecorded.png&diff=14030File:KWWSquishTkTestCaseRecorded.png2008-11-07T22:09:29Z<p>Barre: uploaded a new version of "Image:KWWSquishTkTestCaseRecorded.png"</p>
<hr />
<div>{{KWWidgets/Template/Categories}}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14029KWWidgets/GUI Testing/Squish2008-11-07T21:59:53Z<p>Barre: /* Create a new Test Case */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." in the main menu bar or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...". Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, note that the script has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen. <br />
*# The widget name itself is often very long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke scrollTo</tt> is a Squish command that will act on a widget. In this case, this will scroll the scale slider to its new value, 50.0. <br />
*# <tt>snooze 1.2</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that should close the application window (depending on how you stopped recording).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. <br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity.<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *below* the <tt>snooze</tt> command line by clicking in the gray column immediately to the left of the line, where its number is displayed.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14028KWWidgets/GUI Testing/Squish2008-11-07T21:59:28Z<p>Barre: /* Create a new Test Case */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case", or "File|New Test Case..." or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory. Note that a test suite can store multiple test cases at a time (which would be executed one after the other).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...". Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, note that the script has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen. <br />
*# The widget name itself is often very long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke scrollTo</tt> is a Squish command that will act on a widget. In this case, this will scroll the scale slider to its new value, 50.0. <br />
*# <tt>snooze 1.2</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that should close the application window (depending on how you stopped recording).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. <br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity.<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *below* the <tt>snooze</tt> command line by clicking in the gray column immediately to the left of the line, where its number is displayed.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14027KWWidgets/GUI Testing/Squish2008-11-07T21:53:05Z<p>Barre: </p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|175px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|175px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|175px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|175px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|175px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case" or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|175px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...". Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, note that the script has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen. <br />
*# The widget name itself is often very long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke scrollTo</tt> is a Squish command that will act on a widget. In this case, this will scroll the scale slider to its new value, 50.0. <br />
*# <tt>snooze 1.2</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that should close the application window (depending on how you stopped recording).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|175px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|175px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. <br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity.<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *below* the <tt>snooze</tt> command line by clicking in the gray column immediately to the left of the line, where its number is displayed.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|175px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|175px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|175px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|175px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|175px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=KWWidgets/GUI_Testing/Squish&diff=14026KWWidgets/GUI Testing/Squish2008-11-07T21:51:41Z<p>Barre: /* Create a new Test Suite */</p>
<hr />
<div>==Squish==<br />
<br />
* [http://www.froglogic.com/pg?id=Home Squish Home]<br />
* [http://www.froglogic.com/pg?id=Products&category=squish&sub=editions&subsub=tk Squish for Tk], only for Unix<br />
* about €2500<br />
* Win32/Qt/Java/Web/'''Tk''', scripting in Tcl/Python/JavaScript/Perl, recorder, window inspector, breakpoints/verification<br />
<br />
==Prerequisites==<br />
<br />
* Qt3. Squish for Tk will not work with Qt4. Make sure you install all Qt3 development packages. On a Ubuntu OS, this (most likely) involve: <tt>libqt3-headers, libqt3-mt, libqt3-mt-dev, qt3-apps-dev, qt3-assistant, qt3-designer, qt3-dev-tools, qt3-linguist, qt3-qtconfig</tt>, etc.<br />
* [http://tcl.tk Tcl/Tk] 8.4 or 8.5<br />
* [http://kwwidgets.org KWWidgets]<br />
<br />
==Download==<br />
<br />
* Download a Squish for Tk [http://www.froglogic.com/pg?id=Products&category=squish&sub=evaluate evaluation license]<br />
<pre><br />
-rwxr--r-- 1 barre barre 6587889 2008-09-04 13:08 squish-3.4.1-eval-tk-src.tar.gz*<br />
-rwxr--r-- 1 barre barre 19 2008-09-04 13:08 squish-3-license*<br />
</pre><br />
<br />
==Installation==<br />
<br />
* Reference: [http://www.froglogic.com/download/book/install.html Squish Installation]<br />
* Unpack the archive<br />
<pre><br />
barre@tetsuo:~/build$ tar -xzf /home/barre/tmp/squish/squish-3.4.1-eval-tk-src.tar.gz <br />
</pre><br />
* Configure Squish<br />
<pre><br />
barre@tetsuo:~/build$ cd squish-3.4.1-eval-tk-src<br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./configure "--with-qtdir=/usr/share/qt3"<br />
"--with-tclconfig=/opt/tcltk8.5.2/lib/tclConfig.sh" "--with-tkconfig=/opt/tcltk8.5.2/lib/tkConfig.sh" <br />
</pre><br />
Note that the <tt>configure</tt> script may not find your Qt3 distribution correctly: use <tt>--with-qtdir</tt> to point to the appropriate directory. Use <tt>--with-tclconfig</tt> and <tt>--with-tkconfig</tt> to point to your own Tcl/Tk distribution, if any (here <tt>/opt/tcltk8.5.2</tt>)<br />
* Enter your license key (found in squish-3-license)<br />
<pre><br />
Configuring Squish. For license information please read the LICENSE file.<br />
By configuring and building Squish you are accepting the terms of this license.<br />
Enter license key: ***-*****-*****-***<br />
Checking for C++ compiler ......... g++<br />
Checking for g++'s version ......... 4<br />
[...]<br />
Done with configuring. Full log in config.log. Now type './build'.<br />
* Build<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./build<br />
</pre><br />
<br />
==Testing KWCallbacksExample==<br />
<br />
In this section, we will exercise KWWidgets' <tt>KWCallbacksExample</tt> example.<br />
<br />
* Build KWWidgets examples; set KWWidgets_BUILD_EXAMPLES to ON, make sure the <tt>./bin/KWCallbacksExample</tt> example has been built and is working properly. It should display a simple window with a single slider inside of it. Fancy. When the application exits, make sure you select the "Do not show this dialog anymore" checkbutton in the confirmation dialog.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkKWCallbacksExample.png|thumb|left|200px|KWCallbacksExample]]<br />
|}<br />
<br />
===Create a new Test Suite===<br />
* If you are new to Squish you may want to read: [http://www.froglogic.com/download/book/tgsc-concepts.html Squish Concepts] and [http://www.froglogic.com/download/book/tgs-firsttest-tk.html Creating the First Test]. The Squish for Tk documentation is located offline in your build directory at <tt>squish-3.4.1-eval-tk-src/doc/book/index.html</tt>, or online at [http://www.froglogic.com/download/book/ http://www.froglogic.com/download/book/]. <br />
* Start the Squish IDE<br />
<pre><br />
barre@tetsuo:~/build/squish-3.4.1-eval-tk-src$ ./bin/squish<br />
</pre><br />
* Create a new test<br />
** Select "[http://www.froglogic.com/download/book/tgs-firsttest-tk.html Create New Test Suite]" at the Welcome page, or "File|New Test Suite..." in the main menu bar.<br />
** Enter a Suite Name (say <tt>kwcallbacksexample</tt>). Select where the test suite and its files shall be saved (say <tt>~/tmp/kww_test/</tt>). Hit "Next".<br />
** Specify which toolkit the application is using. KWWidgets uses Tcl/Tk under the hood, therefore select the Tk radiobutton. Hit "Next". NOTE: this page will *only* show up if Squish was built to support *several* toolkits; if only one toolkit is available (hopefully, Tk), this page will not be displayed and the appropriate toolkit will be picked automatically. <br />
** Select Tcl as the scripting language. Hit "Next".<br />
** Select the Application Under Test (AUT): pick the the <tt>./bin/KWCallbacksExample</tt> application found in your KWWidgets build tree. Note that even though we are using Squish for Tk, we are actually exercising a KWWidgets *binary application*, not a Tcl/Tk *script*. Hit "Finish".<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestSuite.png|thumb|left|200px|Create New Test Suite]] || [[Image:KWWSquishTkCreateNewTestSuiteName.png|thumb|left|200px|Pick Test Suite Name]] || [[Image:KWWSquishTkCreateNewTestSuiteScriptingLanguage.png|thumb|left|200px|Pick Scripting Language]] ||<br />
[[Image:KWWSquishTkCreateNewTestSuiteAUT.png|thumb|left|200px|Select AUT]]<br />
|}<br />
<br />
===Create a new Test Case===<br />
* Select "Create New Test Case" or right-click on <tt>suite_kwcallbacksexample</tt> in the left tree and select "New Test Case...". Name it, say, <tt>Test1</tt>. This should create a <tt>tst_Test1</tt> case in the left tree and a <tt>test.tcl</tt> file in your test suite directory.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkCreateNewTestCase.png|thumb|left|200px|New Test Case]]<br />
|}<br />
<br />
===Record the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Record...". Accept the defaults and click "Record". This should launch <tt>KWCallbacksExample</tt>. Note the "Squish Control Bar" window displaying "Recording test case 'tst_Test1'".<br />
* Move the slider in the <tt>KWCallbacksExample</tt> window from 10.0 to a different value, say, 50.0. Note a new (and lengthy) entry in the "Squish Control Bar" window: <tt>"scrollTo KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0 50000"</tt>.<br />
* Exit "Recording" mode by closing or exiting the <tt>KWCallbacksExample</tt> window, or hitting the "End Recording" button in the "Squish Control Bar" window.<br />
* Back to the Squish IDE, note that the script has been updated to reflect your interaction with the AUT:<br />
*# <tt>waitForObject</tt> makes sure a widget is ready and has been mapped on-screen. <br />
*# The widget name itself is often very long as it reflects the hierarchy of parent-child widgets in a typical KWWidgets application. The name of each child in this chain is created at run-time by concatenating the name of the C++ class for that widget to a unique ID among its siblings. The last child in this specific example should be <tt>vtkKWScale0</tt>, which is the de-facto KWWidgets C++ class used to wrap the Tcl/Tk <tt>scale</tt> widget we just interacted with.<br />
*# <tt>invoke scrollTo</tt> is a Squish command that will act on a widget. In this case, this will scroll the scale slider to its new value, 50.0. <br />
*# <tt>snooze 1.2</tt>; snooze statements force the script to wait for N seconds. These calls are generated to ensure that the script always runs with the same time-delays as when it was recorded. They are added because in some cases an action may take some time to complete and the application may not be ready for the following action in time. <br />
*# <tt>invoke closeWindow</tt> is another Squish command that should close the application window (depending on how you stopped recording).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkRecordTestCase.png|thumb|left|200px|Record Test Case]] || [[Image:KWWSquishTkTestCaseRecorded.png|thumb|left|200px|Test Case Recorded]]<br />
|}<br />
<br />
===Execute the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, and bring you back to the Squish IDE. <br />
===Insert a Verification Point===<br />
Verification points (VP) can (and should) be added to make sure the application behaved correctly, i.e. that once executed by Squish, we end up in the state we expected. There are [http://www.froglogic.com/download/book/tgs-vp-tk.html#tgsvp-create-tk multiple ways] to add a VP; in this case, we will insert a breakpoint where the verification should take place, execute the testing script again until it "breaks", and insert the VP itself at this point; we will then inspect (spy on) the AUT's widgets to choose the widget we want to check for validity.<br />
* In the <tt>test.tcl</tt> window, insert a breakpoint on the line right *below* the <tt>snooze</tt> command line by clicking in the gray column immediately to the left of the line, where its number is displayed.<br />
* Execute the test case. Squish should execute the test, then halt it at the breakpoint; the line in which the debugger breaks is highlighted in yellow.<br />
* Start the Squish Spy on the currently running but halted AUT. This is achieved by choosing "Spy|Spy AUT" in the menu. <br />
** Below the editor two new views appear. To the left, it shows the object hierarchy and to the right the property tab. When the property tab is active, it shows the properties of the current object. Each object and property has a check box. By checking a property, a verification point for this property is created.<br />
** Rename the Verification Point (the entry above the object hierarchy), or leave it to <tt>VP1</tt>.<br />
** Select the <tt>vtkKWScale0</tt> widget in the object hierarchy:<br />
*** by opening the hierarchy tree until you reach <tt>vtkKWScale0</tt> (check the <tt>test.tcl</tt> script to find the proper parent-child path), or<br />
*** by selecting the scale widget *directly* in the AUT: invoke "Spy|Pick Object" in the menu, wait for Squish to switch to the AUT GUI then click directly on the scale widget. <br />
** Select the <tt>getvalue</tt> property checkbutton in the property tab: it should reflect the *current* value of the scale widget (here, 50.0). This is the property we want to check for the test to pass.<br />
** Insert the Verification Point in the <tt>test.tcl</tt> script by clicking on the checkmark icon in the toolbar next to the VP name. Note that the tree in the "Test Suite" panel on the left should reflect the new VP as well. <br />
* Stop the script by choosing "Test Suite|Stop" in the menu. You should now see a <tt>test vp</tt> command in the <tt>test.tcl</tt> window. This is the command that will make sure the conditions created for this verification point are met and that the test is passed.<br />
* Remove the breakpoint (by clicking on it).<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkInsertBreakpoint.png|thumb|left|200px|Insert Breakpoint]] || [[Image:KWWSquishTkStoppedAtBreakpoint.png|thumb|left|200px|Stopped At Breakpoint]] || [[Image:KWWSquishTkChooseVerificationPointProperty.png|thumb|left|200px|Choose Verification Point Property]] || [[Image:KWWSquishTkVerificationPointInserted.png|thumb|left|200px|Verification Point Inserted]]<br />
|}<br />
<br />
===Validate the Test Case===<br />
* Right-click on <tt>tst_Test1</tt> and select "Execute", or hit F5, or select "Test Suite|Execute" in the main menu bar. This should run the whole test, move the slider to 50.0 automatically, check the Verification Points and bring you back to the Squish IDE. <br />
* After the test run completed, you see the result of the verification point in the test log view at the bottom of the Squish IDE. This is a detailed report of the test run and would also contain occurring failures, errors, etc. If you click on a test log item, the Squish IDE highlights the script line which generated the test result.<br />
* The Verification Point should pass:<br />
<pre><br />
* PASS Thu Nov 6 14:58:41 2008/home/barre/tmp/kww_test/suite_kwcallbacksexample/tst_Test1/test.tcl:5: VP1: Object property<br />
comparison of ':KWCallbacksExample.vtkKWWindow0.vtkKWFrame3.[...].vtkKWMyWidget0.vtkKWScale0.getvalue' passed<br />
</pre><br />
* You can ignore the failure on <tt>invoke closeWindow</tt> for now :)<br />
* By implementing custom report generators it is possible to process test results in many different ways, for example to store them in a data base, or to output them as HTML files. The default report generator simply prints the results to stdout, or when being used in the Squish IDE they are displayed in the test log view. You can also save the test results in the Squish IDE as XML by right clicking on the test results and choosing Save Results As.<br />
{| class="wikitable" style="margin: 1em auto 1em auto"<br />
|-<br />
| [[Image:KWWSquishTkVerificationPointPassed.png|thumb|left|200px|Verification Point Passed]]<br />
|}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=File:KWWSquishTkCreateNewTestSuiteAUT.png&diff=14025File:KWWSquishTkCreateNewTestSuiteAUT.png2008-11-07T21:49:42Z<p>Barre: </p>
<hr />
<div>{{KWWidgets/Template/Categories}}</div>Barrehttps://public.kitware.com/Wiki/index.php?title=File:KWWSquishTkCreateNewTestSuiteAUT.png&diff=14024File:KWWSquishTkCreateNewTestSuiteAUT.png2008-11-07T21:49:37Z<p>Barre: </p>
<hr />
<div></div>Barre