| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
## Include utility functions. |
| 4 |
. "$XDG_TEST_DIR/include/testassertions.sh" |
| 5 |
|
| 6 |
. "$XDG_TEST_DIR/include/testcontrol.sh" |
| 7 |
|
| 8 |
## Test function |
| 9 |
test_menu_system_as_nonroot() { |
| 10 |
USERPATH="${XDG_DATA_DIRS-/usr/local/share:/usr/share}:$HOME/.local:$HOME/.config:$XDG_DATA_HOME" |
| 11 |
|
| 12 |
## Begin the test. |
| 13 |
test_start "$FUNCNAME: verify error for --mode system when run as a normal user" |
| 14 |
|
| 15 |
# Dependencies section |
| 16 |
test_init |
| 17 |
|
| 18 |
require_notroot |
| 19 |
set_no_display |
| 20 |
|
| 21 |
use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_test.desktop" DESKTOP |
| 22 |
edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE |
| 23 |
assert_file "$DESKTOP" |
| 24 |
|
| 25 |
# Test steps section |
| 26 |
test_procedure |
| 27 |
|
| 28 |
assert_exit 3 xdg-desktop-menu install --mode system "$DESKTOP" |
| 29 |
assert_nostdout |
| 30 |
assert_stderr |
| 31 |
|
| 32 |
assert_file_not_in_path "$DESKTOP" "$USERPATH" |
| 33 |
|
| 34 |
assert_exit 3 xdg-desktop-menu uninstall --mode system "$DESKTOP" |
| 35 |
assert_nostdout |
| 36 |
assert_stderr |
| 37 |
|
| 38 |
test_result |
| 39 |
} |
| 40 |
run_test test_menu_system_as_nonroot |