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

From KitwarePublic
Jump to navigationJump to search
No edit summary
Line 62: Line 62:


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



Revision as of 15:21, 2 January 2009

Goals

 VERY IMPORTANT: Squish must be built with the same tcl/tk libraries that Slicer3 is using, otherwise, Squish won't launch Slicer3. 
 Also, if you have not read  Squish with CMake and KWWidgets, please do so before you try Slicer3 with Squish.
  • Invoke the Squish module when configuring/building Slicer3.
 NOTE: This is not commited to Slicer3 yet, but can be used as a starting point if you want to experiment Squish with Slicer3.

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,


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.