# cmake <http://www.cmake.org> test file for python-gammu
# Copyright (c) 2007-2009 Michal Cihar
# vim: expandtab sw=4 ts=4 sts=4 ft=cmake:

include(SetupDummyPhone)

# Scripts need to be in same directory as built gammu module!
configure_file("examples/backup-convertor.py" "${CMAKE_CURRENT_BINARY_DIR}/test-backup-convertor.py" COPY_ONLY)
file(GLOB VFORMATS "${CMAKE_CURRENT_SOURCE_DIR}/../tests/vcards/*.vcf"
    "${CMAKE_CURRENT_SOURCE_DIR}/../tests/vcal/*.ics"
    "${CMAKE_CURRENT_SOURCE_DIR}/../tests/vcal/*.vcs")
foreach(VCF ${VFORMATS})
    get_filename_component(TESTNAME "${VCF}" NAME_WE)
    get_filename_component(TYPE "${VCF}" EXT)
    add_test("py-backup-${TESTNAME}" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-backup-convertor.py" "${VCF}" "${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}.backup")
    add_test("py-backup-${TESTNAME}-backup" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-backup-convertor.py" "${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}.backup" "${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}-backup.backup")
    if (${TYPE} STREQUAL .vcf)
        foreach (EXT lmb vcf ldif)
            add_test("py-backup-${TESTNAME}-${EXT}" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-backup-convertor.py" "${VCF}" "${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}.${EXT}")
            add_test("py-backup-${TESTNAME}-${EXT}-backup" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-backup-convertor.py" "${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}.${EXT}" "${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}-${EXT}.backup")
        endforeach (EXT)
    else (${TYPE} STREQUAL .vcf)
        foreach (EXT vcs ics)
            add_test("py-backup-${TESTNAME}-${EXT}" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-backup-convertor.py" "${VCF}" "${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}.${EXT}")
            add_test("py-backup-${TESTNAME}-${EXT}-backup" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-backup-convertor.py" "${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}.${EXT}" "${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}-${EXT}.backup")
        endforeach (EXT)
    endif (${TYPE} STREQUAL .vcf)
endforeach(VCF)

configure_file("examples/sms-encode-decode.py" "${CMAKE_CURRENT_BINARY_DIR}/test-sms-encode-decode.py" COPY_ONLY)
add_test("py-sms-encode-decode" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-sms-encode-decode.py")
set_tests_properties("py-sms-encode-decode" PROPERTIES PASS_REGULAR_EXPRESSION "Comparsion: True")

configure_file("examples/sms-link.py" "${CMAKE_CURRENT_BINARY_DIR}/test-sms-link.py" COPY_ONLY)
add_test("py-sms-link" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-sms-link.py")
set_tests_properties("py-sms-link" PROPERTIES PASS_REGULAR_EXPRESSION "Comparsion: True")

configure_file("examples/listfilesystem.py" "${CMAKE_CURRENT_BINARY_DIR}/test-listfilesystem.py" COPY_ONLY)
add_test("py-listfilesystem" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-listfilesystem.py" -c "${CMAKE_CURRENT_BINARY_DIR}/.gammurc")
set_tests_properties("py-listfilesystem" PROPERTIES PASS_REGULAR_EXPRESSION "     .    .-- Folder \"dir1-2-3\"")
add_test("py-listfilesystem-f" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-listfilesystem.py" -c "${CMAKE_CURRENT_BINARY_DIR}/.gammurc" -f)
set_tests_properties("py-listfilesystem-f" PROPERTIES PASS_REGULAR_EXPRESSION "dir2/dir2-5/file4")

configure_file("examples/data/cgi.jpg" "${CMAKE_CURRENT_BINARY_DIR}/cgi.jpg" COPY_ONLY)
configure_file("examples/filesystem-test.py" "${CMAKE_CURRENT_BINARY_DIR}/test-filesystem-test.py" COPY_ONLY)
add_test("py-filesystem-test" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-filesystem-test.py" -c "${CMAKE_CURRENT_BINARY_DIR}/.gammurc" -f testdir -t "${CMAKE_CURRENT_BINARY_DIR}/cgi.jpg")

configure_file("examples/dummy-phone.py" "${CMAKE_CURRENT_BINARY_DIR}/test-dummy-phone.py" COPY_ONLY)
add_test("py-dummy-phone" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-dummy-phone.py" "${CMAKE_CURRENT_BINARY_DIR}/.gammurc")
#set_tests_properties("py-dummy-phone" PROPERTIES PASS_REGULAR_EXPRESSION "Comparsion: True")

configure_file("examples/vcs.py" "${CMAKE_CURRENT_BINARY_DIR}/test-vcs.py" COPY_ONLY)
add_test("py-vcs" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-vcs.py" "${CMAKE_CURRENT_BINARY_DIR}/.gammurc")

configure_file("examples/worker.py" "${CMAKE_CURRENT_BINARY_DIR}/test-worker.py" COPY_ONLY)
add_test("py-worker" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-worker.py" "${CMAKE_CURRENT_BINARY_DIR}/.gammurc")

if (LIBDBI_FOUND AND SQLITE_BIN)
    configure_file("examples/smsd-testing.py" "${CMAKE_CURRENT_BINARY_DIR}/test-smsd-testing.py" @ONLY)
    add_test("py-smsd-testing" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/test-smsd-testing.py")
endif (LIBDBI_FOUND AND SQLITE_BIN)
