summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2015-12-31 21:55:15 +0100
committerDave Davenport <qball@gmpclient.org>2015-12-31 21:55:15 +0100
commit745f9f3c6228a0ad160dd9ef61300006e12f35f2 (patch)
tree9fb652aad869a467e276aa5d7309d78b25081bd6
parentde96149bed50084c14c4665f1bbb4a5d97d9e547 (diff)
Add screenshot test
-rw-r--r--Makefile.am2
-rw-r--r--source/rofi.c6
-rwxr-xr-xtest/run_dmenu_custom_test.sh1
-rwxr-xr-xtest/run_screenshot_test.sh28
-rwxr-xr-xtest/run_test.sh2
5 files changed, 34 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am
index b52052c9..1b5f582f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -186,6 +186,8 @@ test-x: ${bin_PROGRAMS}
$(top_srcdir)/test/run_test.sh 208 $(top_srcdir)/test/run_dmenu_empty.sh $(top_builddir)
echo "Test multiple select"
$(top_srcdir)/test/run_test.sh 209 $(top_srcdir)/test/run_dmenu_issue_292.sh $(top_builddir)
+ echo "Test screenshot"
+ $(top_srcdir)/test/run_test.sh 210 $(top_srcdir)/test/run_screenshot_test.sh $(top_builddir)
echo "End tests"
diff --git a/source/rofi.c b/source/rofi.c
index 2ab6e751..d46b88d6 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -613,14 +613,15 @@ static int locate_switcher ( KeySym key, unsigned int modstate )
*/
static void menu_capture_screenshot ( void )
{
+ const char *outp = g_getenv ( "ROFI_PNG_OUTPUT" );
if ( surface == NULL ) {
// Nothing to store.
fprintf ( stderr, "There is no rofi surface to store\n" );
return;
}
const char *xdg_pict_dir = g_get_user_special_dir ( G_USER_DIRECTORY_PICTURES );
- if ( xdg_pict_dir == NULL ) {
- fprintf ( stderr, "XDG user picture directory is not set. Cannot store screenshot.\n" );
+ if ( outp == NULL && xdg_pict_dir == NULL ) {
+ fprintf ( stderr, "XDG user picture directory or ROFI_PNG_OUTPUT is not set. Cannot store screenshot.\n" );
return;
}
// Get current time.
@@ -630,7 +631,6 @@ static void menu_capture_screenshot ( void )
char *filename = g_strdup_printf ( "%s.png", timestmp );
// Build full path
char *fpath = NULL;
- const char *outp = g_getenv ( "ROFI_PNG_OUTPUT" );
if ( outp == NULL ) {
int index = 0;
fpath = g_build_filename ( xdg_pict_dir, filename, NULL );
diff --git a/test/run_dmenu_custom_test.sh b/test/run_dmenu_custom_test.sh
index 57feb263..56c5042b 100755
--- a/test/run_dmenu_custom_test.sh
+++ b/test/run_dmenu_custom_test.sh
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
-xrdb -load ../doc/example.xresources
echo -e -n "aap\nnoot\nmies" | rofi -width -30 -dmenu > output.txt &
RPID=$!
diff --git a/test/run_screenshot_test.sh b/test/run_screenshot_test.sh
new file mode 100755
index 00000000..842fb00f
--- /dev/null
+++ b/test/run_screenshot_test.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+
+export ROFI_PNG_OUTPUT=out.png
+rofi -show run &
+RPID=$!
+
+# send enter.
+sleep 5;
+xdotool key 't'
+sleep 0.4
+xdotool key 'r'
+sleep 0.4
+xdotool key 'u'
+sleep 0.4
+xdotool key Alt+Shift+s
+sleep 0.4
+xdotool key Return
+
+# Get result, kill xvfb
+wait ${RPID}
+RETV=$?
+
+if [ ! -f out.png ]
+then
+ echo "Failed to create screenshot"
+ exit 1
+fi
+exit ${RETV}
diff --git a/test/run_test.sh b/test/run_test.sh
index 425ca96c..7cbad895 100755
--- a/test/run_test.sh
+++ b/test/run_test.sh
@@ -28,7 +28,7 @@ fi
create_fake_x "$1"
if [ -n "$4" ]
then
- xrdb -load "$4"
+ xrdb -load -retain "$4"
fi
echo "$DISPLAY"
$2