Difference between revisions of "KWWidgets/GUI Testing/Squish/SquishForSlicer3"

From KitwarePublic
Jump to navigationJump to search
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=Goals=
=Goals=


  VERY IMPORTANT: Squish must be built with the same tcl/tk libraries that Slicer3 is using, otherwise, Squish won't launch Slicer3.  
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.
  Also, if you have not read [[KWWidgets/GUI_Testing/Squish/SquishForKWWidgets| Squish with CMake and KWWidgets]], please do so before you try Slicer3 with Squish.


* Invoke the Squish module when configuring/building Slicer3.
{{: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.}}
  NOTE: This is not commited to Slicer3 yet, but can be used as a starting point if you want to experiment Squish with Slicer3.
 
The code presented in the next few sections has not been commited to Slicer3 yet, but can be used as a starting point.


=Files=
=Files=
Modify this file under Slicer3/CMake directory:
Modify the following files in the Slicer3 source directory:


*SlicerMacros.cmake: define Slicer3_ADD_Squish_TEST macro
*<tt>Slicer3/CMake/SlicerMacros.cmake</tt>: define the Slicer3_ADD_Squish_TEST macro
<pre>
<pre>
# Slicer3_ADD_Squish_TEST
# Slicer3_ADD_Squish_TEST
Line 41: Line 41:
</pre>
</pre>


=Use=
=Usage=
==Create Squish test suites==
==Create Squish test suites==
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:
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>:


<pre>
<pre>
Line 54: Line 54:
</pre>
</pre>


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".
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>.


[[Image:SlicerSquishSettings.png| Squish settings for launch Slicer3]]
[[Image:SlicerSquishSettings.png| Squish settings for launch Slicer3]]


==Add Squish tests to CTest lists==
==Add Squish tests to CTest lists==
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 to cover all the data-loading scenarios with different datasets, and the following CMake script should be modified accordingly.
 
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.


<pre>
<pre>
include("${KWWidgets_CMAKE_DIR}/FindSquish.cmake")
include("${KWWidgets_CMAKE_DIR}/FindSquish.cmake")



Latest revision as of 23:12, 2 January 2009

Goals

The goal here is to add Squish tests to Slicer3, the same was some were added to KWWidgets. If you have not checked Squish with KWWidgets or GUI Testing with Squish, please do so before you adding Squish tests to Slicer3.


KwGridWarningIcon.png Warning: Squish *must* be built with the same Tcl/Tk libraries that Slicer3 is using. Squish won't launch Slicer3 properly otherwise.

The code presented in the next few sections has not been commited to Slicer3 yet, but can be used as a starting point.

Files

Modify the following files in the Slicer3 source directory:

  • Slicer3/CMake/SlicerMacros.cmake: define the Slicer3_ADD_Squish_TEST macro
# Slicer3_ADD_Squish_TEST

macro(slicer3_add_squish_test
    test_name
    squish_AUT_name
    squish_test_case_path
    slicerScriptFile
    )

  # Try to find the full path to the test executable

  include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")
  kwwidgets_get_full_path_to_executable(${squish_AUT_name} exe_path)
 
  KWWidgets_ADD_Squish_TEST(
    "${test_name}"
    "${exe_path}"
    "${squish_test_case_path}"
    "${slicerENV}"
    "${slicerPathsScript}"
    "--test-mode --script ${slicerScriptFile}"
    )

  SET_TESTS_PROPERTIES(${test_name}
    PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED;ERROR;FATAL")

endmacro(slicer3_add_squish_test)

Usage

Create Squish test suites

Create a new Squish test suite under Slicer3/Applications/GUI/Testing/Squish with the Squish IDE to instrument the bin/Slicer3-real 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, LoadSimpleScene.tcl:


update
$::slicer3::MRMLScene SetURL $::Slicer3_HOME/share/MRML/Testing/volScene.mrml
$::slicer3::MRMLScene Connect
update

Now copy this LoadSimpleScene.tcl file to Slicer3/Applications/GUI/Testing, go to "Test Suite -> Settings..." in the Squish IDE and modify the arguments of the AUT as follow: --test-mode --script ../../Slicer3/Applications/GUI/Testing/LoadSimpleScene.tcl. This will instruct Slicer3 to automatically run the script and open the corresponding scene when launched from Squish. Note: the --test-mode option is used to NoSplash=true and RegistryLevel=0.

Squish settings for launch Slicer3

Add Squish tests to CTest lists

Add the following code to the CMakeLists.txt file under Slicer3/Applications/GUI/Testing so that Squish test suites stored in the same directory are automatically detected and the corresponding CMake tests added. The LoadSimpleScene.tcl 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.

include("${KWWidgets_CMAKE_DIR}/FindSquish.cmake")

if(SQUISH_FOUND)

  include("${Slicer3_CMAKE_DIR}/Slicer3Macros.cmake")

  file(GLOB SquishTestSuites ${Slicer3_SOURCE_DIR}/Applications/GUI/Testing/Squish/* suite_*)

  foreach(SquishTestSuite ${SquishTestSuites})
    if(IS_DIRECTORY ${SquishTestSuite})

      string(REGEX MATCH ".+suite_(.*)" tmp_suite_name ${SquishTestSuite})
      set(squish_suite_name ${CMAKE_MATCH_1})  

      file(GLOB SquishTests ${SquishTestSuite}/* tst_*)
      foreach(SquishTest ${SquishTests})
        if(IS_DIRECTORY ${SquishTest})
        
          string(REGEX MATCH ".+(tst_(.*))" tmp_test_name ${SquishTest})
          set(squish_test_name "${CMAKE_MATCH_1}")  
          set(slicer_squish_test_name "Squish_${squish_suite_name}_${CMAKE_MATCH_2}")   

# message(STATUS "squish_test_name='${squish_test_name}'")
# message(STATUS "slicer_squish_test_name='${slicer_squish_test_name}'")
          
          slicer3_add_squish_test(
           ${slicer_squish_test_name} "${EXECUTABLE_OUTPUT_PATH}/Slicer3-real" 
           "${SquishTestSuite}/${squish_test_name}"
           "${Slicer3_SOURCE_DIR}/Applications/GUI/Testing/LoadSimpleScene.tcl")    

        endif(IS_DIRECTORY ${SquishTest})
      endforeach(SquishTest)
    endif(IS_DIRECTORY ${SquishTestSuite})
  endforeach(SquishTestSuite)

endif(SQUISH_FOUND)

Known Issues

Squish

Slicer3

  • Screenshot to create baseline images and validate the Squish image-data-processing tests.