#!/bin/bash

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

## Test function
test_menu_install_category() {
## Begin the test.
test_start "$FUNCNAME: verify that the menu properly supports the '$CATEGORY' category"

# Dependencies section
test_init

# Generate .desktop file
#USERPATH="$HOME/.local"

set_no_display

use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_category.desktop" DESKTOP
edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
edit_file "$DESKTOP" 'Test Menu Categories' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
edit_file "$DESKTOP" 'Development' TMP "$CATEGORY"
edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR"

assert_file "$DESKTOP"

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

# Test steps section
test_procedure

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

#assert_file_in_path "$DESKTOP" "$USERPATH"

#if [ -z "$XDG_TEST_NO_INTERACTIVE" -a `whoami` != 'root' ]; then

assert_interactive "Is an item called '$ITEM_TEXT' somewhere in the menu tree?\n\tThe item is probably in a menu that is related to '$CATEGORY'?" y
#fi

## Cleanup
assert_exit 0 xdg-desktop-menu uninstall "$DESKTOP"
assert_nostdout
assert_nostderr

test_result
} 

repeat_test test_menu_install_category 1 CATEGORY AudioVideo Game Office System Education Graphics Network Utility
