# This is a list of test XML files.
# When you add an entry **be sure to describe the actions a user
# must perform to reproduce the test** as it can be painful to
# read the XML when a test needs to be re-recorded.
# **It is also useful to tersely describe what functionality is
# being tested if not clear from the procedural description and
# test name.**
set(xml_tests_with_baselines
  # Just open an SMTK file and ensure it renders properly.
  # Also tests default color-by mode in theory.
  OpenModelFile
  # Open 2 model files; set 1 to color-by-entity, 1 to color-by-volume.
  # Zoom to second model so colors can be discerned.
  PerResourceColorByMode
  # Open an SMTK model, block select some entities, then change the selection filters
  # so only the edges remain selected.
  SelectionFilterJustEdges
  # Open an SMTK model then select 1 model face in the tree view.
  SelectModelEntityInTree
  # Open an SMTK model. Then change the filename and ensure the newly-
  # specified model is loaded. Select a face in the tree view to ensure
  # that both the render and tree views are updated.
  SwitchModelFiles
)

set(xml_tests_no_baselines
)

set(_image_fail_regex "(\n|^)ERROR: The following event FAILED")

set(test_images ${aeva_SOURCE_DIR}/data/baselines/aeva)
if (aeva_data_dir AND aeva_test_data_dir)
  foreach(test ${xml_tests_with_baselines})
    #get_image_threshold_arg(THRESHOLD_CMD ${test})
    set(tname "${test}")
    add_test(
      NAME ${tname}
      COMMAND aeva
        -dr
        --data-directory=${aeva_test_data_dir}
        --test-script=${CMAKE_CURRENT_SOURCE_DIR}/${test}.xml
        --test-directory=${aeva_test_dir}
        --test-baseline=${test_images}/${test}.png
        --exit
    )
    set(tlabels aeva aeva ${${test}-labels})
    set_tests_properties(${tname}
      PROPERTIES
        LABELS "${tlabels}"
    )
    # if a plugins file was created, use it
    if (${plugins_file})
      set_tests_properties(${tname}
        PROPERTIES
          ENVIRONMENT "PV_PLUGIN_CONFIG_FILE=${plugins_file}"
      )
    endif()
  endforeach()
  foreach(test ${xml_tests_no_baselines})
    #get_image_threshold_arg(THRESHOLD_CMD ${test})
    set(tname "${test}")
    add_test(
      NAME ${tname}
      COMMAND aeva
        -dr
        --data-directory=${cmb_test_data_dir}
        --test-script=${CMAKE_CURRENT_SOURCE_DIR}/${test}.xml
        --test-directory=${cmb_test_dir}
        --exit
    )
    set(tlabels aeva ${${test}-labels})
    set(plug_cfg "")
    # if a plugins file was created, use it
    if (${plugins_file})
      set(plug_cfg "PV_PLUGIN_CONFIG_FILE=${plugins_file}")
    endif()
    set_tests_properties(${tname}
      PROPERTIES
        LABELS "${tlabels}"
        FAIL_REGULAR_EXPRESSION "${_image_fail_regex}"
        ENVIRONMENT
          "PARAVIEW_TEST_BASELINE_DIR=${test_images} ${plug_cfg}"
    )
  endforeach()
endif()
