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

From KitwarePublic
Jump to navigationJump to search
Line 8: Line 8:


=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

Revision as of 22:14, 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)

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.