summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hammond <chipx86@chipx86.com>2005-07-04 09:15:43 +0000
committerChristian Hammond <chipx86@chipx86.com>2005-07-04 09:15:43 +0000
commit635fc9d10a9e9f4e486404ae6cf7d6a1f0d99d51 (patch)
tree43660afe95875f24044c50a5f7ae8b17e4ec1925
parent7848ca696820b2602cee0d2079df4e2020180815 (diff)
downloadlibnotify-635fc9d10a9e9f4e486404ae6cf7d6a1f0d99d51.tar.gz
- 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.
-rw-r--r--ChangeLog10
-rw-r--r--configure.ac13
-rw-r--r--tests/Makefile.am26
-rw-r--r--tests/test-markup.c2
-rw-r--r--tests/test-xy-stress.c85
5 files changed, 127 insertions, 9 deletions
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 <chipx86@chipx86.com>
+
+ * 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 <chipx86@chipx86.com>
* 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 <b>bold</b>, <u>underlined</u>, <i>italic</i>, "
"<a href='http://www.google.com'>linked</a> 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 <chipx86@chipx86.com>
+ *
+ * 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 <libnotify/notify.h>
+#include <gdk/gdk.h>
+#include <stdio.h>
+#include <unistd.h>
+
+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;
+}