summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTom Whipple <tw@tomwhipple.com>2006-08-10 22:51:59 +0000
committerTom Whipple <tw@tomwhipple.com>2006-08-10 22:51:59 +0000
commit86fb3927e6f7c7cb7b759d844c858b3e33a4175a (patch)
treec3fb8d7316ca92706136144ac23c3cddd4379704 /tests
parent54c3d5c79da0776343dcc964a9dc35a21da72028 (diff)
add desktop file icon association & svg render tests
Diffstat (limited to 'tests')
-rw-r--r--tests/xdg-utils-usecases/data/icon_test.desktop10
-rwxr-xr-xtests/xdg-utils-usecases/t.11-desktop_file_icon64
-rwxr-xr-xtests/xdg-utils-usecases/t.12-svg_icon_render59
3 files changed, 133 insertions, 0 deletions
diff --git a/tests/xdg-utils-usecases/data/icon_test.desktop b/tests/xdg-utils-usecases/data/icon_test.desktop
new file mode 100644
index 0000000..828a96c
--- /dev/null
+++ b/tests/xdg-utils-usecases/data/icon_test.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Version=1.0
+Encoding=UTF-8
+Type=Application
+
+Exec=touch xdg-test-desktop-icon-install.tmp
+
+Name=Icon Test
+Icon=red
+StartupNotify=false
diff --git a/tests/xdg-utils-usecases/t.11-desktop_file_icon b/tests/xdg-utils-usecases/t.11-desktop_file_icon
new file mode 100755
index 0000000..e742cda
--- /dev/null
+++ b/tests/xdg-utils-usecases/t.11-desktop_file_icon
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_desktop_file_icon() {
+
+test_start "$FUNCNAME: ensure that associations with filetypes is correct."
+
+ICON_SIZES="16 22 24 32 48 64 128"
+
+test_init
+
+# get icon files
+for i in $ICON_SIZES; do
+ use_file "$XDG_TEST_DIR/icons/red-$i.png" TMP
+done
+
+# get & edit desktop file
+use_file "$XDG_TEST_DIR/xdg-utils-usecases/data/icon_test.desktop" DESKTOP_FILE
+edit_file "$DESKTOP_FILE" 'red' ICON_NAME
+TEST_DIR="$XDG_TEST_TMPDIR/show"
+assert_exit 0 mkdir -p "$TEST_DIR"
+assert_exit 0 cp "$DESKTOP_FILE" "$TEST_DIR/"
+
+test_procedure
+
+# install icons of all sizes
+for i in $ICON_SIZES; do
+ assert_exit 0 xdg-icon-resource install --size "$i" "xdgtestdata-$XDG_TEST_ID-red-$i.png" "$ICON_NAME.png"
+ assert_nostdout
+ assert_nostderr
+done
+
+
+# open directory with test file
+if [ `whoami` != 'root' ] ; then
+ assert_exit 0 xdg-open "$TEST_DIR"
+ assert_nostdout
+ assert_nostderr
+else
+ assert_interactive "Please open '$TEST_DIR' in the file browser."
+fi
+
+# ask user to cycle through sizes & ensure correct icons are displayed.
+assert_interactive "Is a file named 'Icon Test' present in the directory?" y
+assert_interactive "Does the icon consist of a red number in the list {$ICON_SIZES}?\n\tThe number should roughly correspond to the icon size.\n\t(You may need to select something like 'View->As Icons')" y
+assert_interactive "Does the number change appropriately when you increase or decrease the view size?" y
+
+## cleanup
+assert_interactive "Please close any windows opened by this test." C
+
+# remove icons
+for i in $ICON_SIZES; do
+ assert_exit 0 xdg-icon-resource uninstall --size "$i" "$ICON_NAME.png"
+ assert_nostdout
+ assert_nostderr
+done
+
+
+test_result
+}
+
+run_test test_desktop_file_icon
diff --git a/tests/xdg-utils-usecases/t.12-svg_icon_render b/tests/xdg-utils-usecases/t.12-svg_icon_render
new file mode 100755
index 0000000..f342fef
--- /dev/null
+++ b/tests/xdg-utils-usecases/t.12-svg_icon_render
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_svg_icon_render() {
+
+test_start "$FUNCNAME: ensure that SVG icons are rendered"
+
+
+test_init
+
+# get icon file
+use_file "$XDG_TEST_DIR/icons/red-SVG.svg" ICON_FILE
+
+# get & edit desktop file
+use_file "$XDG_TEST_DIR/xdg-utils-usecases/data/icon_test.desktop" DESKTOP_FILE
+edit_file "$DESKTOP_FILE" 'red' ICON_NAME
+
+TEST_DIR="$XDG_TEST_TMPDIR"
+#assert_exit 0 mkdir -p "$TEST_DIR"
+#assert_exit 0 cp "$DESKTOP_FILE" "$TEST_DIR/"
+
+
+
+test_procedure
+
+# install icons of all sizes
+assert_exit 0 xdg-icon-resource install "$ICON_FILE" "$ICON_NAME.svg"
+assert_nostdout
+assert_nostderr
+
+# open directory with test file
+if [ `whoami` != 'root' ] ; then
+ assert_exit 0 xdg-open "$TEST_DIR"
+ assert_nostdout
+ assert_nostderr
+else
+ assert_interactive "Please open '$TEST_DIR' in the file browser."
+fi
+
+# ask user to cycle through sizes & ensure correct icons are displayed.
+assert_interactive "Is a file named 'Icon Test' present in the directory?" y
+assert_interactive "Does the icon consist of the red text 'SVG'?\n\t(You may need to select something like 'View->As Icons')" y
+assert_interactive "Does the text change size appropriately when the display size is changed?" y
+
+## cleanup
+assert_interactive "Please close any windows opened by this test." C
+
+# remove icons
+assert_exit 0 xdg-icon-resource uninstall "$ICON_NAME.svg"
+assert_nostdout
+assert_nostderr
+
+
+test_result
+}
+
+run_test test_svg_icon_render