diff options
| author | Daniel Friesel <derf@derf.homelinux.org> | 2010-06-16 18:29:25 +0200 | 
|---|---|---|
| committer | Daniel Friesel <derf@derf.homelinux.org> | 2010-06-16 18:29:25 +0200 | 
| commit | a0f8f486340cdc2109e69d945ba235a8cf6e9e1b (patch) | |
| tree | c851e8eed2402d83a17400bb61da15941c1a6554 | |
| parent | ec496289debf2722626406daa3c34d35d35dd567 (diff) | |
Begin work on X test. So far, checks if q, x and ESC quit feh
| -rw-r--r-- | Makefile | 11 | ||||
| -rwxr-xr-x | test/feh.i | 48 | 
2 files changed, 59 insertions, 0 deletions
| @@ -6,6 +6,17 @@ all:  test: all  	@PACKAGE=${PACKAGE} VERSION=${VERSION} prove test +test-interactive: all +	@if [ "$$(whoami)" != derf ]; then \ +		echo "Note: This will do stuff with your X and take a while"; \ +		echo "If you don't know what's going on, hit ^C now"; \ +		sleep 5; \ +		echo "Okay, running test"; \ +	fi +	@if [ "$$(whoami)" = derf ]; then setxkbmap us; fi +	@prove test/*.i +	@if [ "$$(whoami)" = derf ]; then setxkbmap greedy; fi +  install: install-man install-doc install-bin install-font install-img  install-man: diff --git a/test/feh.i b/test/feh.i new file mode 100755 index 0000000..0a38bf1 --- /dev/null +++ b/test/feh.i @@ -0,0 +1,48 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; + +use Test::More tests => 3; +use X11::GUITest qw/ +	FindWindowLike +	StartApp +	SendKeys +	WaitWindowViewable +/; + +sub feh_start { +	my ($opts, $files) = @_; + +	$opts //= q{}; +	$files //= 'test/ok.png'; + +	StartApp("feh ${opts} ${files}"); +	if (WaitWindowViewable(qr{^feh}) == 0) { +		BAIL_OUT("Unable to start feh ${opts} ${files}"); +	} +} + +sub test_no_win { +	my ($reason) = @_; + +	for (1 .. 10) { +		sleep(0.1); +		if (FindWindowLike(qr{^feh}) == 0) { +			pass("Window closed ($reason)"); +			return; +		} +	} +	fail("Window closed ($reason)"); +	BAIL_OUT("unclosed window still open, cannot continue"); +} + +if (FindWindowLike(qr{^feh})) { +	BAIL_OUT('It appears you have an open feh window. Please close it.'); +} + +for my $key (qw/q x {ESC}/) { +	feh_start(); +	SendKeys($key); +	test_no_win("$key pressed"); +} | 
