#!/bin/bash

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

## Test function
test_screensave_activate() {
test_start "$FUNCNAME: verify screensaver activate"

test_init

require_notroot
require_interactive
## Require a running X server
assert_display

test_procedure

assert_interactive "I will activate the screensaver 1 second after you press enter. Please press shift after it does."

assert_exit 0 xdg-screensaver status
assert_stdout

mv out.stdout out.stat

sleep 1

assert_exit 0 xdg-screensaver activate
assert_nostdout
assert_nostderr

sleep 1

assert_interactive "Did the screensaver activate?" y

assert_exit 0 xdg-screensaver status
assert_stdout out.stat

test_result
}

run_test test_screensave_activate
