#!/bin/bash

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

. "$XDG_TEST_DIR/include/testcontrol.sh"

## Test function
test_icon_nonexist_uninstall() {
test_start "$FUNCNAME: verify $ICON is uninstalled correctly even if it is not installed"

## Begin the test.
userpath="$HOME/.icons:$HOME/.local:$XDG_DATA_HOME"

# Dependencies section
test_init

set_no_display
use_file "$XDG_TEST_DIR/icons/$ICON" ICON_FILE
assert_file "$ICON_FILE"

# Verify the test icon is not installed already.
assert_file_not_in_path "$ICON_FILE" "$userpath"

# Test steps section
test_procedure

assert_exit 0 xdg-icon-resource uninstall --mode user --size "$SIZE" "$ICON_FILE"
assert_nostdout
assert_nostderr

assert_file_not_in_path "$ICON_FILE" "$userpath"

test_result
} 

repeat_test test_icon_nonexist_uninstall 2 ICON SIZE 'red-16.png' 'red-22.png' 'red-24.png' 'red-32.png' 16 22 24 32
repeat_test test_icon_nonexist_uninstall 2 ICON SIZE 'red-48.png' 'red-64.png' 'red-128.png' 48 64 128
