summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dbus/Makefile.am4
-rw-r--r--tests/dbus/account.c38
-rw-r--r--tests/dbus/call-channel.c2
-rw-r--r--tests/dbus/contacts.c24
-rw-r--r--tests/lib/simple-account.c50
-rw-r--r--tests/lib/simple-account.h3
-rw-r--r--tests/util-cxx.cpp2
7 files changed, 106 insertions, 17 deletions
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index 78ce99758..4d02d23d8 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -348,14 +348,14 @@ run-test.sh: run-test.sh.in
@chmod +x $@
dbus-uninstalled/%.conf: $(srcdir)/dbus-uninstalled/%.conf.in
- $(AM_V_at)$(mkdir_p) dbus-uninstalled
+ $(AM_V_at)$(MKDIR_P) dbus-uninstalled
$(AM_V_GEN)sed \
-e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" \
-e "s|[@]abs_top_srcdir[@]|@abs_top_srcdir@|g" \
$< > $@
dbus-installed/%.conf: $(srcdir)/dbus-installed/%.conf.in
- $(AM_V_at)$(mkdir_p) dbus-installed
+ $(AM_V_at)$(MKDIR_P) dbus-installed
$(AM_V_GEN)sed -e "s|[@]tpglibtestsdir[@]|@tpglibtestsdir@|g" $< > $@
service_files = dbus-installed/services/spurious.service
diff --git a/tests/dbus/account.c b/tests/dbus/account.c
index 3fb54b4b7..b921f4068 100644
--- a/tests/dbus/account.c
+++ b/tests/dbus/account.c
@@ -614,11 +614,29 @@ test_storage (Test *test,
}
static void
+check_uri_schemes (const gchar * const * schemes)
+{
+ g_assert (schemes != NULL);
+ g_assert (tp_strv_contains (schemes, "about"));
+ g_assert (tp_strv_contains (schemes, "telnet"));
+ g_assert (schemes[2] == NULL);
+}
+
+static void
+notify_cb (GObject *object,
+ GParamSpec *spec,
+ Test *test)
+{
+ g_main_loop_quit (test->mainloop);
+}
+
+static void
test_addressing (Test *test,
gconstpointer mode)
{
GQuark account_features[] = { TP_ACCOUNT_FEATURE_ADDRESSING, 0 };
const gchar * const *schemes;
+ GStrv tmp;
test->account = tp_account_new (test->dbus, ACCOUNT_PATH, NULL);
g_assert (test->account != NULL);
@@ -645,10 +663,14 @@ test_addressing (Test *test,
g_main_loop_run (test->mainloop);
schemes = tp_account_get_uri_schemes (test->account);
- g_assert (schemes != NULL);
- g_assert (tp_strv_contains (schemes, "about"));
- g_assert (tp_strv_contains (schemes, "telnet"));
- g_assert (schemes[2] == NULL);
+ check_uri_schemes (schemes);
+
+ g_object_get (test->account,
+ "uri-schemes", &tmp,
+ NULL);
+
+ check_uri_schemes ((const gchar * const *) tmp);
+ g_strfreev (tmp);
g_assert (tp_account_associated_with_uri_scheme (test->account,
"about"));
@@ -657,6 +679,14 @@ test_addressing (Test *test,
g_assert (!tp_account_associated_with_uri_scheme (test->account,
"xmpp"));
+ g_signal_connect (test->account, "notify::uri-schemes",
+ G_CALLBACK (notify_cb), test);
+
+ tp_tests_simple_account_add_uri_scheme (test->account_service, "xmpp");
+ g_main_loop_run (test->mainloop);
+
+ g_assert (tp_account_associated_with_uri_scheme (test->account,
+ "xmpp"));
}
static void
diff --git a/tests/dbus/call-channel.c b/tests/dbus/call-channel.c
index 7310c0ff1..4e12a056e 100644
--- a/tests/dbus/call-channel.c
+++ b/tests/dbus/call-channel.c
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "config.h"
+
#include <telepathy-glib/telepathy-glib.h>
#include <telepathy-glib/proxy-subclass.h>
diff --git a/tests/dbus/contacts.c b/tests/dbus/contacts.c
index 2b85d8e1c..9c070a732 100644
--- a/tests/dbus/contacts.c
+++ b/tests/dbus/contacts.c
@@ -359,7 +359,6 @@ test_contact_info (Fixture *f,
&result, finish, NULL);
g_main_loop_run (result.loop);
g_assert_no_error (result.error);
- g_object_ref (g_ptr_array_index (result.contacts, 0));
reset_result (&result);
tp_connection_set_contact_info_async (client_conn, info_list,
@@ -1500,7 +1499,7 @@ test_upgrade_noop (Fixture *f,
&result, finish, NULL);
g_main_loop_run (result.loop);
g_assert_no_error (result.error);
- reset_result (&f->result);
+ reset_result (&result);
put_the_connection_back (f);
@@ -2244,6 +2243,8 @@ test_dup_if_possible (Fixture *f,
g_assert (contact != alice);
g_assert_cmpstr (tp_contact_get_identifier (contact), ==, "bob");
g_assert_cmpuint (tp_contact_get_handle (contact), ==, bob_handle);
+ g_object_unref (contact);
+ g_object_unref (alice);
}
typedef struct
@@ -2692,6 +2693,7 @@ test_contact_list (Fixture *f,
gconstpointer unused G_GNUC_UNUSED)
{
const GQuark conn_features[] = { TP_CONNECTION_FEATURE_CONTACT_LIST, 0 };
+ const GQuark feature_connected[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 };
Result result = { g_main_loop_new (NULL, FALSE), NULL, NULL, NULL };
TpTestsContactListManager *manager;
TpSimpleClientFactory *factory;
@@ -2733,8 +2735,7 @@ test_contact_list (Fixture *f,
g_signal_connect_swapped (f->client_conn, "notify::contact-list-state",
G_CALLBACK (finish), &result);
tp_cli_connection_call_connect (f->client_conn, -1, NULL, NULL, NULL, NULL);
- g_main_loop_run (result.loop);
- g_assert_no_error (result.error);
+ tp_tests_proxy_run_until_prepared (f->client_conn, feature_connected);
g_assert_cmpint (tp_connection_get_contact_list_state (f->client_conn), ==,
TP_CONTACT_LIST_STATE_SUCCESS);
@@ -2832,6 +2833,7 @@ message_filter (DBusConnection *connection,
dbus_message_get_path (msg), TP_IFACE_CHANNEL_INTERFACE_GROUP,
TP_HANDLE_TYPE_LIST, 0, NULL);
tp_proxy_prepare_async (channel, NULL, channel_prepared_cb, closure);
+ g_object_unref (channel);
/* Extract the number of added handles */
dbus_message_iter_init (msg, &iter);
@@ -2855,6 +2857,7 @@ test_initial_contact_list (Fixture *f,
gconstpointer unused G_GNUC_UNUSED)
{
const GQuark conn_features[] = { TP_CONNECTION_FEATURE_CONTACT_LIST, 0 };
+ const GQuark feature_connected[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 };
TpTestsContactListManager *manager;
MembersChangedClosure closure;
DBusConnection *dbus_connection;
@@ -2902,7 +2905,7 @@ test_initial_contact_list (Fixture *f,
tp_cli_connection_call_connect (f->client_conn, -1,
NULL, NULL, NULL, NULL);
- g_main_loop_run (closure.loop);
+ tp_tests_proxy_run_until_prepared (f->client_conn, feature_connected);
dbus_bus_remove_match (dbus_connection, MEMBERS_CHANGED_MATCH_RULE, NULL);
dbus_connection_remove_filter (dbus_connection, message_filter, &closure);
@@ -2974,9 +2977,16 @@ teardown (Fixture *f,
gconstpointer unused G_GNUC_UNUSED)
{
if (f->client_conn != NULL)
- tp_tests_connection_assert_disconnect_succeeds (f->client_conn);
+ {
+ TpConnection *conn = f->client_conn;
+
+ g_object_add_weak_pointer ((GObject *) conn, (gpointer *) &conn);
+ tp_tests_connection_assert_disconnect_succeeds (conn);
+ g_object_unref (conn);
+ g_assert (conn == NULL);
+ f->client_conn = NULL;
+ }
- tp_clear_object (&f->client_conn);
f->service_repo = NULL;
tp_clear_object (&f->service_conn);
tp_clear_object (&f->base_connection);
diff --git a/tests/lib/simple-account.c b/tests/lib/simple-account.c
index 6279d7559..dc0912057 100644
--- a/tests/lib/simple-account.c
+++ b/tests/lib/simple-account.c
@@ -80,6 +80,7 @@ struct _TpTestsSimpleAccountPrivate
gchar *presence_msg;
gchar *connection_path;
gboolean enabled;
+ GPtrArray *uri_schemes;
};
static void
@@ -122,10 +123,14 @@ account_iface_init (gpointer klass,
#undef IMPLEMENT
}
+/* you may have noticed this is not entirely realistic */
+static const gchar * const uri_schemes[] = { "about", "telnet", NULL };
static void
tp_tests_simple_account_init (TpTestsSimpleAccount *self)
{
+ guint i;
+
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TESTS_TYPE_SIMPLE_ACCOUNT,
TpTestsSimpleAccountPrivate);
@@ -134,10 +139,11 @@ tp_tests_simple_account_init (TpTestsSimpleAccount *self)
self->priv->presence_msg = g_strdup ("this is my CurrentPresence");
self->priv->connection_path = g_strdup ("/");
self->priv->enabled = TRUE;
-}
-/* you may have noticed this is not entirely realistic */
-static const gchar * const uri_schemes[] = { "about", "telnet", NULL };
+ self->priv->uri_schemes = g_ptr_array_new_with_free_func (g_free);
+ for (i = 0; uri_schemes[i] != NULL; i++)
+ g_ptr_array_add (self->priv->uri_schemes, g_strdup (uri_schemes[i]));
+}
static void
tp_tests_simple_account_get_property (GObject *object,
@@ -231,7 +237,19 @@ tp_tests_simple_account_get_property (GObject *object,
TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS);
break;
case PROP_URI_SCHEMES:
- g_value_set_boxed (value, uri_schemes);
+ {
+ GPtrArray *arr;
+ guint i;
+
+ arr = g_ptr_array_sized_new (self->priv->uri_schemes->len + 1);
+ for (i = 0; i < self->priv->uri_schemes->len; i++)
+ g_ptr_array_add (arr,
+ g_ptr_array_index (self->priv->uri_schemes, i));
+ g_ptr_array_add (arr, NULL);
+
+ g_value_set_boxed (value, arr->pdata);
+ g_ptr_array_unref (arr);
+ }
break;
case PROP_AVATAR:
{
@@ -274,6 +292,8 @@ tp_tests_simple_account_finalize (GObject *object)
g_free (self->priv->presence_msg);
g_free (self->priv->connection_path);
+ g_ptr_array_unref (self->priv->uri_schemes);
+
G_OBJECT_CLASS (tp_tests_simple_account_parent_class)->finalize (object);
}
@@ -578,3 +598,25 @@ tp_tests_simple_account_set_enabled (TpTestsSimpleAccount *self,
tp_svc_account_emit_account_property_changed (self, change);
g_hash_table_unref (change);
}
+
+void
+tp_tests_simple_account_add_uri_scheme (TpTestsSimpleAccount *self,
+ const gchar *uri_scheme)
+{
+ GHashTable *changed;
+ GStrv schemes;
+
+ g_ptr_array_add (self->priv->uri_schemes, g_strdup (uri_scheme));
+
+ g_object_get (self, "uri-schemes", &schemes, NULL);
+
+ changed = tp_asv_new (
+ "URISchemes", G_TYPE_STRV, schemes,
+ NULL);
+
+ tp_svc_dbus_properties_emit_properties_changed (self,
+ TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING, changed, NULL);
+
+ g_strfreev (schemes);
+ g_hash_table_unref (changed);
+}
diff --git a/tests/lib/simple-account.h b/tests/lib/simple-account.h
index 2ce3efd12..b8547bd75 100644
--- a/tests/lib/simple-account.h
+++ b/tests/lib/simple-account.h
@@ -64,6 +64,9 @@ void tp_tests_simple_account_removed (TpTestsSimpleAccount *self);
void tp_tests_simple_account_set_enabled (TpTestsSimpleAccount *self,
gboolean enabled);
+void tp_tests_simple_account_add_uri_scheme (TpTestsSimpleAccount *self,
+ const gchar * uri_scheme);
+
G_END_DECLS
#endif /* #ifndef __TP_TESTS_SIMPLE_ACCOUNT_H__ */
diff --git a/tests/util-cxx.cpp b/tests/util-cxx.cpp
index 308ac640c..3b2a6b577 100644
--- a/tests/util-cxx.cpp
+++ b/tests/util-cxx.cpp
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "config.h"
+
#include <glib.h>
#include <gio/gio.h>
#include <telepathy-glib/util.h>