diff --git a/testcases/integration-tests.sh b/testcases/integration-tests.sh index 11f7c14b..94d4c274 100755 --- a/testcases/integration-tests.sh +++ b/testcases/integration-tests.sh @@ -1,274 +1,274 @@ #!/bin/bash # Copyright 2018 Johannes Zarl-Zierl # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. export LC_ALL=C myname=`basename "$0"` mydir=`dirname "$0"` -DEPS="kphotoalbum convert exiftool kdialog" +DEPS="kphotoalbum convert exiv2 kdialog" # basic kphotoalbumrc options to make testing less annoying (i.e. prevent some pop-ups): BASE_RC="\n[Thumbnails]\ndisplayCategories=true\n[Notification Messages]\nimage_config_typein_show_help=false\n[TipOfDay]\nRunOnStart=false" TEMPDIR= KEEP_TEMPDIR=0 declare -A _checks _context result_ok=0 result_failed=1 result_err_crash=2 result_err_setup=3 declare -A LOG_LEVELS LOG_LEVELS[debug]=0 LOG_LEVELS[info]=1 LOG_LEVELS[notice]=2 LOG_LEVELS[warning]=3 LOG_LEVELS[err]=4 # default log level: LOG_LEVEL=2 ### functions cleanup() { if [[ "$KEEP_TEMPDIR" == 1 ]] then log info "NOT removing temporary directory '$TEMPDIR'." else if [[ -d "$TEMPDIR" ]] then log debug "Removing '$TEMPDIR'..." rm -rf "$TEMPDIR" fi fi } log() { lvl="$1" shift if [ "${LOG_LEVELS[$lvl]}" -ge "$LOG_LEVEL" ] then echo "$myname[$lvl]: $*" >&2 fi } print_help() { echo "Usage: $myname --check ] [PARAMETERS...] [--all|CHECKS...]" >&2 echo " $myname --help" >&2 echo " $myname --list" >&2 echo " $myname --print" >&2 echo "" >&2 echo "List or run integration tests for KPhotoAlbum." >&2 echo "This script allows guided integration tests that present the user with concrete things to check." >&2 echo "" >&2 echo "Modes:" >&2 echo "-c|--check Run the specified checks." >&2 echo "-l|--list List available checks." >&2 echo "-p|--print Print available checks with description." >&2 echo "" >&2 echo "Parameters:" >&2 echo "--all Run all tests (only valid for --check)." >&2 echo "--keep-tempdir Do not remove temporary files." >&2 echo "--log-level debug|info|notice|warning|err Set log level (default: notice)." >&2 echo "--tempdir DIR Use DIR for temporary files (implies --keep-tempdir)." >&2 echo "" >&2 } setup_check() # setup_check DIR # sets up a demo db in DIR/db { local check_dir="$1" if ! mkdir "$check_dir" "$check_dir/db" "$check_dir/QtProject" then log err "Could not create check directories for prefix '$check_dir'!" return 1 fi # set logging rules cat > "$check_dir/QtProject/qtlogging.ini" <$check_name${_context[$check_name]}" export XDG_CONFIG_HOME="$check_dir" prepare_$check_name "$check_dir" call_$check_name "$check_dir" > "$check_dir/log" 2>&1 || return $result_err_crash if kdialog --yesno "

$check_name — Did KPhotoAlbum pass the test?

As a reminder what you should check:


${_context[$check_name]}
" then return $result_ok else return $result_failed fi } ### MAIN for dep in $DEPS do if ! which "$dep" >/dev/null 2>&1 then log err "Could not find required dependency '$dep'!" exit 2 fi done version=`kphotoalbum --version 2>&1` log info "Using $version (`which kphotoalbum`)..." TEMP=`getopt -o clhp --long "all,check,help,keep-tempdir,list,log-level:,print,tempdir:" -n "$myname" -- "$@"` if [ $? != 0 ] ; then log err "Terminating..." ; exit 1 ; fi # Note the quotes around `$TEMP': they are essential! eval set -- "$TEMP" MODE=check while true ; do case "$1" in -h|--help) print_help ; exit ;; -l|--list) MODE="list" ; shift ;; -c|--check) MODE="check" ; shift ;; -p|--print) MODE="print" ; shift ;; --keep-tempdir) KEEP_TEMPDIR=1 ; shift ;; --tempdir) TEMPDIR="$2" ; KEEP_TEMPDIR=1 ; shift 2 ;; --all) RUN_ALL=1 ; shift ;; --log-level) LOG_LEVEL="${LOG_LEVELS[$2]}" ; shift 2 ;; --) shift ; break ;; *) echo "Internal error!" ; exit 1 ;; esac done if [ -z "$TEMPDIR" ] then TEMPDIR=`mktemp -d --tmpdir kphotoalbum-tests-XXXXXX` fi trap cleanup EXIT # read test files for f in "$mydir/integration-tests/"*.sh do . "$f" done case $MODE in list|print) do_$MODE ;; check) if [[ "$RUN_ALL" == 1 ]] then eval set -- "${!_checks[@]}" fi do_checks "$@" ;; esac diff --git a/testcases/integration-tests/check_stripexif.sh b/testcases/integration-tests/check_stripexif.sh new file mode 100644 index 00000000..b3e4c720 --- /dev/null +++ b/testcases/integration-tests/check_stripexif.sh @@ -0,0 +1,40 @@ +_checks[check_stripexif]="Feature: Strip Camera Generated Default Descriptions" +_context[check_stripexif]="

What this test will do:

+ +

What you have to do:

+
    +
  1. Go to Untagged Images and check that two new images show up.
  2. +
  3. Check if the image with text DEFAULT_DESCRIPTION has an empty description field.
  4. +
  5. Check if the image with text NO DEFAULT_DESCRIPTION has the description \"NO DEFAULT DESCRIPTION\".
  6. +
" + +check_stripexif_exifhelper() +# generate an image with exiv description +{ + convert -size 700x460 label:"$1" "$check_dir/db/$1.jpg" + exiv2 -M"set Exif.Image.ImageDescription $1" "$check_dir/db/$1.jpg" +} + +prepare_check_stripexif() +{ + local check_dir="$1" + # useEXIFComments is set by default + # stripEXIFComments contains several descriptions, line by line + # make sure there's more than one line so that escaping is also checked: + echo -e "[General]\nstripEXIFComments=true\ncommentsToStrip=SOME DEFAULT-,-DEFAULT_DESCRIPTION-,-OTHER-,-\n$BASE_RC" > "$check_dir/kphotoalbumrc" + check_stripexif_exifhelper "DEFAULT_DESCRIPTION" + check_stripexif_exifhelper "NO DEFAULT_DESCRIPTION" +} +call_check_stripexif() +{ + local check_dir="$1" + kphotoalbum --db "$check_dir/db/index.xml" --search +} +check_stripexif() +{ + generic_check check_stripexif +}