KWWidgets/GUI Testing/Squish/SquishForSlicer3: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
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=

Revision as of 22:13, 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 this file under Slicer3/CMake directory:

  • SlicerMacros.cmake: define 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)

Use

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:


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

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

Squish settings for launch Slicer3

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 (similar to the LoadSimpleScene.tcl) to cover all the data-loading scenarios with different datasets, and 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.