From 878281812a378100299732bf7caa7bca88296c88 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 2 Feb 2020 18:25:31 +0800 Subject: [PATCH] Add test script --- Makefile.am | 7 +++++++ configure.ac | 14 +++++++++++++- src/floating_shape.c | 10 ++++------ test.sh | 15 +++++++++++++++ 4 files changed, 39 insertions(+), 7 deletions(-) create mode 100755 test.sh diff --git a/Makefile.am b/Makefile.am index ed45be0..7444d5a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,3 +5,10 @@ EXTRA_DIST = config.rpath m4/ChangeLog cow.svg xcowsay.6 man_MANS = xcowsay.6 ACLOCAL_AMFLAGS = -I m4 + +TESTS = test.sh + +TESTS_ENVIRONMENT = \ + BUILD_DIR=$(top_builddir) \ + SRC_DIR=$(top_srcdir) + diff --git a/configure.ac b/configure.ac index eec04a3..c11d0c4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,19 @@ AC_INIT([xcowsay], [1.4], [Nick Gasson ], [xcowsay]) -AM_INIT_AUTOMAKE([-Wall]) +AC_PREREQ([2.63]) + +dnl Automake 1.11 does not support the serial-tests option +dnl Remove this when 1.11 no longer in common use +m4_define([serial_tests], [ + m4_esyscmd([ + automake --version | + head -1 | + awk '{split ($NF,a,"."); if (a[1] == 1 && a[2] >= 12) { print "serial-tests" }}' + ]) +]) + +AM_INIT_AUTOMAKE([1.11 -Wall -Wno-extra-portability color-tests] serial_tests) # Check for programs AC_PROG_CC diff --git a/src/floating_shape.c b/src/floating_shape.c index 7837144..2941d13 100644 --- a/src/floating_shape.c +++ b/src/floating_shape.c @@ -39,15 +39,13 @@ static gboolean draw_shape(GtkWidget *widget, GdkEventExpose *event, gpointer userdata) { float_shape_t *s = (float_shape_t *)userdata; + cairo_t *cr; + int width, height; - cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget)); + cr = gdk_cairo_create(gtk_widget_get_window(widget)); - if (true /*supports_alpha*/) - cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); /* transparent */ - else - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* opaque white */ + cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); - int width, height; gtk_window_get_size(GTK_WINDOW(widget), &width, &height); gdk_cairo_set_source_pixbuf(cr, s->pixbuf, 0, 0); diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..5e9cdcf --- /dev/null +++ b/test.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +echo Normal mode +$BUILD_DIR/src/xcowsay Hello World + +echo Left bubble +$BUILD_DIR/src/xcowsay --left Hello World + +echo Thought bubble +$BUILD_DIR/src/xcowsay --think Hello World + +echo Dream +$BUILD_DIR/src/xcowsay --dream $SRC_DIR/cow_small.png -t 2 -- 2.39.2