| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
## Include utility functions. |
| 4 |
. "$XDG_TEST_DIR/include/testassertions.sh" |
| 5 |
. "$XDG_TEST_DIR/include/testcontrol.sh" |
| 6 |
|
| 7 |
## Test function |
| 8 |
test_menu_advanced_install() { |
| 9 |
## Begin the test. |
| 10 |
test_start "$FUNCNAME: verify submenus are handled correctly" |
| 11 |
|
| 12 |
# Dependencies section |
| 13 |
test_init |
| 14 |
|
| 15 |
USERPATH="$HOME/.local:$HOME/.config" |
| 16 |
|
| 17 |
set_no_display |
| 18 |
|
| 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_item_dummy2.desktop" DESKTOP3 |
| 23 |
use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_install.directory" DIRECTORY |
| 24 |
|
| 25 |
edit_file "$DIRECTORY" 'XDG UTILS TEST' MENU_NAME "MENU $XDG_TEST_SHORTID" |
| 26 |
|
| 27 |
edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE |
| 28 |
edit_file "$DESKTOP" 'Test Menu Item Install' ITEM_TEXT "TEST $XDG_TEST_SHORTID" |
| 29 |
edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR" |
| 30 |
|
| 31 |
assert_file "$DESKTOP" |
| 32 |
assert_file "$DIRECTORY" |
| 33 |
|
| 34 |
# Verify the test icon is not installed already. |
| 35 |
assert_file_not_in_path "$DESKTOP" "$USERPATH" |
| 36 |
assert_file_not_in_path "$DIRECTORY" "$USERPATH" |
| 37 |
|
| 38 |
# Test steps section |
| 39 |
test_procedure |
| 40 |
|
| 41 |
assert_exit 0 xdg-desktop-menu install "$DIRECTORY" "$DESKTOP" "$DESKTOP2" "$DESKTOP3" |
| 42 |
assert_nostdout |
| 43 |
assert_nostderr |
| 44 |
|
| 45 |
if [ `whoami` != 'root' ]; then |
| 46 |
assert_file_in_path "$DESKTOP" "$USERPATH" |
| 47 |
assert_file_in_path "$DESKTOP2" "$USERPATH" |
| 48 |
assert_file_in_path "$DESKTOP3" "$USERPATH" |
| 49 |
assert_file_in_path "$DIRECTORY" "$USERPATH" |
| 50 |
fi |
| 51 |
|
| 52 |
if [ -z "$XDG_TEST_NO_INTERACTIVE" -a `whoami` != 'root' ]; then |
| 53 |
assert_interactive "Is there a menu in <main> called '$MENU_NAME'?" y |
| 54 |
assert_interactive "Are there exactly 3 items in '<main>/$MENU_NAME' called 'EXTRA ITEM', 'EXTRA ITEM 2' and '$ITEM_TEXT'?" y |
| 55 |
fi |
| 56 |
|
| 57 |
assert_exit 0 xdg-desktop-menu uninstall "$DIRECTORY" "$DESKTOP3" |
| 58 |
assert_nostdout |
| 59 |
assert_nostderr |
| 60 |
|
| 61 |
if [ `whoami` != 'root' ]; then |
| 62 |
assert_file_in_path "$DESKTOP" "$USERPATH" |
| 63 |
assert_file_in_path "$DESKTOP2" "$USERPATH" |
| 64 |
assert_file_not_in_path "$DESKTOP3" "$USERPATH" |
| 65 |
assert_file_in_path "$DIRECTORY" "$USERPATH" |
| 66 |
fi |
| 67 |
|
| 68 |
if [ -z "$XDG_TEST_NO_INTERACTIVE" -a `whoami` != 'root' ]; then |
| 69 |
assert_interactive "Is there still a menu in <main> called '$MENU_NAME'?" y |
| 70 |
assert_interactive "Are there exactly 2 items in '<main>/$MENU_NAME' called 'EXTRA ITEM' and '$ITEM_TEXT'?" y |
| 71 |
fi |
| 72 |
|
| 73 |
assert_exit 0 xdg-desktop-menu uninstall "$DIRECTORY" "$DESKTOP" "$DESKTOP2" |
| 74 |
assert_nostdout |
| 75 |
assert_nostderr |
| 76 |
|
| 77 |
if [ `whoami` != 'root' ]; then |
| 78 |
assert_file_not_in_path "$DESKTOP" "$USERPATH" |
| 79 |
assert_file_not_in_path "$DESKTOP2" "$USERPATH" |
| 80 |
assert_file_not_in_path "$DESKTOP3" "$USERPATH" |
| 81 |
assert_file_not_in_path "$DIRECTORY" "$USERPATH" |
| 82 |
fi |
| 83 |
|
| 84 |
test_result |
| 85 |
} |
| 86 |
|
| 87 |
run_test test_menu_advanced_install |