From c0ac60b8fc5a146e22412d90ba7f2a38d99c157b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Ball=C3=B3?= Date: Sun, 20 Nov 2011 02:17:19 +0100 Subject: Make building tests optional --- Makefile.am | 10 +++++++--- configure.ac | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 3bd312e..807cad0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,13 +2,17 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} SUBDIRS = \ libindicator \ - tests \ tools -tests: libindicator - tools: libindicator +if WANT_TESTS +SUBDIRS += \ + tests + +tests: libindicator +endif + DISTCHECK_CONFIGURE_FLAGS = --disable-deprecations DISTCLEANFILES = \ diff --git a/configure.ac b/configure.ac index 2357f13..a2c39b5 100644 --- a/configure.ac +++ b/configure.ac @@ -107,6 +107,14 @@ AC_DEFINE_PATH(PREFIX, "${prefix}", [prefix directory]) AC_DEFINE_PATH(SYSCONFDIR, "${sysconfdir}", [system configuration dir]) AC_DEFINE_PATH(LIBDIR, "${libdir}", [system configuration dir]) +######################### +# Check if build tests +######################### +AC_ARG_ENABLE([tests], + AC_HELP_STRING([--disable-tests], [disable tests]),, + [enable_tests=yes]) +AM_CONDITIONAL([WANT_TESTS], [test "x$enable_tests" != "xno"]) + ######################### # Debug symbols ######################### @@ -146,5 +154,6 @@ Libindicator Configuration: Prefix: $prefix GTK+ Version: $with_gtk + Enable tests: $enable_tests Enable debugging: $enable_debug ]) -- cgit v1.2.3 From d1263521c78b88c2dfffe09aac10fc1a15cd790d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Ball=C3=B3?= Date: Sun, 20 Nov 2011 02:19:45 +0100 Subject: Use different directory for headers of gtk3 library --- libindicator/Makefile.am | 2 +- libindicator/indicator3-0.4.pc.in.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am index 53f9985..f9fb011 100644 --- a/libindicator/Makefile.am +++ b/libindicator/Makefile.am @@ -26,7 +26,7 @@ CLEANFILES += indicator$(VER)-0.$(INDICATOR_API_VERSION).pc include $(top_srcdir)/Makefile.am.marshal -libindicatorincludedir=$(includedir)/libindicator-0.$(INDICATOR_API_VERSION)/libindicator +libindicatorincludedir=$(includedir)/libindicator$(VER)-0.$(INDICATOR_API_VERSION)/libindicator indicator_headers = \ indicator.h \ diff --git a/libindicator/indicator3-0.4.pc.in.in b/libindicator/indicator3-0.4.pc.in.in index 1f34567..d4b5f0f 100644 --- a/libindicator/indicator3-0.4.pc.in.in +++ b/libindicator/indicator3-0.4.pc.in.in @@ -7,7 +7,7 @@ includedir=@includedir@ indicatordir=${libdir}/indicators3/@indicator_abi_version@/ iconsdir=@datarootdir@/@PACKAGE@/icons/ -Cflags: -I${includedir}/libindicator-0.@indicator_api_version@ +Cflags: -I${includedir}/libindicator3-0.@indicator_api_version@ Requires: gtk+-3.0 Libs: -lindicator3 -- cgit v1.2.3 From b1aebe568a4f0d0d76e9ea32df47385b26b45c5d Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Tue, 6 Dec 2011 15:21:45 -0600 Subject: Added coverage reporting via gcov config and targets. --- Makefile.am | 35 +++++++++++++++++++++ configure.ac | 10 ++++++ libindicator/Makefile.am | 2 ++ m4/gcov.m4 | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 m4/gcov.m4 diff --git a/Makefile.am b/Makefile.am index 3bd312e..1cb279e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,3 +40,38 @@ dist-hook: echo Failed to generate AUTHORS: not a branch >&2; \ fi + +# Coverage targets + +.PHONY: clean-gcda +clean-gcda: + @echo Removing old coverage results + -find -name '*.gcda' -print | xargs -r rm + +.PHONY: coverage-html generate-coverage-html clean-coverage-html +coverage-html: clean-gcda + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html + +generate-coverage-html: + @echo Collecting coverage data + $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool + LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info + +clean-coverage-html: clean-gcda + -$(LCOV) --directory $(top_builddir) -z + -rm -rf coverage.info coveragereport + +.PHONY: coverage-xml generate-coverage-xml clean-coverage-xml +coverage-xml: clean-gcda + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(MAKE) $(AM_MAKEFLAGS) generate-coverage-xml + +generate-coverage-xml: + @echo Generating coverage XML report + $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml + +clean-coverage-xml: clean-gcda + -rm -rf $(top_builddir)/coverage.xml + +clean-local: clean-coverage-html clean-coverage-xml diff --git a/configure.ac b/configure.ac index 2357f13..42a476a 100644 --- a/configure.ac +++ b/configure.ac @@ -121,6 +121,15 @@ fi AM_CONDITIONAL(ENABLE_DEBUG, test "$enable_debug" = "yes") +########################### +# gcov coverage reporting +########################### +m4_include([m4/gcov.m4]) +AC_TDD_GCOV +AC_SUBST(COVERAGE_CFLAGS) +AC_SUBST(COVERAGE_CXXFLAGS) +AC_SUBST(COVERAGE_LDFLAGS) + ########################### # Files ########################### @@ -147,4 +156,5 @@ Libindicator Configuration: GTK+ Version: $with_gtk Enable debugging: $enable_debug + Coverage reporting: $use_gcov ]) diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am index 53f9985..0f5ad34 100644 --- a/libindicator/Makefile.am +++ b/libindicator/Makefile.am @@ -55,6 +55,7 @@ libindicator_la_SOURCES = \ libindicator_la_CFLAGS = \ $(LIBINDICATOR_CFLAGS) \ + $(COVERAGE_CFLAGS) \ -DG_LOG_DOMAIN=\"libindicator\" \ -Wall -Werror @@ -62,6 +63,7 @@ libindicator_la_LIBADD = \ $(LIBINDICATOR_LIBS) libindicator_la_LDFLAGS = \ + $(COVERAGE_LDFLAGS) \ -version-info $(INDICATOR_ABI_VERSION):0:0 \ -no-undefined \ -export-symbols-regex "^[^_].*" diff --git a/m4/gcov.m4 b/m4/gcov.m4 new file mode 100644 index 0000000..9331cd3 --- /dev/null +++ b/m4/gcov.m4 @@ -0,0 +1,82 @@ +# Checks for existence of coverage tools: +# * gcov +# * lcov +# * genhtml +# * gcovr +# +# Sets ac_cv_check_gcov to yes if tooling is present +# and reports the executables to the variables LCOV, GCOVR and GENHTML. +AC_DEFUN([AC_TDD_GCOV], +[AC_CACHE_CHECK([whether code coverage tools are available], ac_cv_check_gcov, +[ +AC_ARG_ENABLE(gcov, + AS_HELP_STRING([--enable-gcov], + [enable coverage testing with gcov]), + [use_gcov=$enableval], [use_gcov=no]) + + if test "x$use_gcov" = "xyes"; then + # we need gcc: + if test "$GCC" != "yes"; then + AC_MSG_ERROR([GCC is required for --enable-gcov]) + fi + + # Check if ccache is being used + AC_CHECK_PROG(SHTOOL, shtool, shtool) + case `$SHTOOL path $CC` in + *ccache*[)] gcc_ccache=yes;; + *[)] gcc_ccache=no;; + esac + + if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then + AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) + fi + + lcov_version_list="1.6 1.7 1.8 1.9" + AC_CHECK_PROG(LCOV, lcov, lcov) + AC_CHECK_PROG(GENHTML, genhtml, genhtml) + AC_CHECK_PROG(GCOVR, gcovr, gcovr) + + if test "$LCOV"; then + AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ + glib_cv_lcov_version=invalid + lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` + for lcov_check_version in $lcov_version_list; do + if test "$lcov_version" = "$lcov_check_version"; then + glib_cv_lcov_version="$lcov_check_version (ok)" + fi + done + ]) + else + lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" + AC_MSG_ERROR([$lcov_msg]) + fi + + case $glib_cv_lcov_version in + ""|invalid[)] + lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." + AC_MSG_ERROR([$lcov_msg]) + LCOV="exit 0;" + ;; + esac + + if test -z "$GENHTML"; then + AC_MSG_ERROR([Could not find genhtml from the lcov package]) + fi + + if test -z "$GCOVR"; then + AC_MSG_ERROR([Could not find gcovr; easy_install (or pip) gcovr]) + fi + + + # Remove all optimization flags from CFLAGS + changequote({,}) + CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` + changequote([,]) + + # Add the special gcc flags + COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage" + COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage" + COVERAGE_LDFLAGS="-lgcov" + +fi +])]) # AC_TDD_GCOV -- cgit v1.2.3 From 976209fbb36c9b09a59c8d51da80ae065cca8192 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Jan 2012 13:04:25 +0100 Subject: Ignoring all the stuff we build --- .bzrignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.bzrignore b/.bzrignore index 5f78c4a..0874106 100644 --- a/.bzrignore +++ b/.bzrignore @@ -172,3 +172,10 @@ libindicator/s-enum-types-h libindicator/gen-indicator-service.xml.c libindicator/gen-indicator-service.xml.h libindicator/libindicator_la-gen-indicator-service.xml.lo +libindicator/indicator-0.4.pc.in +libindicator/indicator3-0.4.pc +libindicator/indicator3-0.4.pc.in +libindicator/libindicator3_la-gen-indicator-service.xml.lo +tools/indicator-loader3 +libindicator-[0-9]*.[0-9]*.[0-9]* +build-aux -- cgit v1.2.3 From 2bb19db591c96af488d90ec184ea458230a2c471 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Jan 2012 15:01:01 +0100 Subject: Adding an activate window function, that can also be virtual! --- libindicator/indicator-object.c | 8 ++++++++ libindicator/indicator-object.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index bd056f0..7cb75ae 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -538,6 +538,14 @@ indicator_object_get_show_now (IndicatorObject * io, IndicatorObjectEntry * entr return FALSE; } +void +indicator_object_entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) +{ + + + return; +} + /** indicator_object_entry_activate: @io: #IndicatorObject to query diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h index 3a120f5..bbc215a 100644 --- a/libindicator/indicator-object.h +++ b/libindicator/indicator-object.h @@ -118,6 +118,7 @@ struct _IndicatorObjectClass { gboolean (*get_show_now) (IndicatorObject * io, IndicatorObjectEntry * entry); void (*entry_activate) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); + void (*entry_activate_window) (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp); void (*entry_close) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); /* Signals */ @@ -184,6 +185,7 @@ GList * indicator_object_get_entries (IndicatorObject * io); guint indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry); guint indicator_object_get_show_now (IndicatorObject * io, IndicatorObjectEntry * entry); void indicator_object_entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); +void indicator_object_entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp); void indicator_object_entry_close (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); void indicator_object_set_environment (IndicatorObject * io, const GStrv env); -- cgit v1.2.3 From a6ed65aead78749086a67f92f53252b82c1bfc3d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Jan 2012 15:07:18 +0100 Subject: Documenting what this stuff does --- libindicator/indicator-object.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 7cb75ae..e606077 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -538,6 +538,22 @@ indicator_object_get_show_now (IndicatorObject * io, IndicatorObjectEntry * entr return FALSE; } +/** + indicator_object_entry_activate_window: + @io: #IndicatorObject to query + @entry: The #IndicatorObjectEntry whose entry was shown + @windowid: ID of the window that is currently focused (or will + be very shortly) + @timestamp: The X11 timestamp of the event + + Used to signal to the indicator that the menu on an entry has + been clicked on. This can either be an activate or a showing + of the menu. Also includes a window ID so that we can know what + application is going to be getting focused soon. If there is + no override of this function, it is the same as calling + indicator_object_entry_activate and in general is preferable + if you have that information available. +*/ void indicator_object_entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) { -- cgit v1.2.3 From a88097a93dcbd513d2d03d699c396e7b99ed4494 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Jan 2012 15:25:42 +0100 Subject: Handling the activate_window function and going up the stack --- libindicator/indicator-object.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index e606077..1fad637 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -557,7 +557,14 @@ indicator_object_get_show_now (IndicatorObject * io, IndicatorObjectEntry * entr void indicator_object_entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) { + g_return_if_fail(INDICATOR_IS_OBJECT(io)); + IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io); + if (class->entry_activate_window != NULL) { + return class->entry_activate_window(io, entry, windowid, timestamp); + } else { + indicator_object_entry_activate(io, entry, timestamp); + } return; } -- cgit v1.2.3 From 0419bac431d9820e3e611aeb2d95f3a6d2caf258 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Jan 2012 15:34:48 +0100 Subject: Clearing the entry function pointers --- libindicator/indicator-object.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 1fad637..7a3e393 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -99,6 +99,10 @@ indicator_object_class_init (IndicatorObjectClass *klass) klass->get_entries = get_entries_default; klass->get_location = NULL; + klass->entry_activate = NULL; + klass->entry_activate_window = NULL; + klass->entry_close = NULL; + /** IndicatorObject::entry-added: @arg0: The #IndicatorObject object -- cgit v1.2.3 From 68c166698b604451b1f14280c14838d4461121b2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Jan 2012 16:38:58 +0100 Subject: Build a new dummy indicator --- .bzrignore | 2 + tests/Makefile.am | 23 ++++++- tests/dummy-indicator-entry-func.c | 123 +++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 tests/dummy-indicator-entry-func.c diff --git a/.bzrignore b/.bzrignore index 0874106..7da05f5 100644 --- a/.bzrignore +++ b/.bzrignore @@ -179,3 +179,5 @@ libindicator/libindicator3_la-gen-indicator-service.xml.lo tools/indicator-loader3 libindicator-[0-9]*.[0-9]*.[0-9]* build-aux +libdummy_indicator_entry_func_la-dummy-indicator-entry-func.lo +libdummy-indicator-entry-func.la diff --git a/tests/Makefile.am b/tests/Makefile.am index f11a9d1..9d16748 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,7 +14,8 @@ lib_LTLIBRARIES = \ libdummy-indicator-blank.la \ libdummy-indicator-null.la \ libdummy-indicator-signaler.la \ - libdummy-indicator-simple.la + libdummy-indicator-simple.la \ + libdummy-indicator-entry-func.la DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf XVFB_RUN=". $(srcdir)/run-xvfb.sh" @@ -161,6 +162,26 @@ libdummy_indicator_simple_la_LDFLAGS = \ -module \ -avoid-version +############################# +# Dummy Indicator Entry Func +############################# + +libdummy_indicator_entry_func_la_SOURCES = \ + dummy-indicator-entry-func.c + +libdummy_indicator_entry_func_la_CFLAGS = \ + -Wall -Werror \ + $(LIBINDICATOR_CFLAGS) -I$(top_srcdir) + +libdummy_indicator_entry_func_la_LIBADD = \ + $(LIBINDICATOR_LIBS) \ + -L$(top_builddir)/libindicator/.libs \ + $(INDICATOR_LIB) + +libdummy_indicator_entry_func_la_LDFLAGS = \ + -module \ + -avoid-version + ############################# # Service Shutdown Timeout ############################# diff --git a/tests/dummy-indicator-entry-func.c b/tests/dummy-indicator-entry-func.c new file mode 100644 index 0000000..7271e86 --- /dev/null +++ b/tests/dummy-indicator-entry-func.c @@ -0,0 +1,123 @@ +/* +Test for libindicator + +Copyright 2012 Canonical Ltd. + +Authors: + Ted Gould + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +version 3.0 as published by the Free Software Foundation. + +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 General Public License version 3.0 for more details. + +You should have received a copy of the GNU General Public +License along with this library. If not, see +. +*/ + + +#include +#include + +#include "libindicator/indicator.h" +#include "libindicator/indicator-object.h" + +#define DUMMY_INDICATOR_ENTRY_FUNC_TYPE (dummy_indicator_entry_func_get_type ()) +#define DUMMY_INDICATOR_ENTRY_FUNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFunc)) +#define DUMMY_INDICATOR_ENTRY_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFuncClass)) +#define IS_DUMMY_INDICATOR_ENTRY_FUNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE)) +#define IS_DUMMY_INDICATOR_ENTRY_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_ENTRY_FUNC_TYPE)) +#define DUMMY_INDICATOR_ENTRY_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFuncClass)) + +typedef struct _DummyIndicatorEntryFunc DummyIndicatorEntryFunc; +typedef struct _DummyIndicatorEntryFuncClass DummyIndicatorEntryFuncClass; + +struct _DummyIndicatorEntryFuncClass { + IndicatorObjectClass parent_class; +}; + +struct _DummyIndicatorEntryFunc { + IndicatorObject parent; +}; + +GType dummy_indicator_entry_func_get_type (void); + +INDICATOR_SET_VERSION +INDICATOR_SET_TYPE(DUMMY_INDICATOR_ENTRY_FUNC_TYPE) + + +GtkLabel * +get_label (IndicatorObject * io) +{ + return NULL; +} + +GtkImage * +get_icon (IndicatorObject * io) +{ + return NULL; +} + +GtkMenu * +get_menu (IndicatorObject * io) +{ + return NULL; +} +const gchar * +get_accessible_desc (IndicatorObject * io) +{ + return NULL; +} + +static void dummy_indicator_entry_func_class_init (DummyIndicatorEntryFuncClass *klass); +static void dummy_indicator_entry_func_init (DummyIndicatorEntryFunc *self); +static void dummy_indicator_entry_func_dispose (GObject *object); +static void dummy_indicator_entry_func_finalize (GObject *object); + +G_DEFINE_TYPE (DummyIndicatorEntryFunc, dummy_indicator_entry_func, INDICATOR_OBJECT_TYPE); + +static void +dummy_indicator_entry_func_class_init (DummyIndicatorEntryFuncClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = dummy_indicator_entry_func_dispose; + object_class->finalize = dummy_indicator_entry_func_finalize; + + IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass); + + io_class->get_label = get_label; + io_class->get_image = get_icon; + io_class->get_menu = get_menu; + io_class->get_accessible_desc = get_accessible_desc; + + return; +} + +static void +dummy_indicator_entry_func_init (DummyIndicatorEntryFunc *self) +{ + + return; +} + +static void +dummy_indicator_entry_func_dispose (GObject *object) +{ + + G_OBJECT_CLASS (dummy_indicator_entry_func_parent_class)->dispose (object); + return; +} + +static void +dummy_indicator_entry_func_finalize (GObject *object) +{ + + G_OBJECT_CLASS (dummy_indicator_entry_func_parent_class)->finalize (object); + return; +} -- cgit v1.2.3 From 347ab41628cd47e996663d47244749d2d9fa1ea7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Jan 2012 16:48:52 +0100 Subject: Moving things into a shared header --- tests/dummy-indicator-entry-func.c | 24 +----------------- tests/dummy-indicator-entry-func.h | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 23 deletions(-) create mode 100644 tests/dummy-indicator-entry-func.h diff --git a/tests/dummy-indicator-entry-func.c b/tests/dummy-indicator-entry-func.c index 7271e86..76d8605 100644 --- a/tests/dummy-indicator-entry-func.c +++ b/tests/dummy-indicator-entry-func.c @@ -20,30 +20,8 @@ License along with this library. If not, see . */ +#include "dummy-indicator-entry-func.h" -#include -#include - -#include "libindicator/indicator.h" -#include "libindicator/indicator-object.h" - -#define DUMMY_INDICATOR_ENTRY_FUNC_TYPE (dummy_indicator_entry_func_get_type ()) -#define DUMMY_INDICATOR_ENTRY_FUNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFunc)) -#define DUMMY_INDICATOR_ENTRY_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFuncClass)) -#define IS_DUMMY_INDICATOR_ENTRY_FUNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE)) -#define IS_DUMMY_INDICATOR_ENTRY_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_ENTRY_FUNC_TYPE)) -#define DUMMY_INDICATOR_ENTRY_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFuncClass)) - -typedef struct _DummyIndicatorEntryFunc DummyIndicatorEntryFunc; -typedef struct _DummyIndicatorEntryFuncClass DummyIndicatorEntryFuncClass; - -struct _DummyIndicatorEntryFuncClass { - IndicatorObjectClass parent_class; -}; - -struct _DummyIndicatorEntryFunc { - IndicatorObject parent; -}; GType dummy_indicator_entry_func_get_type (void); diff --git a/tests/dummy-indicator-entry-func.h b/tests/dummy-indicator-entry-func.h new file mode 100644 index 0000000..1134ee7 --- /dev/null +++ b/tests/dummy-indicator-entry-func.h @@ -0,0 +1,52 @@ +/* +Test for libindicator + +Copyright 2012 Canonical Ltd. + +Authors: + Ted Gould + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +version 3.0 as published by the Free Software Foundation. + +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 General Public License version 3.0 for more details. + +You should have received a copy of the GNU General Public +License along with this library. If not, see +. +*/ + +#ifndef __DUMMY_INDICATOR_ENTRY_FUNC__ +#define __DUMMY_INDICATOR_ENTRY_FUNC__ + +#include +#include + +#include "libindicator/indicator.h" +#include "libindicator/indicator-object.h" + +G_BEGIN_DECLS + +#define DUMMY_INDICATOR_ENTRY_FUNC_TYPE (dummy_indicator_entry_func_get_type ()) +#define DUMMY_INDICATOR_ENTRY_FUNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFunc)) +#define DUMMY_INDICATOR_ENTRY_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFuncClass)) +#define IS_DUMMY_INDICATOR_ENTRY_FUNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE)) +#define IS_DUMMY_INDICATOR_ENTRY_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_ENTRY_FUNC_TYPE)) +#define DUMMY_INDICATOR_ENTRY_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFuncClass)) + +typedef struct _DummyIndicatorEntryFunc DummyIndicatorEntryFunc; +typedef struct _DummyIndicatorEntryFuncClass DummyIndicatorEntryFuncClass; + +struct _DummyIndicatorEntryFuncClass { + IndicatorObjectClass parent_class; +}; + +struct _DummyIndicatorEntryFunc { + IndicatorObject parent; +}; + +#endif /* __DUMMY_INDICATOR_ENTRY_FUNC__ */ -- cgit v1.2.3 From 530b2112773545b4449879ef45118e1469946a22 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Jan 2012 16:52:42 +0100 Subject: Adding some public values to know if functions were called --- tests/dummy-indicator-entry-func.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/dummy-indicator-entry-func.h b/tests/dummy-indicator-entry-func.h index 1134ee7..f5c8264 100644 --- a/tests/dummy-indicator-entry-func.h +++ b/tests/dummy-indicator-entry-func.h @@ -47,6 +47,10 @@ struct _DummyIndicatorEntryFuncClass { struct _DummyIndicatorEntryFunc { IndicatorObject parent; + + gboolean entry_activate_called; + gboolean entry_activate_window_called; + gboolean entry_close_called; }; #endif /* __DUMMY_INDICATOR_ENTRY_FUNC__ */ -- cgit v1.2.3 From efcb3e654caba19ade1dbe905eb9ae8526f08791 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Jan 2012 17:00:47 +0100 Subject: Setting up entry functions --- tests/dummy-indicator-entry-func.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/dummy-indicator-entry-func.c b/tests/dummy-indicator-entry-func.c index 76d8605..bccd818 100644 --- a/tests/dummy-indicator-entry-func.c +++ b/tests/dummy-indicator-entry-func.c @@ -52,6 +52,28 @@ get_accessible_desc (IndicatorObject * io) return NULL; } +static void +entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp) +{ + + return; +} + +static void +entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) +{ + + return; +} + +static void +entry_close (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp) +{ + + return; +} + + static void dummy_indicator_entry_func_class_init (DummyIndicatorEntryFuncClass *klass); static void dummy_indicator_entry_func_init (DummyIndicatorEntryFunc *self); static void dummy_indicator_entry_func_dispose (GObject *object); @@ -74,6 +96,10 @@ dummy_indicator_entry_func_class_init (DummyIndicatorEntryFuncClass *klass) io_class->get_menu = get_menu; io_class->get_accessible_desc = get_accessible_desc; + io_class->entry_activate = entry_activate; + io_class->entry_activate_window = entry_activate_window; + io_class->entry_close = entry_close; + return; } -- cgit v1.2.3 From b7c8a634f190e176b1d3b201ff08d861ba5e265b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 14 Jan 2012 10:07:43 +0100 Subject: Mark the entry functions as called --- tests/dummy-indicator-entry-func.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/dummy-indicator-entry-func.c b/tests/dummy-indicator-entry-func.c index bccd818..96e5ad0 100644 --- a/tests/dummy-indicator-entry-func.c +++ b/tests/dummy-indicator-entry-func.c @@ -55,21 +55,24 @@ get_accessible_desc (IndicatorObject * io) static void entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp) { - + DummyIndicatorEntryFunc * self = DUMMY_INDICATOR_ENTRY_FUNC(io); + self->entry_activate_called = TRUE; return; } static void entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) { - + DummyIndicatorEntryFunc * self = DUMMY_INDICATOR_ENTRY_FUNC(io); + self->entry_activate_window_called = TRUE; return; } static void entry_close (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp) { - + DummyIndicatorEntryFunc * self = DUMMY_INDICATOR_ENTRY_FUNC(io); + self->entry_close_called = TRUE; return; } -- cgit v1.2.3 From 7586398a88487db955504cce8d348a65f95d4c22 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 14 Jan 2012 10:30:22 +0100 Subject: Adding a test functioin for the entry func demmy indicator --- tests/Makefile.am | 2 +- tests/test-loader.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 9d16748..13a34c4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -433,7 +433,7 @@ DISTCLEANFILES += service-manager-connect-nostart-tester XML_REPORT = loader-check-results.xml HTML_REPORT = loader-check-results.html -loader-tester: test-loader libdummy-indicator-null.la libdummy-indicator-simple.la Makefile +loader-tester: test-loader libdummy-indicator-null.la libdummy-indicator-simple.la libdummy-indicator-entry-func.la Makefile @echo "#!/bin/bash" > loader-tester @echo $(XVFB_RUN) >> $@ @echo gtester -k --verbose -o=$(XML_REPORT) ./test-loader >> loader-tester diff --git a/tests/test-loader.c b/tests/test-loader.c index ac9d4e5..3adce3b 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -23,6 +23,34 @@ License along with this library. If not, see #include #include "libindicator/indicator-object.h" +#include "dummy-indicator-entry-func.h" + +void +test_loader_entry_funcs (void) +{ + IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-entry-func.so"); + g_assert(object != NULL); + + DummyIndicatorEntryFunc * entryfunc = (DummyIndicatorEntryFunc *)(object); + + entryfunc->entry_activate_called = FALSE; + entryfunc->entry_activate_window_called = FALSE; + entryfunc->entry_close_called = FALSE; + + indicator_object_entry_activate(object, NULL, 0); + g_assert(entryfunc->entry_activate_called); + + indicator_object_entry_activate_window(object, NULL, 0, 0); + g_assert(entryfunc->entry_activate_window_called); + + indicator_object_entry_close(object, NULL, 0); + g_assert(entryfunc->entry_close_called); + + g_object_unref(object); + + return; +} + void destroy_cb (gpointer data, GObject * object); void @@ -174,6 +202,7 @@ test_loader_creation_deletion_suite (void) g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors); g_test_add_func ("/libindicator/loader/dummy/simple_location", test_loader_filename_dummy_simple_location); g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler); + g_test_add_func ("/libindicator/loader/dummy/entry_funcs", test_loader_entry_funcs); return; } -- cgit v1.2.3 From da798a2bfc8d4b1068eb1e9a1ec502cad09c59ac Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 14 Jan 2012 10:33:29 +0100 Subject: Getting the header in dist --- tests/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 13a34c4..c8a9ba7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -167,7 +167,8 @@ libdummy_indicator_simple_la_LDFLAGS = \ ############################# libdummy_indicator_entry_func_la_SOURCES = \ - dummy-indicator-entry-func.c + dummy-indicator-entry-func.c \ + dummy-indicator-entry-func.h libdummy_indicator_entry_func_la_CFLAGS = \ -Wall -Werror \ -- cgit v1.2.3 From 2dfe3fff249cd22eea6a993dc5ec50b129d961f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 14 Jan 2012 10:51:55 +0100 Subject: Add a function to swap out the window entry handler --- tests/dummy-indicator-entry-func.c | 14 ++++++++++++++ tests/dummy-indicator-entry-func.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/tests/dummy-indicator-entry-func.c b/tests/dummy-indicator-entry-func.c index 96e5ad0..ac330aa 100644 --- a/tests/dummy-indicator-entry-func.c +++ b/tests/dummy-indicator-entry-func.c @@ -128,3 +128,17 @@ dummy_indicator_entry_func_finalize (GObject *object) G_OBJECT_CLASS (dummy_indicator_entry_func_parent_class)->finalize (object); return; } + +void +dummy_indicator_entry_func_support_window(DummyIndicatorEntryFunc * ind, gboolean different) +{ + DummyIndicatorEntryFuncClass * entry_class = DUMMY_INDICATOR_ENTRY_FUNC_GET_CLASS(ind); + + if (different) { + entry_class->parent_class.entry_activate_window = entry_activate_window; + } else { + entry_class->parent_class.entry_activate_window = NULL; + } + + return; +} diff --git a/tests/dummy-indicator-entry-func.h b/tests/dummy-indicator-entry-func.h index f5c8264..d22abed 100644 --- a/tests/dummy-indicator-entry-func.h +++ b/tests/dummy-indicator-entry-func.h @@ -53,4 +53,6 @@ struct _DummyIndicatorEntryFunc { gboolean entry_close_called; }; +void dummy_indicator_entry_func_support_window(DummyIndicatorEntryFunc * ind, gboolean different); + #endif /* __DUMMY_INDICATOR_ENTRY_FUNC__ */ -- cgit v1.2.3 From f898563b6eaff8a00dd0cc2f7adabed16b80b698 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Jan 2012 03:45:00 +0100 Subject: Adding a test to look to make sure the fallback works --- tests/test-loader.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test-loader.c b/tests/test-loader.c index 3adce3b..48537c0 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -25,6 +25,31 @@ License along with this library. If not, see #include "dummy-indicator-entry-func.h" +void +test_loader_entry_func_window (void) +{ + IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-entry-func.so"); + g_assert(object != NULL); + + DummyIndicatorEntryFunc * entryfunc = (DummyIndicatorEntryFunc *)(object); + + entryfunc->entry_activate_called = FALSE; + entryfunc->entry_activate_window_called = FALSE; + entryfunc->entry_close_called = FALSE; + + dummy_indicator_entry_func_support_window(entryfunc, FALSE); + indicator_object_entry_activate_window(object, NULL, 0, 0); + g_assert(entryfunc->entry_activate_called); + + dummy_indicator_entry_func_support_window(entryfunc, TRUE); + indicator_object_entry_activate_window(object, NULL, 0, 0); + g_assert(entryfunc->entry_activate_window_called); + + g_object_unref(object); + + return; +} + void test_loader_entry_funcs (void) { @@ -203,6 +228,7 @@ test_loader_creation_deletion_suite (void) g_test_add_func ("/libindicator/loader/dummy/simple_location", test_loader_filename_dummy_simple_location); g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler); g_test_add_func ("/libindicator/loader/dummy/entry_funcs", test_loader_entry_funcs); + g_test_add_func ("/libindicator/loader/dummy/entry_func_window", test_loader_entry_func_window); return; } -- cgit v1.2.3 From 6a0f41aaa53cb79e03520a8214cc2c9305821496 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Jan 2012 03:59:29 +0100 Subject: Moving the function into the tester to making linking simpler --- tests/dummy-indicator-entry-func.c | 14 -------------- tests/dummy-indicator-entry-func.h | 2 -- tests/test-loader.c | 23 +++++++++++++++++++++-- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/tests/dummy-indicator-entry-func.c b/tests/dummy-indicator-entry-func.c index ac330aa..96e5ad0 100644 --- a/tests/dummy-indicator-entry-func.c +++ b/tests/dummy-indicator-entry-func.c @@ -128,17 +128,3 @@ dummy_indicator_entry_func_finalize (GObject *object) G_OBJECT_CLASS (dummy_indicator_entry_func_parent_class)->finalize (object); return; } - -void -dummy_indicator_entry_func_support_window(DummyIndicatorEntryFunc * ind, gboolean different) -{ - DummyIndicatorEntryFuncClass * entry_class = DUMMY_INDICATOR_ENTRY_FUNC_GET_CLASS(ind); - - if (different) { - entry_class->parent_class.entry_activate_window = entry_activate_window; - } else { - entry_class->parent_class.entry_activate_window = NULL; - } - - return; -} diff --git a/tests/dummy-indicator-entry-func.h b/tests/dummy-indicator-entry-func.h index d22abed..f5c8264 100644 --- a/tests/dummy-indicator-entry-func.h +++ b/tests/dummy-indicator-entry-func.h @@ -53,6 +53,4 @@ struct _DummyIndicatorEntryFunc { gboolean entry_close_called; }; -void dummy_indicator_entry_func_support_window(DummyIndicatorEntryFunc * ind, gboolean different); - #endif /* __DUMMY_INDICATOR_ENTRY_FUNC__ */ diff --git a/tests/test-loader.c b/tests/test-loader.c index 48537c0..2e9cf55 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -25,6 +25,25 @@ License along with this library. If not, see #include "dummy-indicator-entry-func.h" +void +entry_func_swap (IndicatorObject * io) +{ + static void (*saved_func) (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) = NULL; + IndicatorObjectClass * klass = INDICATOR_OBJECT_GET_CLASS(io); + + if (saved_func == NULL) { + saved_func = klass->entry_activate_window; + } + + if (klass->entry_activate_window == NULL) { + klass->entry_activate_window = saved_func; + } else { + klass->entry_activate_window = NULL; + } + + return; +} + void test_loader_entry_func_window (void) { @@ -37,11 +56,11 @@ test_loader_entry_func_window (void) entryfunc->entry_activate_window_called = FALSE; entryfunc->entry_close_called = FALSE; - dummy_indicator_entry_func_support_window(entryfunc, FALSE); + entry_func_swap(object); indicator_object_entry_activate_window(object, NULL, 0, 0); g_assert(entryfunc->entry_activate_called); - dummy_indicator_entry_func_support_window(entryfunc, TRUE); + entry_func_swap(object); indicator_object_entry_activate_window(object, NULL, 0, 0); g_assert(entryfunc->entry_activate_window_called); -- cgit v1.2.3