OLD | NEW |
(Empty) | |
| 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_user_install() { |
| 9 ## Begin the test. |
| 10 test_start "$FUNCNAME: verify a user menu is created 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_install.directory" DIRECTORY |
| 23 |
| 24 edit_file "$DIRECTORY" 'XDG UTILS TEST' MENU_NAME "MENU $XDG_TEST_SHORTID" |
| 25 |
| 26 edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE |
| 27 edit_file "$DESKTOP" 'Test Menu Item Install' ITEM_TEXT "TEST $XDG_TEST_SHORTID" |
| 28 edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR" |
| 29 |
| 30 assert_file "$DESKTOP" |
| 31 assert_file "$DIRECTORY" |
| 32 |
| 33 # Verify the test icon is not installed already. |
| 34 assert_file_not_in_path "$DESKTOP" "$USERPATH" |
| 35 assert_file_not_in_path "$DIRECTORY" "$USERPATH" |
| 36 |
| 37 # Test steps section |
| 38 test_procedure |
| 39 |
| 40 assert_exit 0 xdg-desktop-menu install --mode user "$DIRECTORY" "$DESKTOP" "$DES
KTOP2" |
| 41 assert_nostdout |
| 42 assert_nostderr |
| 43 |
| 44 assert_file_in_path "$DESKTOP" "$USERPATH" |
| 45 assert_file_in_path "$DESKTOP2" "$USERPATH" |
| 46 assert_file_in_path "$DIRECTORY" "$USERPATH" |
| 47 |
| 48 if [ "$GDMSESSION" = "kde" ] ; then |
| 49 # TODO: HACK: this shouldn't be necessary. |
| 50 assert_interactive_notroot "You are running KDE. Please note that KDE ta
kes time to update it's menus. Please refresh the menu several times prior to an
swering the following questions." |
| 51 fi |
| 52 |
| 53 if [ -z "$XDG_TEST_NO_INTERACTIVE" -a `whoami` != 'root' ]; then |
| 54 assert_interactive "Is there a menu in <main> called '$MENU_NAME'?" y |
| 55 assert_interactive "Are there exactly 2 items in '<main>/$MENU_NAME' called 'EXT
RA ITEM' and '$ITEM_TEXT'?" y |
| 56 assert_interactive "Please select the menu item '<main>/$MENU_NAME/$ITEM_TEXT'" |
| 57 |
| 58 ## Double clicking will result in the command 'touch xdg-test-menu-item-install.
tmp' to be run |
| 59 assert_file "$WORK_DIR/$CREATEFILE" |
| 60 fi |
| 61 |
| 62 ## Cleanup |
| 63 xdg-desktop-menu uninstall --mode user "$DIRECTORY" "$DESKTOP" "$DESKTOP2">/dev/
null 2>&1 |
| 64 |
| 65 test_result |
| 66 } |
| 67 |
| 68 run_test test_menu_user_install |
OLD | NEW |