summaryrefslogtreecommitdiff
path: root/tests/xdg-desktop-menu/t.22-menu_system_install
blob: 19d83040057d505b7cf654d79c2be6f76edf68af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash

## Include utility functions.
. "$XDG_TEST_DIR/include/testassertions.sh"
. "$XDG_TEST_DIR/include/testcontrol.sh"

## Test function
test_menu_system_install() {
## Begin the test.
test_start "$FUNCNAME: verify a system menu is created correctly"

# Dependencies section
test_init

USERPATH="$XDG_DATA_DIRS:$XDG_CONFIG_DIRS"

require_root
set_no_display

# Generate .desktop file
use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_test.desktop" DESKTOP
use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_dummy.desktop" DESKTOP2
use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_install.directory" DIRECTORY
use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_install.menu" MENU

edit_file "$MENU" 'menu_install.directory' tmp "$DIRECTORY"
edit_file "$MENU" 'menu_item_dummy.desktop' tmp "$DESKTOP2"
edit_file "$MENU" 'menu_item_test.desktop' tmp "$DESKTOP"
edit_file "$MENU" 'XDG UTILS TEST' MENU_NAME "TEST MENU $XDG_TEST_SHORTID"

edit_file "$DIRECTORY" 'XDG UTILS TEST' tmp "$MENU_NAME"

edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
edit_file "$DESKTOP" 'Test Menu Item Install' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR"

assert_file "$DESKTOP"
assert_file "$MENU"
assert_file "$DIRECTORY"

# Verify the test icon is not installed already.
assert_file_not_in_path "$DESKTOP" "$USERPATH"
assert_file_not_in_path "$DIRECTORY" "$USERPATH"
assert_file_not_in_path "$MENU" "$USERPATH"

# Test steps section
test_procedure

assert_exit 0 xdg-desktop-menu install --noupdate --mode system "$DESKTOP"
assert_nostdout
assert_nostderr

assert_exit 0 xdg-desktop-menu install --noupdate --mode system "$DESKTOP2"
assert_nostdout
assert_nostderr

assert_exit 0 xdg-desktop-menu install --noupdate --mode system "$DIRECTORY"
assert_nostdout
assert_nostderr

assert_exit 0 xdg-desktop-menu install --noupdate --mode system "$MENU"
assert_nostdout
assert_nostderr

assert_exit 0 xdg-desktop-menu forceupdate --mode system
assert_nostdout
assert_nostderr

assert_file_in_path "$DESKTOP" "$USERPATH"
assert_file_in_path "$DESKTOP2" "$USERPATH"
assert_file_in_path "$DIRECTORY" "$USERPATH"
assert_file_in_path "$MENU" "$USERPATH"


if [ -z "$XDG_TEST_NO_INTERACTIVE" ]; then

assert_interactive "Is there a menu in <main> called '$MENU_NAME'?\n(NOTE: If you are using KDE, it may take a few seconds for the menu to appear.)" y
assert_interactive "Are there exactly 2 items in '<main>/$MENU_NAME' called 'EXTRA ITEM' and '$ITEM_TEXT'?" y
assert_interactive "Please select the menu item '<main>/$MENU_NAME/$ITEM_TEXT'"

## Double clicking will result in the command 'touch xdg-test-menu-item-install.tmp' to be run
assert_file "$WORK_DIR/$CREATEFILE"

fi

## Cleanup
xdg-desktop-menu uninstall --mode system "$DESKTOP" >/dev/null 2>&1
xdg-desktop-menu uninstall --mode system "$DESKTOP2" >/dev/null 2>&1
xdg-desktop-menu uninstall --mode system "$DIRECTORY" >/dev/null 2>&1
xdg-desktop-menu uninstall --mode system "$MENU" >/dev/null 2>&1
xdg-desktop-menu forceupdate --mode system >/dev/null 2>&1

test_result
} 

run_test test_menu_system_install