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_system_install() { |
| 9 ## Begin the test. |
| 10 test_start "$FUNCNAME: verify a system menu is created correctly" |
| 11 |
| 12 # Dependencies section |
| 13 test_init |
| 14 |
| 15 USERPATH="${XDG_DATA_DIRS-/usr/local/share:/usr/share}:${XDG_CONFIG_DIRS-/etc/xd
g}" |
| 16 |
| 17 require_root |
| 18 set_no_display |
| 19 |
| 20 # Generate .desktop file |
| 21 use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_test.desktop" DESKTOP |
| 22 use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_dummy.desktop" DESKTOP2 |
| 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 --mode system "$DIRECTORY" "$DESKTOP" "$D
ESKTOP2" |
| 42 assert_nostdout |
| 43 assert_nostderr |
| 44 |
| 45 assert_file_in_path "$DESKTOP" "$USERPATH" |
| 46 assert_file_in_path "$DESKTOP2" "$USERPATH" |
| 47 assert_file_in_path "$DIRECTORY" "$USERPATH" |
| 48 |
| 49 |
| 50 if [ -z "$XDG_TEST_NO_INTERACTIVE" ]; then |
| 51 |
| 52 assert_interactive "Is there a menu in <main> called '$MENU_NAME'?\n\t(NOTE: If
you are using KDE, it may take a few seconds for the menu to appear.)" y |
| 53 assert_interactive "Are there exactly 2 items in '<main>/$MENU_NAME' called 'EXT
RA ITEM' and '$ITEM_TEXT'?" y |
| 54 assert_interactive "Please select the menu item '<main>/$MENU_NAME/$ITEM_TEXT'" |
| 55 |
| 56 ## Double clicking will result in the command 'touch xdg-test-menu-item-install.
tmp' to be run |
| 57 assert_file "$WORK_DIR/$CREATEFILE" |
| 58 |
| 59 fi |
| 60 |
| 61 ## Cleanup |
| 62 xdg-desktop-menu uninstall --mode system "$DIRECTORY" "$DESKTOP" "$DESKTOP2">/de
v/null 2>&1 |
| 63 |
| 64 test_result |
| 65 } |
| 66 |
| 67 run_test test_menu_system_install |
OLD | NEW |