aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac30
-rw-r--r--m4/gtest.m463
-rw-r--r--src/im-menu-item.c40
-rw-r--r--src/indicator-messages.c2
-rw-r--r--src/messages-service.c1
-rw-r--r--src/status-provider-telepathy.c2
-rw-r--r--test/Makefile.am34
-rw-r--r--test/test-gtest.cpp16
8 files changed, 182 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index 8ba218e..8646a0f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ AC_INIT(src/indicator-messages.c)
AC_PREREQ(2.53)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(indicator-messages, 0.5.92)
+AM_INIT_AUTOMAKE(indicator-messages, 0.5.93)
AM_MAINTAINER_MODE
@@ -31,6 +31,9 @@ AS_IF([test "x$enable_deprecations" = xno],
[CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE -DGTK_DISABLE_SINGLE_INCLUDES"]
)
+# the Google Test targets are cpp
+AC_PROG_CXX
+
###########################
# Dependencies
###########################
@@ -42,6 +45,7 @@ PANEL_REQUIRED_VERSION=2.0.0
INDICATE_REQUIRED_VERSION=0.6.90
INDICATOR_REQUIRED_VERSION=0.3.19
DBUSMENUGTK_REQUIRED_VERSION=0.5.90
+GLIB_REQUIRED_VERSION=2.31.20
AC_ARG_WITH([gtk],
[AS_HELP_STRING([--with-gtk],
@@ -54,14 +58,17 @@ AS_IF([test "x$with_gtk" = x3],
gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION
indicate-0.7 >= $INDICATE_REQUIRED_VERSION
- dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION)
+ dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
+ glib-2.0 >= GLIB_REQUIRED_VERSION)
+
],
[test "x$with_gtk" = x2],
[PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION
gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
indicator-0.4 >= $INDICATOR_REQUIRED_VERSION
indicate-0.7 >= $INDICATE_REQUIRED_VERSION
- dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION)
+ dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
+ glib-2.0 >= GLIB_REQUIRED_VERSION)
],
[AC_MSG_FAILURE([Value for --with-indicator-gtk was neither 2 nor 3])]
)
@@ -69,6 +76,15 @@ AC_SUBST(APPLET_CFLAGS)
AC_SUBST(APPLET_LIBS)
###########################
+# Test Dependencies
+###########################
+
+AC_ARG_ENABLE([tests],
+ AC_HELP_STRING([--disable-tests], [Disable test scripts and tools]),,
+ [enable_tests=auto])
+AM_CONDITIONAL(BUILD_TESTS, test xyes = xyes)
+
+###########################
# Status Provider Deps
###########################
@@ -104,6 +120,13 @@ AC_SUBST(COVERAGE_CXXFLAGS)
AC_SUBST(COVERAGE_LDFLAGS)
###########################
+# Google Test framework
+###########################
+
+m4_include([m4/gtest.m4])
+CHECK_GTEST
+
+###########################
# Check to see if we're local
###########################
@@ -192,6 +215,7 @@ data/icons/scalable/Makefile
data/icons/scalable/status/Makefile
data/icons/scalable/categories/Makefile
po/Makefile.in
+test/Makefile
])
###########################
diff --git a/m4/gtest.m4 b/m4/gtest.m4
new file mode 100644
index 0000000..2de334c
--- /dev/null
+++ b/m4/gtest.m4
@@ -0,0 +1,63 @@
+# Copyright (C) 2012 Canonical, Ltd.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+# Checks whether the gtest source is available on the system. Allows for
+# adjusting the include and source path. Sets have_gtest=yes if the source is
+# present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and
+# source location respectively.
+AC_DEFUN([CHECK_GTEST],
+[
+ AC_ARG_WITH([gtest-include-path],
+ [AS_HELP_STRING([--with-gtest-include-path],
+ [location of the Google test headers])],
+ [GTEST_CPPFLAGS="-I$withval"])
+
+ AC_ARG_WITH([gtest-source-path],
+ [AS_HELP_STRING([--with-gtest-source-path],
+ [location of the Google test sources, defaults to /usr/src/gtest])],
+ [GTEST_SOURCE="$withval"],
+ [GTEST_SOURCE="/usr/src/gtest"])
+
+ GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE"
+
+ AC_LANG_PUSH([C++])
+
+ tmp_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $GTEST_CPPFLAGS"
+
+ AC_CHECK_HEADER([gtest/gtest.h])
+
+ CPPFLAGS="$tmp_CPPFLAGS"
+
+ AC_LANG_POP
+
+ AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
+ [$GTEST_SOURCE/src/gtest_main.cc],
+ [have_gtest_source=yes],
+ [have_gtest_source=no])
+
+ AS_IF([test "x$ac_cv_header_gtest_gtest_h" = xyes -a \
+ "x$have_gtest_source" = xyes],
+ [have_gtest=yes]
+ [AC_SUBST(GTEST_CPPFLAGS)]
+ [AC_SUBST(GTEST_SOURCE)],
+ [have_gtest=no])
+]) # CHECK_GTEST
diff --git a/src/im-menu-item.c b/src/im-menu-item.c
index e7c0177..f07fff9 100644
--- a/src/im-menu-item.c
+++ b/src/im-menu-item.c
@@ -288,11 +288,47 @@ time_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateL
return;
}
+/* Returns a newly allocated string which is 'str' with all occurences of
+ * consecutive whitespace collapsed into single space character. */
+static gchar *
+collapse_whitespace (const gchar *str)
+{
+ GString *result;
+ gboolean in_space = FALSE;
+
+ if (!str)
+ return NULL;
+
+ result = g_string_sized_new (strlen (str));
+
+ while (*str) {
+ gunichar c = g_utf8_get_char_validated (str, -1);
+
+ if (c < 0)
+ break;
+
+ if (!g_unichar_isspace (c)) {
+ g_string_append_unichar (result, c);
+ in_space = FALSE;
+ }
+ else if (!in_space) {
+ g_string_append_c (result, ' ');
+ in_space = TRUE;
+ }
+
+ str = g_utf8_next_char (str);
+ }
+
+ return g_string_free (result, FALSE);
+}
+
/* Callback from libindicate that is for getting the sender information
on a particular indicator. */
static void
sender_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const gchar * propertydata, gpointer data)
{
+ gchar *label;
+
g_debug("Got Sender Information: %s", propertydata);
ImMenuItem * self = IM_MENU_ITEM(data);
@@ -310,7 +346,9 @@ sender_cb (IndicateListener * listener, IndicateListenerServer * server, Indicat
return;
}
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_LABEL, propertydata);
+ label = collapse_whitespace (propertydata);
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_LABEL, label);
+ g_free (label);
return;
}
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index cf81f40..2c5e3cd 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -724,7 +724,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
gtk_widget_set_size_request(GTK_WIDGET (gmi), -1, height + 4);
#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_widget_set_margin_left (hbox, width + 2 * padding);
+ gtk_widget_set_margin_left (hbox, width + padding);
#endif
GdkPixbuf * pixbuf = dbusmenu_menuitem_property_get_image(newitem, INDICATOR_MENUITEM_PROP_ICON);
diff --git a/src/messages-service.c b/src/messages-service.c
index a21435c..6e53d85 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -621,6 +621,7 @@ server_shortcut_added (AppMenuItem * appitem, DbusmenuMenuitem * mi, gpointer da
g_debug("Application Shortcut added: %s", mi != NULL ? dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL) : "none");
DbusmenuMenuitem * shell = DBUSMENU_MENUITEM(data);
if (mi != NULL) {
+ dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, "");
dbusmenu_menuitem_child_append(shell, mi);
}
resort_menu(shell);
diff --git a/src/status-provider-telepathy.c b/src/status-provider-telepathy.c
index c8e89da..948e965 100644
--- a/src/status-provider-telepathy.c
+++ b/src/status-provider-telepathy.c
@@ -290,7 +290,7 @@ set_status (StatusProvider * sp, StatusProviderStatus status)
ret = dbus_g_proxy_call(priv->proxy,
"GetPresence", &error,
G_TYPE_INVALID,
- G_TYPE_UINT, &priv->mc_status,
+ G_TYPE_UINT, &mcstatus,
G_TYPE_INVALID);
/* If we can't get the get call to work, let's not set */
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..e359ad4
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,34 @@
+
+check_LIBRARIES = libgtest.a
+check_PROGRAMS = test-gtest
+
+TESTS =
+
+AM_CPPFLAGS = $(GTEST_CPPFLAGS) \
+ -I${top_srcdir}/src
+
+nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc
+libgtest_a_SOURCES = \
+ $(GTEST_SOURCE)/src/gtest-all.cc \
+ $(GTEST_SOURCE)/src/gtest_main.cc
+libgtest_a_CPPFLAGS = \
+ $(GTEST_CPPFLAGS) -w
+libgtest_a_CXXFLAGS = \
+ $(AM_CXXFLAGS)
+libgtest_a_CPPFLAGS = \
+ $(AM_CPPFLAGS)
+
+TESTS += test-gtest
+
+test_gtest_SOURCES = \
+ $(top_srcdir)/src/launcher-menu-item.c \
+ $(top_srcdir)/src/default-applications.c \
+ $(top_srcdir)/src/seen-db.c \
+ test-gtest.cpp
+test_gtest_CPPFLAGS = \
+ $(APPLET_CFLAGS) \
+ $(AM_CPPFLAGS)
+test_gtest_LDFLAGS = -pthread
+test_gtest_LDADD = \
+ $(APPLET_LIBS) \
+ libgtest.a
diff --git a/test/test-gtest.cpp b/test/test-gtest.cpp
new file mode 100644
index 0000000..bb9943d
--- /dev/null
+++ b/test/test-gtest.cpp
@@ -0,0 +1,16 @@
+
+#include <glib.h>
+#include <gtest/gtest.h>
+
+extern "C" {
+ #include "launcher-menu-item.h"
+}
+
+TEST(LauncherMenuItem, NameInitialized) {
+ g_type_init();
+ //const gchar * expected = "foo";
+ //LauncherMenuItem * test_li = launcher_menu_item_new ("foo");
+ //gchar * result = launcher_menu_item_get_name(test_li);
+ //EXPECT_EQ(0, strcmp("foo", result));
+ EXPECT_TRUE(true);
+}