3
## Include utility functions.
4
. "$XDG_TEST_DIR/include/testassertions.sh"
5
. "$XDG_TEST_DIR/include/testcontrol.sh"
8
test_menu_user_install() {
10
test_start "$FUNCNAME: verify a user menu is created correctly"
12
# Dependencies section
15
USERPATH="$HOME/.local:$HOME/.config"
19
# Generate .desktop file
20
use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_test.desktop" DESKTOP
21
use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_dummy.desktop" DESKTOP2
22
use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_install.directory" DIRECTORY
23
use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_install.menu" MENU
25
edit_file "$MENU" 'menu_install.directory' tmp "$DIRECTORY"
26
edit_file "$MENU" 'menu_item_test.desktop' tmp "$DESKTOP"
27
edit_file "$MENU" 'menu_item_dummy.desktop' tmp "$DESKTOP2"
28
edit_file "$MENU" 'XDG UTILS TEST' MENU_NAME "MENU $XDG_TEST_SHORTID"
30
edit_file "$DIRECTORY" 'XDG UTILS TEST' tmp "$MENU_NAME"
32
edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
33
edit_file "$DESKTOP" 'Test Menu Item Install' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
34
edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR"
36
assert_file "$DESKTOP"
38
assert_file "$DIRECTORY"
40
# Verify the test icon is not installed already.
41
assert_file_not_in_path "$DESKTOP" "$USERPATH"
42
assert_file_not_in_path "$DIRECTORY" "$USERPATH"
43
assert_file_not_in_path "$MENU" "$USERPATH"
48
assert_exit 0 xdg-desktop-menu install --noupdate --mode user "$DESKTOP"
52
assert_exit 0 xdg-desktop-menu install --noupdate --mode user "$DESKTOP2"
56
assert_exit 0 xdg-desktop-menu install --noupdate --mode user "$DIRECTORY"
60
assert_exit 0 xdg-desktop-menu install --noupdate --mode user "$MENU"
64
assert_exit 0 xdg-desktop-menu forceupdate --mode system
68
assert_file_in_path "$DESKTOP" "$USERPATH"
69
assert_file_in_path "$DESKTOP2" "$USERPATH"
70
assert_file_in_path "$DIRECTORY" "$USERPATH"
71
assert_file_in_path "$MENU" "$USERPATH"
73
if [ "$GDMSESSION" = "kde" ] ; then
74
# TODO: HACK: this shouldn't be necessary.
75
assert_interactive_notroot "You are running KDE. Please note that KDE takes time to update it's menus. Please refresh the menu several times prior to answering the following questions."
78
if [ -z "$XDG_TEST_NO_INTERACTIVE" -a `whoami` != 'root' ]; then
79
assert_interactive "Is there a menu in <main> called '$MENU_NAME'?" y
80
assert_interactive "Are there exactly 2 items in '<main>/$MENU_NAME' called 'EXTRA ITEM' and '$ITEM_TEXT'?" y
81
assert_interactive "Please select the menu item '<main>/$MENU_NAME/$ITEM_TEXT'"
83
## Double clicking will result in the command 'touch xdg-test-menu-item-install.tmp' to be run
84
assert_file "$WORK_DIR/$CREATEFILE"
88
xdg-desktop-menu uninstall --mode user "$DESKTOP" >/dev/null 2>&1
89
xdg-desktop-menu uninstall --mode user "$DESKTOP2" >/dev/null 2>&1
90
xdg-desktop-menu uninstall --mode user "$DIRECTORY" >/dev/null 2>&1
91
xdg-desktop-menu uninstall --mode user "$MENU" >/dev/null 2>&1
92
xdg-desktop-menu forceupdate --mode user >/dev/null 2>&1
97
run_test test_menu_user_install