From 635fc9d10a9e9f4e486404ae6cf7d6a1f0d99d51 Mon Sep 17 00:00:00 2001 From: Christian Hammond Date: Mon, 4 Jul 2005 09:15:43 +0000 Subject: [PATCH] - Conditionally build gdk-dependent test apps if we have gdk. - Added a X, Y stress test that will be used to help test accurately positioning the arrows. --- ChangeLog | 10 +++++ configure.ac | 13 +++++++ tests/Makefile.am | 26 +++++++++---- tests/test-markup.c | 2 +- tests/test-xy-stress.c | 85 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 9 deletions(-) create mode 100644 tests/test-xy-stress.c diff --git a/ChangeLog b/ChangeLog index b404feb..bf2f3f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Jul 04 02:13:56 PDT 2005 Christian Hammond + + * tests/Makefile.am: + * tests/test-markup.c: + A tests/test-xy-stress.c: + * configure.ac: + - Conditionally build gdk-dependent test apps if we have gdk. + - Added a X, Y stress test that will be used to help test + accurately positioning the arrows. + Thu Jun 30 21:09:18 PDT 2005 Christian Hammond * tests/Makefile.am: diff --git a/configure.ac b/configure.ac index 9a3a01f..d4c7b82 100644 --- a/configure.ac +++ b/configure.ac @@ -94,6 +94,19 @@ PKG_CHECK_MODULES(PACKAGE, [$pkg_modules]) AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) +gdk_modules="gdk-2.0 gdk-pixbuf-2.0" +PKG_CHECK_MODULES(GDK, [$gdk_modules], have_gdk=yes, +[ + have_gdk=no + + AC_WARN("Some test apps will not be built") +]) + +AM_CONDITIONAL(HAVE_GDK, test "x$have_gdk" = "xyes") + +AC_SUBST(GDK_CFLAGS) +AC_SUBST(GDK_LIBS) + dnl dnl Check the D-BUS version. dnl diff --git a/tests/Makefile.am b/tests/Makefile.am index cdc38ab..2475d71 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,3 +1,14 @@ +if HAVE_GDK +gdk_tests = \ + test-animation \ + test-xy-stress + +test_animation_SOURCES = test-animation.c +test_xy_stress_SOURCES = test-xy-stress.c +else +gdk_tests = +endif + noinst_PROGRAMS = \ test-replace \ test-default-action \ @@ -5,15 +16,14 @@ noinst_PROGRAMS = \ test-image \ test-basic \ test-error \ - test-animation \ test-markup \ - test-xy + test-xy \ + $(gdk_tests) common_ldflags = \ $(top_builddir)/libnotify/libnotify.la \ - $(PACKAGE_LIBS) - -# FIXME: don't install these + $(PACKAGE_LIBS) \ + $(GDK_LIBS) test_replace_SOURCES = test-replace.c test_replace_LDADD = $(common_ldflags) @@ -28,9 +38,7 @@ test_basic_LDADD = $(common_ldflags) test_error_SOURCES = test-error.c test_error_LDADD = $(common_ldflags) -test_animation_SOURCES = test-animation.c test_animation_LDADD = $(common_ldflags) -test_animation_LDFLAGS = `pkg-config --libs gdk-pixbuf-2.0` test_markup_SOURCES = test-markup.c test_markup_LDADD = $(common_ldflags) @@ -38,4 +46,6 @@ test_markup_LDADD = $(common_ldflags) test_xy_SOURCES = test-xy.c test_xy_LDADD = $(common_ldflags) -INCLUDES = $(PACKAGE_CFLAGS) `pkg-config --cflags gdk-pixbuf-2.0` +test_xy_stress_LDADD = $(common_ldflags) + +INCLUDES = $(PACKAGE_CFLAGS) $(GDK_CFLAGS) diff --git a/tests/test-markup.c b/tests/test-markup.c index 6f3179f..6455f02 100644 --- a/tests/test-markup.c +++ b/tests/test-markup.c @@ -34,7 +34,7 @@ int main() { "Some bold, underlined, italic, " "linked text", NULL, // no icon - TRUE, time(NULL) + 5, + FALSE, 0, NULL, // no hints NULL, // no user data 0); // no actions diff --git a/tests/test-xy-stress.c b/tests/test-xy-stress.c new file mode 100644 index 0000000..c825630 --- /dev/null +++ b/tests/test-xy-stress.c @@ -0,0 +1,85 @@ +/* + * @file tests/test-xy.c Unit test: X, Y hints + * + * @Copyright (C) 2005 Christian Hammond + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include + +static void +emit_notification(int x, int y) +{ + NotifyHints *hints; + static char buffer[BUFSIZ]; + + hints = notify_hints_new(); + notify_hints_set_int(hints, "x", x); + notify_hints_set_int(hints, "y", y); + + g_snprintf(buffer, sizeof(buffer), + "This notification should point to %d, %d.", x, y); + + NotifyHandle *n = notify_send_notification( + NULL, // replaces nothing + NULL, + NOTIFY_URGENCY_NORMAL, + "X, Y Test", + buffer, + NULL, // no icon + TRUE, time(NULL) + 5, + hints, + NULL, // no user data + 0); // no actions + + if (!n) { + fprintf(stderr, "failed to send notification\n"); + } +} + +int +main(int argc, char **argv) +{ + GdkDisplay *display; + GdkScreen *screen; + int screen_x2, screen_y2; + + gdk_init(&argc, &argv); + + notify_init("XY"); + + display = gdk_display_get_default(); + screen = gdk_display_get_default_screen(display); + screen_x2 = gdk_screen_get_width(screen) - 1; + screen_y2 = gdk_screen_get_height(screen) - 1; + + emit_notification(0, 0); + emit_notification(screen_x2, 0); + emit_notification(5, 150); + emit_notification(screen_x2 - 5, 150); + emit_notification(0, screen_y2 / 2); + emit_notification(screen_x2, screen_y2 / 2); + emit_notification(5, screen_y2 - 150); + emit_notification(screen_x2 - 5, screen_y2 - 150); + emit_notification(0, screen_y2); + emit_notification(screen_x2, screen_y2); + + return 0; +}