1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
|
#!/bin/sh -e
# --------
# File: ssft_tests.sh
# Description: Script to test the ssft funtions
# Author: Sergio Talens-Oliag <sto@debian.org>
# Copyright: (c) 2005, 2006 Sergio Talens-Oliag <sto@debian.org>
# SVN Id: $Id: ssft-test.sh 86 2009-07-13 22:48:13Z sto $
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
# --------
if [ -f ../src/ssft.sh ]; then
. ../src/ssft.sh || exit 1
else
. ssft.sh || exit 1
fi
TEXTDOMAIN="ssft"
ssft_sh_frontend_tests() {
progname="$0"
RES="`gettext "Result"`"
CANCEL="`gettext "The user CANCELLED the operation"`"
if [ $# -lt 1 ]; then
MSG=$(eval_gettext "Usage: \$progname FRONTENDS
Where FRONTENDS is one or more of zenity, kdialog, dialog, text or noninteractive")
echo "$MSG"
return 0
fi
FRONTENDS=""
for f in $@; do
# Remove duplicates
for af in $FRONTENDS; do
if [ "$af" = "$f" ]; then
f=""; break;
fi
done
# Add to FRONTENDS
case $f in
zenity|kdialog|dialog|text|noninteractive)
FRONTENDS="$FRONTENDS $f"
;;
esac
done
for frontend in $FRONTENDS; do
export SSFT_FRONTEND="$frontend"
MSG=$(eval_gettext "TESTING FRONTEND '\$frontend'")
echo "$MSG"
echo ""
echo "-------------------------------"
echo "ssft_display_message"
echo "-------------------------------"
echo ""
TIT="`gettext "Display message test"`"
MSG="`gettext "This is a simple message
It is shown using ssft_display_message"`"
ssft_display_message "$TIT" "$MSG"
echo "-----------------------------"
echo "ssft_display_error"
echo "-----------------------------"
echo ""
TIT="`gettext "Display error test"`"
MSG="`gettext "This is an error message
It is shown using ssft_display_error"`"
ssft_display_error "$TIT" "$MSG"
echo "------------------------------"
echo "ssft_file_selection"
echo "------------------------------"
echo ""
TIT="`gettext "Select a file"`"
MSG="`gettext "Choose a file, please!"`"
if ssft_file_selection "$TIT" "$MSG"; then
MSG=$(eval_gettext "The user said: '\$SSFT_RESULT'")
else
MSG="$CANCEL"
fi
ssft_display_message "$RES" "$MSG"
echo "------------------------------"
echo "ssft_directory_selection"
echo "------------------------------"
echo ""
TIT="`gettext "Select a directory"`"
MSG="`gettext "Choose a directory, please!"`"
if ssft_directory_selection "$TIT" "$MSG"; then
MSG=$(eval_gettext "The user said: '\$SSFT_RESULT'")
else
MSG="$CANCEL"
fi
ssft_display_message "$RES" "$MSG"
echo "----------------------------"
echo "ssft_progress_bar"
echo "----------------------------"
echo ""
TIT="`gettext "Sample PROGRESSBAR"`"
if ! (
for x in `seq 0 20 100`; do \
MSG=$(eval_gettext "We are at \$x %"); \
echo "$x"; echo "$MSG"; sleep 1; \
done | ssft_progress_bar "$TIT" ); then
ssft_display_message "$RES" "$CANCEL"
fi
echo "---------------------------"
echo "ssft_read_string"
echo "---------------------------"
echo ""
TIT="`gettext "Read STRING"`"
MSG="`gettext "Gimme a string"`"
if ssft_read_string "$TIT" "$MSG"; then
MSG=$(eval_gettext "The user said: '\$SSFT_RESULT'")
else
MSG="$CANCEL"
fi
ssft_display_message "$RES" "$MSG"
echo "---------------------------"
echo "ssft_read_string (defaults)"
echo "---------------------------"
echo ""
SSFT_DEFAULT="default string"
TIT="`gettext "Read STRING"`"
MSG="`gettext "Gimme a string"`"
if ssft_read_string "$TIT" "$MSG"; then
MSG=$(eval_gettext "The user said: '\$SSFT_RESULT'")
else
MSG="$CANCEL"
fi
ssft_display_message "$RES" "$MSG"
echo "-----------------------------"
echo "ssft_read_password"
echo "-----------------------------"
echo ""
TIT="`gettext "Read PASSWD"`"
MSG="`gettext "Gimme a password"`"
if ssft_read_password "$TIT" "$MSG"; then
MSG=$(eval_gettext "The user said: '\$SSFT_RESULT'");
else
MSG="$CANCEL"
fi
ssft_display_message "$RES" "$MSG"
echo "-------------------------------"
echo "ssft_select_multiple"
echo "-------------------------------"
echo ""
TIT="`gettext "Select MULTIPLE"`"
MSG="`gettext "Select ONE or MORE Distributions"`"
OPTS="Debian LliureX Mandrake RedHat Slackware SuSE Ubuntu"
if ssft_select_multiple "$TIT" "$MSG" $OPTS; then
MSG=$(eval_gettext "The user selected: '\$SSFT_RESULT'")
else
MSG="$CANCEL"
fi
ssft_display_message "$RES" "$MSG"
echo "-------------------------------"
echo "ssft_select_multiple (defaults)"
echo "-------------------------------"
echo ""
SSFT_DEFAULT="Debian
LliureX
Ubuntu"
TIT="`gettext "Select MULTIPLE"`"
MSG="`gettext "Select ONE or MORE Distributions"`"
OPTS="Debian LliureX Mandrake RedHat Slackware SuSE Ubuntu"
if ssft_select_multiple "$TIT" "$MSG" $OPTS; then
MSG=$(eval_gettext "The user selected: '\$SSFT_RESULT'")
else
MSG="$CANCEL"
fi
ssft_display_message "$RES" "$MSG"
echo "-----------------------------"
echo "ssft_select_single"
echo "-----------------------------"
echo ""
TIT="`gettext "Select SINGLE"`"
MSG="`gettext "Select ONE Distribution"`"
OPTS="Debian LliureX Mandrake RedHat Slackware SuSE"
if ssft_select_single "$TIT" "$MSG" $OPTS; then
MSG=$(eval_gettext "The user selected: '\$SSFT_RESULT'")
else
MSG="$CANCEL"
fi
ssft_display_message "$RES" "$MSG"
echo "-----------------------------"
echo "ssft_select_single (defaults)"
echo "-----------------------------"
echo ""
SSFT_DEFAULT="Slackware"
TIT="`gettext "Select SINGLE"`"
MSG="`gettext "Select ONE Distribution"`"
OPTS="Debian LliureX Mandrake RedHat Slackware SuSE"
if ssft_select_single "$TIT" "$MSG" $OPTS; then
MSG=$(eval_gettext "The user selected: '\$SSFT_RESULT'")
else
MSG="$CANCEL"
fi
ssft_display_message "$RES" "$MSG"
echo "-------------------------"
echo "ssft_show_file"
echo "-------------------------"
echo ""
TIT="`gettext "Showing the source code of this test"`"
if ssft_show_file "$TIT" "$script_file"; then
MSG=$(eval_gettext "The file '\$script_file' was shown")
else
MSG=$(eval_gettext "The file '\$script_file' was NOT shown")
fi
ssft_display_message "$RES" "$MSG"
echo "---------------------"
echo "ssft_yesno"
echo "---------------------"
echo ""
TIT="`gettext "Title for Yes/No Question"`"
MSG="`gettext "All was OK?"`"
if ssft_yesno "$TIT" "$MSG"; then
MSG="`gettext "The user said YES"`"
else
MSG="`gettext "The user said NO"`"
fi
ssft_display_message "$RES" "$MSG"
done
}
# Main program
script_file="$0"
ssft_sh_frontend_tests "$@"
# ------
# SVN Id: $Id: ssft-test.sh 86 2009-07-13 22:48:13Z sto $
|