ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #00062
[Branch ~ted/libindicate/messages-v2] Rev 390: Merging in tests for the v2 features.
Merge authors:
Ted Gould (ted)
------------------------------------------------------------
revno: 390 [merge]
committer: Ted Gould <ted@xxxxxxxxxxxxx>
branch nick: messages-v2
timestamp: Thu 2009-09-03 17:09:23 -0500
message:
Merging in tests for the v2 features.
added:
tests/test-indicator-display-client.c
tests/test-indicator-display-half-client.c
tests/test-indicator-display-half-server.c
tests/test-indicator-display-server.c
tests/test-max-indicators-client.c
tests/test-max-indicators-list.h
tests/test-max-indicators-server-repeat.c
tests/test-max-indicators-server.c
tests/test_indicator_display
tests/test_indicator_display_half
tests/test_max_indicators
tests/test_max_indicators_repeat
modified:
.bzrignore
tests/Makefile.am
--
lp:~ted/libindicate/messages-v2
https://code.launchpad.net/~ted/libindicate/messages-v2
Your team ayatana-commits is subscribed to branch lp:~ted/libindicate/messages-v2.
To unsubscribe from this branch go to https://code.launchpad.net/~ted/libindicate/messages-v2/+edit-subscription.
=== modified file '.bzrignore'
--- .bzrignore 2009-08-31 13:23:29 +0000
+++ .bzrignore 2009-09-03 21:57:34 +0000
@@ -140,3 +140,10 @@
libindicate-gtk/indicate-gtk-0.2.pc
tests/Makefile
tests/Makefile.in
+tests/test-max-indicators-client
+tests/test-max-indicators-server
+tests/test-max-indicators-server-repeat
+tests/test-indicator-display-client
+tests/test-indicator-display-server
+tests/test-indicator-display-half-server
+tests/test-indicator-display-half-client
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2009-04-27 15:48:38 +0000
+++ tests/Makefile.am 2009-09-03 22:04:01 +0000
@@ -3,7 +3,11 @@
test_simple \
test_interests \
test_interests_multi \
- test_thousand_indicators
+ test_thousand_indicators \
+ test_max_indicators \
+ test_max_indicators_repeat \
+ test_indicator_display \
+ test_indicator_display_half
libexec_PROGRAMS = \
test-interests-client \
@@ -16,7 +20,14 @@
test-thousand-indicators-client \
test-thousand-indicators-server \
test-simple-client \
- test-simple-server
+ test-simple-server \
+ test-max-indicators-server-repeat \
+ test-max-indicators-server \
+ test-max-indicators-client \
+ test-indicator-display-server \
+ test-indicator-display-client \
+ test-indicator-display-half-server \
+ test-indicator-display-half-client
EXTRA_DIST = \
$(TESTS)
@@ -139,3 +150,81 @@
../libindicate/libindicate.la \
$(LIBINDICATE_LIBS)
+test_max_indicators: test-max-indicators-client test-max-indicators-server
+
+test_max_indicators_client_SOURCES = \
+ test-max-indicators-client.c test-max-indicators-list.h
+
+test_max_indicators_client_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_max_indicators_client_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+test_max_indicators_server_SOURCES = \
+ test-max-indicators-server.c test-max-indicators-list.h
+
+test_max_indicators_server_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_max_indicators_server_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+test_max_indicators_repeat: test-max-indicators-client test-max-indicators-server-repeat
+
+test_max_indicators_server_repeat_SOURCES = \
+ test-max-indicators-server-repeat.c test-max-indicators-list.h
+
+test_max_indicators_server_repeat_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_max_indicators_server_repeat_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+test_indicator_display: test-indicator-display-client test-indicator-display-server
+
+test_indicator_display_client_SOURCES = \
+ test-indicator-display-client.c
+
+test_indicator_display_client_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_indicator_display_client_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+test_indicator_display_server_SOURCES = \
+ test-indicator-display-server.c
+
+test_indicator_display_server_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_indicator_display_server_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+test_indicator_display_half: test-indicator-display-half-client test-indicator-display-half-server
+
+test_indicator_display_half_client_SOURCES = \
+ test-indicator-display-half-client.c
+
+test_indicator_display_half_client_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_indicator_display_half_client_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+test_indicator_display_half_server_SOURCES = \
+ test-indicator-display-half-server.c
+
+test_indicator_display_half_server_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_indicator_display_half_server_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
=== added file 'tests/test-indicator-display-client.c'
--- tests/test-indicator-display-client.c 1970-01-01 00:00:00 +0000
+++ tests/test-indicator-display-client.c 2009-09-03 21:32:22 +0000
@@ -0,0 +1,64 @@
+
+#include <glib.h>
+#include "libindicate/indicator.h"
+#include "libindicate/server.h"
+#include "libindicate/interests.h"
+
+#define MAX_INDICATOR_COUNT 100
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+static int count = 0;
+
+
+static void
+indicator_displayed (IndicateIndicator * indicator, gboolean displayed, gpointer user_data)
+{
+ g_debug("Indicator displayed: %s", displayed ? "true" : "false");
+ if (displayed) {
+ count++;
+ }
+
+ return;
+}
+
+static gboolean
+done_timeout_cb (gpointer data)
+{
+ g_debug("%d of %d indicators displayed", count, MAX_INDICATOR_COUNT);
+ if (count != MAX_INDICATOR_COUNT) {
+ passed = FALSE;
+ }
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+static guint indicators = 0;
+static gboolean
+idle_func (gpointer data)
+{
+ if (indicators == MAX_INDICATOR_COUNT) {
+ return FALSE;
+ }
+
+ indicators++;
+ IndicateIndicator * indicator = indicate_indicator_new();
+ g_signal_connect(G_OBJECT(indicator), INDICATE_INDICATOR_SIGNAL_DISPLAYED, G_CALLBACK(indicator_displayed), NULL);
+ indicate_indicator_show(indicator);
+
+ return TRUE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ g_idle_add(idle_func, NULL);
+ g_timeout_add(MAX_INDICATOR_COUNT * 10, done_timeout_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
=== added file 'tests/test-indicator-display-half-client.c'
--- tests/test-indicator-display-half-client.c 1970-01-01 00:00:00 +0000
+++ tests/test-indicator-display-half-client.c 2009-09-03 22:01:41 +0000
@@ -0,0 +1,64 @@
+
+#include <glib.h>
+#include "libindicate/indicator.h"
+#include "libindicate/server.h"
+#include "libindicate/interests.h"
+
+#define MAX_INDICATOR_COUNT 100
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+static int count = 0;
+
+
+static void
+indicator_displayed (IndicateIndicator * indicator, gboolean displayed, gpointer user_data)
+{
+ g_debug("Indicator displayed: %s", displayed ? "true" : "false");
+ if (displayed) {
+ count++;
+ }
+
+ return;
+}
+
+static gboolean
+done_timeout_cb (gpointer data)
+{
+ g_debug("%d of %d indicators displayed", count, MAX_INDICATOR_COUNT / 2);
+ if (count != MAX_INDICATOR_COUNT / 2) {
+ passed = FALSE;
+ }
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+static guint indicators = 0;
+static gboolean
+idle_func (gpointer data)
+{
+ if (indicators == MAX_INDICATOR_COUNT) {
+ return FALSE;
+ }
+
+ indicators++;
+ IndicateIndicator * indicator = indicate_indicator_new();
+ g_signal_connect(G_OBJECT(indicator), INDICATE_INDICATOR_SIGNAL_DISPLAYED, G_CALLBACK(indicator_displayed), NULL);
+ indicate_indicator_show(indicator);
+
+ return TRUE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ g_idle_add(idle_func, NULL);
+ g_timeout_add(MAX_INDICATOR_COUNT * 10, done_timeout_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
=== added file 'tests/test-indicator-display-half-server.c'
--- tests/test-indicator-display-half-server.c 1970-01-01 00:00:00 +0000
+++ tests/test-indicator-display-half-server.c 2009-09-03 22:01:41 +0000
@@ -0,0 +1,55 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+#include "test-max-indicators-list.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+gboolean doit = TRUE;
+
+static void
+indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gpointer data)
+{
+ if (doit) {
+ indicate_listener_displayed(listener, server, indicator, TRUE);
+ doit = FALSE;
+ } else {
+ doit = TRUE;
+ }
+ return;
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Done indicatating displayed");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+static void
+server_removed (void)
+{
+ g_debug("Server went away, exiting.");
+ g_main_loop_quit(mainloop);
+ return;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED, G_CALLBACK(indicator_added), NULL);
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_CALLBACK(server_removed), NULL);
+
+ g_timeout_add_seconds(2, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
=== added file 'tests/test-indicator-display-server.c'
--- tests/test-indicator-display-server.c 1970-01-01 00:00:00 +0000
+++ tests/test-indicator-display-server.c 2009-09-03 21:25:30 +0000
@@ -0,0 +1,48 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+#include "test-max-indicators-list.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+
+static void
+indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gpointer data)
+{
+ return indicate_listener_displayed(listener, server, indicator, TRUE);
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Done indicatating displayed");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+static void
+server_removed (void)
+{
+ g_debug("Server went away, exiting.");
+ g_main_loop_quit(mainloop);
+ return;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED, G_CALLBACK(indicator_added), NULL);
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_CALLBACK(server_removed), NULL);
+
+ g_timeout_add_seconds(2, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
=== added file 'tests/test-max-indicators-client.c'
--- tests/test-max-indicators-client.c 1970-01-01 00:00:00 +0000
+++ tests/test-max-indicators-client.c 2009-09-03 01:47:13 +0000
@@ -0,0 +1,57 @@
+
+#include <glib.h>
+#include "libindicate/indicator.h"
+#include "libindicate/server.h"
+#include "libindicate/interests.h"
+#include "test-max-indicators-list.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+static int count = 0;
+
+
+static void
+max_changed (IndicateServer * server, gint max, gpointer userdata)
+{
+ g_debug("Oh, max changed: %d", max);
+
+ if (max != max_indicator_list[count]) {
+ passed = FALSE;
+ g_debug("\tBut that's not right! We wanted: %d", max_indicator_list[count]);
+ }
+ count++;
+
+ if (count == MAX_INDICATOR_COUNT) {
+ g_main_loop_quit(mainloop);
+ }
+
+ return;
+}
+
+static gboolean
+done_timeout_cb (gpointer data)
+{
+ g_debug("All maxes not set");
+ passed = FALSE;
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateIndicator * indicator = indicate_indicator_new();
+ indicate_indicator_show(indicator);
+
+ IndicateServer * server = indicate_server_ref_default();
+ g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED, G_CALLBACK(max_changed), NULL);
+
+ g_timeout_add(MAX_INDICATOR_COUNT * 10 * 100, done_timeout_cb, indicator);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
=== added file 'tests/test-max-indicators-list.h'
--- tests/test-max-indicators-list.h 1970-01-01 00:00:00 +0000
+++ tests/test-max-indicators-list.h 2009-09-03 01:37:33 +0000
@@ -0,0 +1,3 @@
+
+#define MAX_INDICATOR_COUNT 8
+gint max_indicator_list[MAX_INDICATOR_COUNT] = { 1, 0, 1000, 0, 500, 1, 7, -1 };
=== added file 'tests/test-max-indicators-server-repeat.c'
--- tests/test-max-indicators-server-repeat.c 1970-01-01 00:00:00 +0000
+++ tests/test-max-indicators-server-repeat.c 2009-09-03 01:50:10 +0000
@@ -0,0 +1,86 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+#include "test-max-indicators-list.h"
+
+gint repeat_list[MAX_INDICATOR_COUNT] = { 2, 3, 1, 4, 2, 3, 1, 20 };
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static guint count = 0;
+static guint repeat = 0;
+
+static IndicateListener * l = NULL;
+static IndicateListenerServer * s = NULL;
+
+gboolean
+set_max (gpointer userdata)
+{
+ g_debug("Setting max indicators to: %d", max_indicator_list[count]);
+ indicate_listener_set_server_max_indicators(l, s, max_indicator_list[count]);
+ if (repeat == repeat_list[count]) {
+ count++;
+ repeat = 0;
+ } else {
+ repeat++;
+ }
+
+ if (count >= MAX_INDICATOR_COUNT) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+}
+
+static void
+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+{
+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+
+ if (l != NULL || s != NULL) {
+ g_warning("Adding a second server? %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server));
+ return;
+ }
+
+ l = listener;
+ s = server;
+
+ g_timeout_add(100, set_max, NULL);
+
+ return;
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Done indicatating max indicators");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+
+ guint i, repeat_sum = 0;
+ for (i = 0; i < MAX_INDICATOR_COUNT; i++) {
+ repeat_sum += repeat_list[i];
+ }
+
+ if (repeat_sum / MAX_INDICATOR_COUNT > 9) {
+ g_warning("Risk of client timeout.");
+ }
+
+ g_timeout_add((MAX_INDICATOR_COUNT + 4 + repeat_sum) * 100, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
=== added file 'tests/test-max-indicators-server.c'
--- tests/test-max-indicators-server.c 1970-01-01 00:00:00 +0000
+++ tests/test-max-indicators-server.c 2009-09-03 01:50:10 +0000
@@ -0,0 +1,69 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+#include "test-max-indicators-list.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static guint count = 0;
+
+static IndicateListener * l = NULL;
+static IndicateListenerServer * s = NULL;
+
+gboolean
+set_max (gpointer userdata)
+{
+ g_debug("Setting max indicators to: %d", max_indicator_list[count]);
+ indicate_listener_set_server_max_indicators(l, s, max_indicator_list[count]);
+ count++;
+
+ if (count >= MAX_INDICATOR_COUNT) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+}
+
+static void
+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+{
+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+
+ if (l != NULL || s != NULL) {
+ g_warning("Adding a second server? %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server));
+ return;
+ }
+
+ l = listener;
+ s = server;
+
+ g_timeout_add(100, set_max, NULL);
+
+ return;
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Done indicatating max indicators");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+
+ g_timeout_add((MAX_INDICATOR_COUNT + 4) * 100, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
=== added file 'tests/test_indicator_display'
--- tests/test_indicator_display 1970-01-01 00:00:00 +0000
+++ tests/test_indicator_display 2009-09-03 21:07:15 +0000
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
+
+${DBUS_RUNNER} --task ./test-indicator-display-client --task-name Client --task ./test-indicator-display-server --task-name Server
=== added file 'tests/test_indicator_display_half'
--- tests/test_indicator_display_half 1970-01-01 00:00:00 +0000
+++ tests/test_indicator_display_half 2009-09-03 21:58:04 +0000
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
+
+${DBUS_RUNNER} --task ./test-indicator-display-half-client --task-name Client --task ./test-indicator-display-half-server --task-name Server
=== added file 'tests/test_max_indicators'
--- tests/test_max_indicators 1970-01-01 00:00:00 +0000
+++ tests/test_max_indicators 2009-09-02 22:07:29 +0000
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
+
+${DBUS_RUNNER} --task ./test-max-indicators-client --task-name Client --task ./test-max-indicators-server --task-name Server
=== added file 'tests/test_max_indicators_repeat'
--- tests/test_max_indicators_repeat 1970-01-01 00:00:00 +0000
+++ tests/test_max_indicators_repeat 2009-09-03 01:41:31 +0000
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
+
+${DBUS_RUNNER} --task ./test-max-indicators-client --task-name Client --task ./test-max-indicators-server-repeat --task-name Server