diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-01-22 17:38:38 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-01-23 14:43:05 +0100 |
commit | 3a2b4dc767c7c90e257a644e00b385ed06c87a92 (patch) | |
tree | d37a47cd890a87d055e66a83b999444cee0f576c | |
parent | 78c4725aaa8e5321e98261e278e46048bd4b9052 (diff) |
Observer and NewChannel are now singular
38 files changed, 318 insertions, 389 deletions
diff --git a/mission-control-plugins/dispatch-operation.c b/mission-control-plugins/dispatch-operation.c index da8a4de5..97bf7806 100644 --- a/mission-control-plugins/dispatch-operation.c +++ b/mission-control-plugins/dispatch-operation.c @@ -248,7 +248,7 @@ mcp_dispatch_operation_ref_nth_channel_properties (McpDispatchOperation *self, * mcp_dispatch_operation_end_delay() exactly once, at which point dispatching * will continue and the token becomes invalid. * - * This is similar to an Observer delaying the return from ObserveChannels, + * This is similar to an Observer delaying the return from ObserveChannel, * except that there is no time limit - a dispatch operation policy plugin * can delay the dispatch operation indefinitely. * diff --git a/src/mcd-client.c b/src/mcd-client.c index 54db916f..b36cf301 100644 --- a/src/mcd-client.c +++ b/src/mcd-client.c @@ -587,8 +587,8 @@ _mcd_client_recover_observer (McdClientProxy *self, TpChannel *channel, GPtrArray *satisfied_requests; GHashTable *observer_info; TpConnection *conn; - const gchar *connection_path; - GPtrArray *channels_array; + const gchar *connection_path, *chan_path; + GHashTable *chan_props; satisfied_requests = g_ptr_array_new (); observer_info = g_hash_table_new (g_str_hash, g_str_equal); @@ -597,22 +597,23 @@ _mcd_client_recover_observer (McdClientProxy *self, TpChannel *channel, TP_HASH_TYPE_OBJECT_IMMUTABLE_PROPERTIES_MAP, g_hash_table_new (NULL, NULL)); - channels_array = _mcd_tp_channel_details_build_from_tp_chan (channel); conn = tp_channel_get_connection (channel); connection_path = tp_proxy_get_object_path (conn); + chan_path = tp_proxy_get_object_path (channel); + chan_props = _mcd_tp_channel_dup_immutable_properties_asv (channel); - DEBUG ("calling ObserveChannels on %s for channel %p", + DEBUG ("calling ObserveChannel on %s for channel %p", tp_proxy_get_bus_name (self), channel); - tp_cli_client_observer_call_observe_channels ( + tp_cli_client_observer_call_observe_channel ( (TpClient *) self, -1, account_path, - connection_path, channels_array, + connection_path, chan_path, chan_props, "/", satisfied_requests, observer_info, NULL, NULL, NULL, NULL); - _mcd_tp_channel_details_free (channels_array); g_ptr_array_unref (satisfied_requests); g_hash_table_unref (observer_info); + g_hash_table_unref (chan_props); } static void @@ -963,7 +964,7 @@ mcd_client_proxy_unique_name_cb (TpDBusDaemon *dbus_daemon, _mcd_client_proxy_set_inactive (self); /* To recover activatable Observers, we just need to call - * ObserveChannels on them. */ + * ObserveChannel on them. */ should_recover = self->priv->recover && self->priv->activatable; } else diff --git a/src/mcd-connection.c b/src/mcd-connection.c index 0d941f4b..e2b60dd6 100644 --- a/src/mcd-connection.c +++ b/src/mcd-connection.c @@ -110,7 +110,7 @@ struct _McdConnectionPrivate /* FALSE until the dispatcher has said it's ready for us */ guint dispatching_started : 1; - /* FALSE until channels announced by NewChannel/NewChannels need to be + /* FALSE until channels announced by NewChannel need to be * dispatched */ guint dispatched_initial_channels : 1; @@ -816,34 +816,34 @@ static gboolean mcd_connection_need_dispatch (McdConnection *connection, GHashTable *props); static void -on_new_channels (TpConnection *proxy, const GPtrArray *channels, - gpointer user_data, GObject *weak_object) +on_new_channel (TpConnection *proxy, + const gchar *object_path, + GHashTable *props, + gpointer user_data, + GObject *weak_object) { McdConnection *connection = MCD_CONNECTION (weak_object); McdConnectionPrivate *priv = user_data; - guint i; + GValue *value; + gboolean requested = FALSE; + gboolean only_observe = FALSE; + McdChannel *channel; if (DEBUGGING) { - for (i = 0; i < channels->len; i++) - { - GValueArray *va = g_ptr_array_index (channels, i); - const gchar *object_path = g_value_get_boxed (va->values); - GHashTable *props = g_value_get_boxed (va->values + 1); - GHashTableIter iter; - gpointer k, v; + GHashTableIter iter; + gpointer k, v; - DEBUG ("%s", object_path); + DEBUG ("%s", object_path); - g_hash_table_iter_init (&iter, props); + g_hash_table_iter_init (&iter, props); - while (g_hash_table_iter_next (&iter, &k, &v)) - { - gchar *repr = g_strdup_value_contents (v); + while (g_hash_table_iter_next (&iter, &k, &v)) + { + gchar *repr = g_strdup_value_contents (v); - DEBUG(" \"%s\" => %s", (const gchar *) k, repr); - g_free (repr); - } + DEBUG(" \"%s\" => %s", (const gchar *) k, repr); + g_free (repr); } } @@ -851,51 +851,38 @@ on_new_channels (TpConnection *proxy, const GPtrArray *channels, * FALSE: they'll also be in Channels in the GetAll(Requests) result */ if (!priv->dispatched_initial_channels) return; - sp_timestamp ("NewChannels received"); - for (i = 0; i < channels->len; i++) - { - GValueArray *va; - const gchar *object_path; - GHashTable *props; - GValue *value; - gboolean requested = FALSE; - gboolean only_observe = FALSE; - McdChannel *channel; - - va = g_ptr_array_index (channels, i); - object_path = g_value_get_boxed (va->values); - props = g_value_get_boxed (va->values + 1); + sp_timestamp ("NewChannel received"); - only_observe = !mcd_connection_need_dispatch (connection, object_path, - props); + only_observe = !mcd_connection_need_dispatch (connection, object_path, + props); - /* Don't do anything for requested channels */ - value = g_hash_table_lookup (props, TP_IFACE_CHANNEL ".Requested"); - if (value && g_value_get_boolean (value)) - requested = TRUE; + /* Don't do anything for requested channels */ + value = g_hash_table_lookup (props, TP_IFACE_CHANNEL ".Requested"); + if (value && g_value_get_boolean (value)) + requested = TRUE; - /* if the channel was a request, we already have an object for it; - * otherwise, create a new one */ - channel = mcd_connection_find_channel_by_path (connection, object_path); - if (!channel) - { - channel = mcd_channel_new_from_properties (proxy, object_path, - props); - if (G_UNLIKELY (!channel)) continue; + /* if the channel was a request, we already have an object for it; + * otherwise, create a new one */ + channel = mcd_connection_find_channel_by_path (connection, object_path); + if (!channel) + { + channel = mcd_channel_new_from_properties (proxy, object_path, + props); + if (G_UNLIKELY (!channel)) + return; - mcd_operation_take_mission (MCD_OPERATION (connection), - MCD_MISSION (channel)); - } + mcd_operation_take_mission (MCD_OPERATION (connection), + MCD_MISSION (channel)); + } - if (!requested) - { - /* we always dispatch unrequested (incoming) channels */ - only_observe = FALSE; - } + if (!requested) + { + /* we always dispatch unrequested (incoming) channels */ + only_observe = FALSE; + } - _mcd_dispatcher_add_channel (priv->dispatcher, channel, requested, + _mcd_dispatcher_add_channel (priv->dispatcher, channel, requested, only_observe); - } } static void @@ -1031,13 +1018,13 @@ mcd_connection_setup_requests (McdConnection *connection) McdConnectionPrivate *priv = connection->priv; /* - * 1. connect to the NewChannels + * 1. connect to the NewChannel * 2. get existing channels * 3. disconnect from NewChannel * 4. dispatch the UNDISPATCHED */ - tp_cli_connection_interface_requests_connect_to_new_channels - (priv->tp_conn, on_new_channels, priv, NULL, + tp_cli_connection_interface_requests_connect_to_new_channel + (priv->tp_conn, on_new_channel, priv, NULL, (GObject *)connection, NULL); tp_cli_dbus_properties_call_get_all (priv->tp_conn, -1, @@ -1701,7 +1688,7 @@ _mcd_connection_get_property (GObject * obj, guint prop_id, * @object_path: the object path of the new channel (only for debugging) * @props: the properties of the new channel * - * This functions must be called in response to a NewChannels signals, and is + * This functions must be called in response to a NewChannel signals, and is * responsible for deciding whether MC must handle the channels or not. */ static gboolean @@ -1940,7 +1927,7 @@ common_request_channel_cb (TpConnection *proxy, gboolean yours, } /* No dispatching here: the channel will be dispatched upon receiving the - * NewChannels signal */ + * NewChannel signal */ } static void diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c index e2aae21e..f6a8a132 100644 --- a/src/mcd-dispatch-operation.c +++ b/src/mcd-dispatch-operation.c @@ -217,7 +217,7 @@ struct _McdDispatchOperationPrivate gboolean invoked_observers_if_needed; gboolean invoked_approvers_if_needed; - /* The number of observers that have not yet returned from ObserveChannels. + /* The number of observers that have not yet returned from ObserveChannel. * Until they have done so, we can't allow the dispatch operation to * finish. This is a client lock. * @@ -1987,9 +1987,9 @@ _mcd_dispatch_operation_run_observers (McdDispatchOperation *self) { McdClientProxy *client = MCD_CLIENT_PROXY (client_p); gboolean observed = FALSE; - const gchar *account_path, *connection_path; - GPtrArray *channels_array, *satisfied_requests; - GHashTable *request_properties; + const gchar *account_path, *connection_path, *chan_path; + GPtrArray *satisfied_requests; + GHashTable *request_properties, *chan_props; if (!tp_proxy_has_interface_by_id (client, TP_IFACE_QUARK_CLIENT_OBSERVER)) @@ -2018,11 +2018,8 @@ _mcd_dispatch_operation_run_observers (McdDispatchOperation *self) connection_path = _mcd_dispatch_operation_get_connection_path (self); account_path = _mcd_dispatch_operation_get_account_path (self); - - /* TODO: there's room for optimization here: reuse the channels_array, - * if the observed list is the same */ - channels_array = _mcd_tp_channel_details_build_from_tp_chan ( - mcd_channel_get_tp_channel (self->priv->channel)); + chan_path = mcd_channel_get_object_path (self->priv->channel); + chan_props = mcd_channel_dup_immutable_properties_asv (self->priv->channel); collect_satisfied_requests (self->priv->channel, &satisfied_requests, &request_properties); @@ -2040,18 +2037,17 @@ _mcd_dispatch_operation_run_observers (McdDispatchOperation *self) _mcd_dispatch_operation_inc_observers_pending (self, client); - DEBUG ("calling ObserveChannels on %s for CDO %p", + DEBUG ("calling ObserveChannel on %s for CDO %p", tp_proxy_get_bus_name (client), self); - tp_cli_client_observer_call_observe_channels ( + tp_cli_client_observer_call_observe_channel ( (TpClient *) client, -1, - account_path, connection_path, channels_array, + account_path, connection_path, chan_path, chan_props, dispatch_operation_path, satisfied_requests, observer_info, observe_channels_cb, g_object_ref (self), g_object_unref, NULL); g_ptr_array_unref (satisfied_requests); - - _mcd_tp_channel_details_free (channels_array); + g_hash_table_unref (chan_props); } g_hash_table_unref (observer_info); diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c index e6827a90..07313400 100644 --- a/src/mcd-dispatcher.c +++ b/src/mcd-dispatcher.c @@ -936,7 +936,7 @@ _mcd_dispatcher_add_channel (McdDispatcher *dispatcher, g_return_if_fail (requested); /* these channels were requested "behind our back", so only call - * ObserveChannels on them */ + * ObserveChannel on them */ _mcd_dispatcher_enter_state_machine (dispatcher, channel, NULL, TRUE, TRUE); return; diff --git a/tests/twisted/account-requests/create-text.py b/tests/twisted/account-requests/create-text.py index 3ef1a486..a79299d2 100644 --- a/tests/twisted/account-requests/create-text.py +++ b/tests/twisted/account-requests/create-text.py @@ -134,16 +134,14 @@ def test_channel_creation(q, bus, account, client, conn, ensure): # Observer should get told, processing waits for it e = q.expect('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == '/', e.args # no dispatch operation - assert e.args[4] == [request_path], e.args - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == channel.object_path, channels - assert channels[0][1] == channel_immutable, channels + assert e.args[2] == channel.object_path, e.args.object_path + assert e.args[3] == channel_immutable, e.args + assert e.args[4] == '/', e.args # no dispatch operation + assert e.args[5] == [request_path], e.args # Observer says "OK, go" q.dbus_return(e.message, signature='') diff --git a/tests/twisted/crash-recovery/crash-recovery.py b/tests/twisted/crash-recovery/crash-recovery.py index a6963e59..432082a0 100644 --- a/tests/twisted/crash-recovery/crash-recovery.py +++ b/tests/twisted/crash-recovery/crash-recovery.py @@ -106,13 +106,13 @@ def test(q, bus, unused, **kwargs): e, = mc.wait_for_names( EventPattern('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[1] == conn.object_path, e.args - channels = e.args[2] - assert channels[0][0] == unhandled_chan.object_path, channels + chan_path = e.args[2] + assert chan_path == unhandled_chan.object_path, e.args q.dbus_return(e.message, signature='') # ... and as a handler diff --git a/tests/twisted/dispatcher/already-has-channel.py b/tests/twisted/dispatcher/already-has-channel.py index 8e64b988..211da3d2 100644 --- a/tests/twisted/dispatcher/already-has-channel.py +++ b/tests/twisted/dispatcher/already-has-channel.py @@ -139,21 +139,19 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, chan.object_path + assert e.args[3] == channel_properties, channel_properties + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied assert k.args == e.args diff --git a/tests/twisted/dispatcher/approver-fails.py b/tests/twisted/dispatcher/approver-fails.py index ef49f560..a09ddf91 100644 --- a/tests/twisted/dispatcher/approver-fails.py +++ b/tests/twisted/dispatcher/approver-fails.py @@ -108,16 +108,15 @@ def test(q, bus, mc): e = q.expect('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, chan.object_path + assert e.args[3] == channel_properties, channel_properties + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied + q.dbus_return(e.message, bus=empathy_bus, signature='') diff --git a/tests/twisted/dispatcher/bypass-approval.py b/tests/twisted/dispatcher/bypass-approval.py index 0bef1f64..97a9c6ab 100644 --- a/tests/twisted/dispatcher/bypass-approval.py +++ b/tests/twisted/dispatcher/bypass-approval.py @@ -109,21 +109,19 @@ def announce_common(q, bus, empathy, kopete, account, conn, cd_props, e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, chan.object_path + assert e.args[3] == channel_properties, channel_properties + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied assert k.args == e.args diff --git a/tests/twisted/dispatcher/capture-bundle.py b/tests/twisted/dispatcher/capture-bundle.py index 5da029ef..dc4b034a 100644 --- a/tests/twisted/dispatcher/capture-bundle.py +++ b/tests/twisted/dispatcher/capture-bundle.py @@ -118,21 +118,19 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, chan.object_path + assert e.args[3] == channel_properties, channel_properties + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied assert k.args == e.args @@ -248,21 +246,19 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, chan.object_path + assert e.args[3] == channel_properties, channel_properties + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied assert k.args == e.args diff --git a/tests/twisted/dispatcher/cdo-claim.py b/tests/twisted/dispatcher/cdo-claim.py index 01d94101..9d109b0b 100644 --- a/tests/twisted/dispatcher/cdo-claim.py +++ b/tests/twisted/dispatcher/cdo-claim.py @@ -74,7 +74,7 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=logger.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=gs.object_path, @@ -117,7 +117,7 @@ def test(q, bus, mc): # Logger recovers the channel e = q.expect('dbus-method-call', path=logger.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) # gnome-shell which is handling the channel asks to re-ensure it diff --git a/tests/twisted/dispatcher/create-at-startup.py b/tests/twisted/dispatcher/create-at-startup.py index 72c2198c..b74d6ddc 100644 --- a/tests/twisted/dispatcher/create-at-startup.py +++ b/tests/twisted/dispatcher/create-at-startup.py @@ -168,21 +168,18 @@ def test(q, bus, unused, **kwargs): path=conn.object_path, handled=True), EventPattern('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', interface=cs.CONN_IFACE_REQUESTS, method='CreateChannel', path=conn.object_path, args=[request], handled=False), ) - assert a.args[0] == account.object_path, a.args assert a.args[1] == conn.object_path, a.args - assert a.args[3] != '/', a.args # there is a dispatch operation - assert a.args[4] == [], a.args - channels = a.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == announcement.object_path, channels - assert channels[0][1] == announcement_immutable, channels + assert a.args[2] == announcement.object_path, channels + assert a.args[3] == announcement_immutable, channels + assert a.args[4] != '/', a.args # there is a dispatch operation + assert a.args[5] == [], e.args # no requests satisfied # Time passes. A channel is returned. @@ -203,17 +200,14 @@ def test(q, bus, unused, **kwargs): # Empathy observes the newly-created channel. e = q.expect('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == '/', e.args # no dispatch operation - assert e.args[4] == [request_path], e.args - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == channel.object_path, channels - assert channels[0][1] == channel_immutable, channels + assert e.args[2] == channel.object_path, channel.object_path + assert e.args[3] == channel_immutable, channel_immutable + assert e.args[4] == '/', e.args # no dispatch operation # Observer says "OK, go" q.dbus_return(a.message, signature='') diff --git a/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py b/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py index 1c91eb88..1d675546 100644 --- a/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py +++ b/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py @@ -105,7 +105,7 @@ def test(q, bus, mc): forbidden = [ EventPattern('dbus-method-call', method='CreateChannel'), EventPattern('dbus-method-call', method='EnsureChannel'), - EventPattern('dbus-method-call', method='ObserveChannels'), + EventPattern('dbus-method-call', method='ObserveChannel'), EventPattern('dbus-method-call', method='AddDispatchOperation'), EventPattern('dbus-method-call', method='HandleChannel'), ] diff --git a/tests/twisted/dispatcher/create-handler-fails.py b/tests/twisted/dispatcher/create-handler-fails.py index cc1eeea2..ac8e00ea 100644 --- a/tests/twisted/dispatcher/create-handler-fails.py +++ b/tests/twisted/dispatcher/create-handler-fails.py @@ -139,16 +139,14 @@ def test_channel_creation(q, bus, account, client, conn, ensure): # Observer should get told, processing waits for it e = q.expect('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == '/', e.args # no dispatch operation - assert e.args[4] == [request_path], e.args - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == channel.object_path, channels - assert channels[0][1] == channel_immutable, channels + assert e.args[2] == channel.object_path, channel.object_path + assert e.args[3] == channel_immutable, channel_immutable + assert e.args[4] == '/', e.args # no dispatch operation + assert e.args[5] == [request_path], e.args # Observer says "OK, go" q.dbus_return(e.message, signature='') diff --git a/tests/twisted/dispatcher/create-hints.py b/tests/twisted/dispatcher/create-hints.py index 2e6fb557..6c2b9f42 100644 --- a/tests/twisted/dispatcher/create-hints.py +++ b/tests/twisted/dispatcher/create-hints.py @@ -141,17 +141,15 @@ def test_channel_creation(q, bus, account, client, conn, # Observer should get told, processing waits for it e = q.expect('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == '/', e.args # no dispatch operation - assert e.args[4] == [request_path], e.args - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == channel.object_path, channels - assert channels[0][1] == channel_immutable, channels - info = e.args[5] + assert e.args[2] == channel.object_path, channel.object_path + assert e.args[3] == channel_immutable, channel_immutable + assert e.args[4] == '/', e.args # no dispatch operation + assert e.args[5] == [request_path], e.args # no requests satisfied + info = e.args[6] assert info['request-properties'] == {request_path: request_props}, info # Observer says "OK, go" diff --git a/tests/twisted/dispatcher/create-no-preferred-handler.py b/tests/twisted/dispatcher/create-no-preferred-handler.py index e433a555..954d95f7 100644 --- a/tests/twisted/dispatcher/create-no-preferred-handler.py +++ b/tests/twisted/dispatcher/create-no-preferred-handler.py @@ -145,16 +145,14 @@ def test_channel_creation(q, bus, account, client, conn, ensure): # Observer should get told, processing waits for it e = q.expect('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == '/', e.args # no dispatch operation - assert e.args[4] == [request_path], e.args - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == channel.object_path, channels - assert channels[0][1] == channel_immutable, channels + assert e.args[2] == channel.object_path, channel.object_path + assert e.args[3] == channel_immutable, channel_immutable + assert e.args[4] == '/', e.args # no dispatch operation + assert e.args[5] == [request_path], e.args # Observer says "OK, go" q.dbus_return(e.message, signature='') diff --git a/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py b/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py index fb09df45..427f21fc 100644 --- a/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py +++ b/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py @@ -39,7 +39,7 @@ def test(q, bus, mc): forbidden = [ EventPattern('dbus-method-call', method='CreateChannel'), EventPattern('dbus-method-call', method='EnsureChannel'), - EventPattern('dbus-method-call', method='ObserveChannels'), + EventPattern('dbus-method-call', method='ObserveChannel'), EventPattern('dbus-method-call', method='AddDispatchOperation'), EventPattern('dbus-method-call', method='HandleChannel'), ] diff --git a/tests/twisted/dispatcher/create-text.py b/tests/twisted/dispatcher/create-text.py index 43001968..56923e6e 100644 --- a/tests/twisted/dispatcher/create-text.py +++ b/tests/twisted/dispatcher/create-text.py @@ -160,16 +160,15 @@ def test_channel_creation(q, bus, account, client, conn, # Observer should get told, processing waits for it e = q.expect('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == '/', e.args # no dispatch operation - assert e.args[4] == [request_path], e.args - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == channel.object_path, channels - assert channels[0][1] == channel_immutable, channels + assert e.args[2] == channel.object_path, channel.object_path + assert e.args[3] == channel_immutable, channel_immutable + assert e.args[4] == '/', e.args # no dispatch operation + assert e.args[5] == [request_path], e.args + # Observer says "OK, go" q.dbus_return(e.message, signature='') diff --git a/tests/twisted/dispatcher/created-behind-our-back.py b/tests/twisted/dispatcher/created-behind-our-back.py index b1e03517..d768c099 100644 --- a/tests/twisted/dispatcher/created-behind-our-back.py +++ b/tests/twisted/dispatcher/created-behind-our-back.py @@ -78,21 +78,19 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == '/', e.args # no dispatch operation - assert e.args[4] == [], e.args - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == channel.object_path, channels - assert channels[0][1] == channel_immutable, channels + assert e.args[2] == channel.object_path, channel.object_path + assert e.args[3] == channel_immutable, channel_immutable + assert e.args[4] == '/', e.args # no dispatch operation + assert e.args[5] == [], e.args # no requests satisfied assert e.args == k.args diff --git a/tests/twisted/dispatcher/delay-approvers.py b/tests/twisted/dispatcher/delay-approvers.py index cf278d85..be11acc7 100644 --- a/tests/twisted/dispatcher/delay-approvers.py +++ b/tests/twisted/dispatcher/delay-approvers.py @@ -85,7 +85,7 @@ def test(q, bus, mc): # Empathy, the observer, gets the channel to observe. Because it # has DelayApprovers=TRUE, Kopete should not have # AddDispatchOperation called on it until Empathy returns from - # ObserveChannels. + # ObserveChannel. forbidden = [EventPattern('dbus-method-call', path=kopete.object_path, interface=cs.APPROVER, method='AddDispatchOperation')] @@ -93,7 +93,7 @@ def test(q, bus, mc): o = q.expect('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) # Waste a little time here and there. We can't call sync_dbus @@ -102,7 +102,7 @@ def test(q, bus, mc): call_async(q, cd_props, 'Get', cs.CD_IFACE_OP_LIST, 'DispatchOperations') event = q.expect('dbus-return', method='Get') - # Finally return from ObserveChannels, so now we expect ADO to be + # Finally return from ObserveChannel, so now we expect ADO to be # called on Kopete. q.dbus_return(o.message, bus=bus, signature='') q.unforbid_events(forbidden) diff --git a/tests/twisted/dispatcher/delay-then-call-handle-with.py b/tests/twisted/dispatcher/delay-then-call-handle-with.py index 62fc6989..f0a05afb 100644 --- a/tests/twisted/dispatcher/delay-then-call-handle-with.py +++ b/tests/twisted/dispatcher/delay-then-call-handle-with.py @@ -85,7 +85,7 @@ def test(q, bus, mc): # Empathy, the observer, gets the channel to observe. Because it # has DelayApprovers=TRUE, Kopete should not have # AddDispatchOperation called on it until Empathy returns from - # ObserveChannels, but Empathy will call HandleWith(Kopete) on the + # ObserveChannel, but Empathy will call HandleWith(Kopete) on the # CDO so we should ensure ADO is never called on any approver. forbidden = [EventPattern('dbus-method-call', interface=cs.APPROVER, method='AddDispatchOperation')] @@ -93,7 +93,7 @@ def test(q, bus, mc): o = q.expect('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) # Waste a little time here and there. We can't call sync_dbus @@ -106,7 +106,7 @@ def test(q, bus, mc): # HandleChannel returns. call_async(q, cdo_iface, 'HandleWith', cs.CLIENT + '.Kopete', 0) - # Finally return from ObserveChannels. + # Finally return from ObserveChannel. q.dbus_return(o.message, bus=bus, signature='') h = q.expect('dbus-method-call', diff --git a/tests/twisted/dispatcher/delay-then-dont-call-approvers.py b/tests/twisted/dispatcher/delay-then-dont-call-approvers.py index 27c26363..b30377e3 100644 --- a/tests/twisted/dispatcher/delay-then-dont-call-approvers.py +++ b/tests/twisted/dispatcher/delay-then-dont-call-approvers.py @@ -85,7 +85,7 @@ def test(q, bus, mc): # Empathy, the observer, gets the channel to observe. Because it # has DelayApprovers=TRUE, Kopete should not have # AddDispatchOperation called on it until Empathy returns from - # ObserveChannels, but Empathy will call Claim on the CDO so we + # ObserveChannel, but Empathy will call Claim on the CDO so we # should ensure neither ADO or HC is called on any of our clients. forbidden = [EventPattern('dbus-method-call', interface=cs.APPROVER, method='AddDispatchOperation'), @@ -95,7 +95,7 @@ def test(q, bus, mc): o = q.expect('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) # Waste a little time here and there. We can't call sync_dbus @@ -105,10 +105,10 @@ def test(q, bus, mc): event = q.expect('dbus-return', method='Get') # We can't call this synchronously because MC won't return until - # ObserveChannels calls return. + # ObserveChannel calls return. call_async(q, cdo_iface, 'Claim') - # Finally return from ObserveChannels. + # Finally return from ObserveChannel. q.dbus_return(o.message, bus=bus, signature='') q.expect('dbus-return', method='Claim') diff --git a/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py b/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py index 33f4f1a1..c4d4d687 100644 --- a/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py +++ b/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py @@ -74,11 +74,11 @@ def signal_channel_expect_query(q, bus, account, conn, empathy, kopete): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) diff --git a/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py b/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py index 0eb11d01..3f79f1c4 100644 --- a/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py +++ b/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py @@ -107,7 +107,7 @@ def test(q, bus, mc): cs.tp_name_prefix + '.Client.Kopete'], handlers # The plugin realises we've been rickrolled, and responds. It calls Destroy - # even though neither Empathy nor Kopete has returned from ObserveChannels + # even though neither Empathy nor Kopete has returned from ObserveChannel # yet destruction, e, k = q.expect_many( EventPattern('dbus-method-call', @@ -116,11 +116,11 @@ def test(q, bus, mc): args=[], handled=False), EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) # treat the destruction like Close @@ -182,11 +182,11 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) diff --git a/tests/twisted/dispatcher/dispatch-text.py b/tests/twisted/dispatcher/dispatch-text.py index 2d9438d2..c0261410 100644 --- a/tests/twisted/dispatcher/dispatch-text.py +++ b/tests/twisted/dispatcher/dispatch-text.py @@ -120,21 +120,19 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, e.args + assert e.args[3] == channel_properties, e.args + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied assert k.args == e.args @@ -251,21 +249,19 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, e.args + assert e.args[3] == channel_properties, e.args + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied assert k.args == e.args @@ -374,21 +370,19 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == claimed_chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == claimed_chan.object_path, e.args + assert e.args[3] == channel_properties, e.args + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied assert k.args == e.args @@ -471,11 +465,11 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) q.dbus_return(k.message, bus=kopete_bus, signature='') diff --git a/tests/twisted/dispatcher/ensure-and-redispatch.py b/tests/twisted/dispatcher/ensure-and-redispatch.py index ddda1ada..38a05edb 100644 --- a/tests/twisted/dispatcher/ensure-and-redispatch.py +++ b/tests/twisted/dispatcher/ensure-and-redispatch.py @@ -163,16 +163,14 @@ def test_channel_creation(q, bus, account, client, conn): # Observer should get told, processing waits for it e = q.expect('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == '/', e.args # no dispatch operation - assert e.args[4] == [request_path], e.args - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == channel.object_path, channels - assert channels[0][1] == channel_immutable, channels + assert e.args[2] == channel.object_path, e.args + assert e.args[3] == channel_immutable, e.args + assert e.args[4] == '/', e.args # no dispatch operation + assert e.args[5] == [request_path], e.args # Observer says "OK, go" q.dbus_return(e.message, signature='') @@ -207,7 +205,7 @@ def test_channel_redispatch(q, bus, account, client, conn, channel, forbidden = [ # Because we create no new channels, nothing should be observed. - EventPattern('dbus-method-call', method='ObserveChannels'), + EventPattern('dbus-method-call', method='ObserveChannel'), # Even though there is a better handler on a different unique # name, the channels must not be re-dispatched to it. EventPattern('dbus-method-call', method='HandleChannel', diff --git a/tests/twisted/dispatcher/ensure-is-approval.py b/tests/twisted/dispatcher/ensure-is-approval.py index 2ceea63a..d4945ff1 100644 --- a/tests/twisted/dispatcher/ensure-is-approval.py +++ b/tests/twisted/dispatcher/ensure-is-approval.py @@ -128,21 +128,20 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, e.args + assert e.args[3] == channel_properties, e.args + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied + assert k.args == e.args diff --git a/tests/twisted/dispatcher/ensure-rapidly.py b/tests/twisted/dispatcher/ensure-rapidly.py index 46b5eb11..f2909ff3 100644 --- a/tests/twisted/dispatcher/ensure-rapidly.py +++ b/tests/twisted/dispatcher/ensure-rapidly.py @@ -167,7 +167,7 @@ def test_channel_creation(q, bus, account, client, conn, conn.ensure_handle(cs.HT_CONTACT, 'juliet') channel = SimulatedChannel(conn, channel_immutable) - # Having announce() (i.e. NewChannels) come last is guaranteed by + # Having announce() (i.e. NewChannel) come last is guaranteed by # telepathy-spec (since 0.17.14). There is no other ordering guarantee. if swap_requests: @@ -185,17 +185,15 @@ def test_channel_creation(q, bus, account, client, conn, # Observer should get told, processing waits for it e = q.expect('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == '/', e.args # no dispatch operation - assert sorted(e.args[4]) == sorted([cr1.object_path, - cr2.object_path]), e.args - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == channel.object_path, channels - assert channels[0][1] == channel.immutable, channels + assert e.args[2] == channel.object_path, e.args + assert e.args[3] == channel.immutable, e.args + assert e.args[4] == '/', e.args # no dispatch operation + assert sorted(e.args[5]) == sorted([cr1.object_path, + cr2.object_path]), e.args[5] # Observer says "OK, go" q.dbus_return(e.message, signature='') diff --git a/tests/twisted/dispatcher/exploding-bundles.py b/tests/twisted/dispatcher/exploding-bundles.py index 9eaa6cf4..9fb7e240 100644 --- a/tests/twisted/dispatcher/exploding-bundles.py +++ b/tests/twisted/dispatcher/exploding-bundles.py @@ -105,7 +105,8 @@ def test(q, bus, mc): media_chan = SimulatedChannel(conn, media_channel_properties, destroyable=False) - conn.NewChannels([text_chan, media_chan]) + conn.NewChannel(text_chan) + conn.NewChannel(media_chan) # A channel dispatch operation is created for the Text channel first. @@ -135,25 +136,40 @@ def test(q, bus, mc): e_observe_text, k_observe_text = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e_observe_text.args[0] == account.object_path, e_observe_text.args assert e_observe_text.args[1] == conn.object_path, e_observe_text.args - assert e_observe_text.args[3] == text_cdo_path, e_observe_text.args - assert e_observe_text.args[4] == [], e_observe_text.args - channels = e_observe_text.args[2] - assert len(channels) == 1, channels - assert (text_chan.object_path, text_channel_properties) in channels + assert e_observe_text.args[2] == text_chan.object_path, e_observe_text.args + assert e_observe_text.args[3] == text_channel_properties, e_observe_text.args + assert e_observe_text.args[4] == text_cdo_path, e_observe_text.args + assert e_observe_text.args[5] == [], e_observe_text.args assert k_observe_text.args[0] == e_observe_text.args[0], k_observe_text.args assert k_observe_text.args[1] == e_observe_text.args[1], k_observe_text.args - assert (k_observe_text.args[2] == - [(text_chan.object_path, text_channel_properties)]) + assert k_observe_text.args[2] == text_chan.object_path, k_observe_text.args + assert k_observe_text.args[3] == text_channel_properties, k_observe_text.args + + e_approve_text, k_approve_text = q.expect_many( + EventPattern('dbus-method-call', + path=empathy.object_path, + interface=cs.APPROVER, method='AddDispatchOperation', + predicate=lambda e: e.args[0] == text_cdo_path, + handled=False), + EventPattern('dbus-method-call', + path=kopete.object_path, + interface=cs.APPROVER, method='AddDispatchOperation', + handled=False), + ) + + assertEquals(text_cdo_path, e_approve_text.args[0]) + assertEquals(text_cdo_properties, e_approve_text.args[1]) + assertEquals(k_approve_text.args, e_approve_text.args) # Now a separate CDO is created for the media channel. @@ -185,47 +201,29 @@ def test(q, bus, mc): e_observe_media = q.expect('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e_observe_media.args[0] == account.object_path, e_observe_media.args assert e_observe_media.args[1] == conn.object_path, e_observe_media.args - assert e_observe_media.args[3] == media_cdo_path, e_observe_media.args - assert e_observe_media.args[4] == [], e_observe_media.args - channels = e_observe_media.args[2] - assert len(channels) == 1, channels - assert (media_chan.object_path, media_channel_properties) in channels + assert e_observe_media.args[2] == media_chan.object_path, e_observe_media.args + assert e_observe_media.args[3] == media_channel_properties, e_observe_media.args + assert e_observe_media.args[4] == media_cdo_path, e_observe_media.args + assert e_observe_media.args[5] == [], e_observe_media.args - # All Observers reply. + e_approve_media = q.expect('dbus-method-call', + path=empathy.object_path, + interface=cs.APPROVER, method='AddDispatchOperation', + predicate=lambda e: e.args[0] == media_cdo_path, + handled=False) + assertEquals(media_cdo_path, e_approve_media.args[0]) + assertEquals(media_cdo_properties, e_approve_media.args[1]) + + # All Observers reply. q.dbus_return(e_observe_text.message, signature='') q.dbus_return(k_observe_text.message, signature='') q.dbus_return(e_observe_media.message, signature='') - # The Approvers are next - e_approve_text, k_approve_text, e_approve_media = q.expect_many( - EventPattern('dbus-method-call', - path=empathy.object_path, - interface=cs.APPROVER, method='AddDispatchOperation', - predicate=lambda e: e.args[0] == text_cdo_path, - handled=False), - EventPattern('dbus-method-call', - path=kopete.object_path, - interface=cs.APPROVER, method='AddDispatchOperation', - handled=False), - EventPattern('dbus-method-call', - path=empathy.object_path, - interface=cs.APPROVER, method='AddDispatchOperation', - predicate=lambda e: e.args[0] == media_cdo_path, - handled=False) - ) - - assertEquals(text_cdo_path, e_approve_text.args[0]) - assertEquals(text_cdo_properties, e_approve_text.args[1]) - assertEquals(k_approve_text.args, e_approve_text.args) - - assertEquals(media_cdo_path, e_approve_media.args[0]) - assertEquals(media_cdo_properties, e_approve_media.args[1]) - q.dbus_return(e_approve_text.message, signature='') q.dbus_return(k_approve_text.message, signature='') q.dbus_return(e_approve_media.message, signature='') @@ -313,7 +311,10 @@ def test(q, bus, mc): ext_chan = SimulatedChannel(conn, ext_channel_properties, destroyable=False) - conn.NewChannels([text_chan, media_chan, ext_chan, respawning_chan]) + conn.NewChannel(text_chan) + conn.NewChannel(media_chan) + conn.NewChannel(ext_chan) + conn.NewChannel(respawning_chan) # No client can handle all four channels, so the bundle explodes into # two dispatch operations and two failures. We can only match the first @@ -323,18 +324,18 @@ def test(q, bus, mc): _, _, _ = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', - predicate=(lambda e: e.args[2][0][0] == media_chan.object_path), + interface=cs.OBSERVER, method='ObserveChannel', + predicate=(lambda e: e.args[2] == media_chan.object_path), handled=False), EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', - predicate=(lambda e: e.args[2][0][0] == text_chan.object_path), + interface=cs.OBSERVER, method='ObserveChannel', + predicate=(lambda e: e.args[2] == text_chan.object_path), handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', - predicate=(lambda e: e.args[2][0][0] == text_chan.object_path), + interface=cs.OBSERVER, method='ObserveChannel', + predicate=(lambda e: e.args[2] == text_chan.object_path), handled=False), EventPattern('dbus-method-call', path=empathy.object_path, diff --git a/tests/twisted/dispatcher/handle-channels-fails.py b/tests/twisted/dispatcher/handle-channels-fails.py index 5497b49f..3b8e1597 100644 --- a/tests/twisted/dispatcher/handle-channels-fails.py +++ b/tests/twisted/dispatcher/handle-channels-fails.py @@ -121,16 +121,15 @@ def test(q, bus, mc): e = q.expect('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, e.args + assert e.args[3] == channel_properties, e.args + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied + q.dbus_return(e.message, bus=empathy_bus, signature='') diff --git a/tests/twisted/dispatcher/lose-text.py b/tests/twisted/dispatcher/lose-text.py index 5d9c7b2d..4aa73350 100644 --- a/tests/twisted/dispatcher/lose-text.py +++ b/tests/twisted/dispatcher/lose-text.py @@ -105,19 +105,17 @@ def test(q, bus, mc): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, e.args + assert e.args[3] == channel_properties, e.args assert k.args == e.args diff --git a/tests/twisted/dispatcher/recover-from-disconnect.py b/tests/twisted/dispatcher/recover-from-disconnect.py index 7754ec1a..21420bfd 100644 --- a/tests/twisted/dispatcher/recover-from-disconnect.py +++ b/tests/twisted/dispatcher/recover-from-disconnect.py @@ -199,21 +199,19 @@ def test_dispatching(q, bus, conn, account, empathy, kopete): e, k = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=kopete.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, e.args + assert e.args[3] == channel_properties, e.args + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied assert k.args == e.args diff --git a/tests/twisted/dispatcher/respawn-activatable-observers.py b/tests/twisted/dispatcher/respawn-activatable-observers.py index 4257386a..2db7c8c7 100644 --- a/tests/twisted/dispatcher/respawn-activatable-observers.py +++ b/tests/twisted/dispatcher/respawn-activatable-observers.py @@ -138,17 +138,15 @@ def test(q, bus, mc): # Logger is told about the new channel e = q.expect('dbus-method-call', path=logger.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, e.args + assert e.args[3] == channel_properties, e.args + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied # Logger indicates that it is ready to proceed q.dbus_return(e.message, bus=logger_bus, signature='') @@ -210,7 +208,7 @@ def test(q, bus, mc): e = q.expect('dbus-method-call', path=logger.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) # FIXME: assert the same things as before, except CDO (which we don't @@ -218,12 +216,10 @@ def test(q, bus, mc): # that the recovering observer info key is set assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - assert e.args[5]['recovering'] == 1, e.args # due to observer recovery - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, e.args + assert e.args[3] == channel_properties, e.args + assert e.args[5] == [], e.args # no requests satisfied + assert e.args[6]['recovering'] == 1, e.args # due to observer recovery # Logger indicates that it is ready to proceed q.dbus_return(e.message, bus=logger_bus, signature='') diff --git a/tests/twisted/dispatcher/respawn-observers.py b/tests/twisted/dispatcher/respawn-observers.py index 535226d1..a766a596 100644 --- a/tests/twisted/dispatcher/respawn-observers.py +++ b/tests/twisted/dispatcher/respawn-observers.py @@ -122,17 +122,15 @@ def test(q, bus, mc): e = q.expect('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e.args[2] == chan.object_path, e.args + assert e.args[3] == channel_properties, e.args + assert e.args[4] == cdo_path, e.args + assert e.args[5] == [], e.args # no requests satisfied # Empathy indicates that it is ready to proceed q.dbus_return(e.message, bus=empathy_bus, signature='') @@ -226,17 +224,15 @@ def test(q, bus, mc): e = q.expect('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) assert e.args[0] == account.object_path, e.args assert e.args[1] == conn.object_path, e.args - assert e.args[3] == cdo2_path, e.args - assert e.args[4] == [], e.args # no requests satisfied - channels = e.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan2.object_path, channels - assert channels[0][1] == channel2_properties, channels + assert e.args[2] == chan2.object_path, e.args + assert e.args[3] == channel2_properties, e.args + assert e.args[4] == cdo2_path, e.args + assert e.args[5] == [], e.args # no requests satisfied # Empathy indicates that it is ready to proceed q.dbus_return(e.message, bus=empathy_bus, signature='') @@ -277,33 +273,29 @@ def test(q, bus, mc): e1, e2 = q.expect_many( EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', - predicate=lambda e: e.args[2][0][0] == chan.object_path, + interface=cs.OBSERVER, method='ObserveChannel', + predicate=lambda e: e.args[2] == chan.object_path, handled=False), EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', - predicate=lambda e: e.args[2][0][0] == chan2.object_path, + interface=cs.OBSERVER, method='ObserveChannel', + predicate=lambda e: e.args[2] == chan2.object_path, handled=False), ) assert e1.args[0] == account.object_path, e1.args assert e1.args[1] == conn.object_path, e1.args - assert e1.args[4] == [], e1.args # no requests satisfied - assert e1.args[5]['recovering'] == 1, e1.args # due to observer recovery - channels = e1.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan.object_path, channels - assert channels[0][1] == channel_properties, channels + assert e1.args[2] == chan.object_path, e1.args + assert e1.args[3] == channel_properties, e1.args + assert e1.args[5] == [], e1.args # no requests satisfied + assert e1.args[6]['recovering'] == 1, e1.args # due to observer recovery assert e2.args[0] == account.object_path, e2.args assert e2.args[1] == conn.object_path, e2.args - assert e2.args[4] == [], e2.args # no requests satisfied - assert e2.args[5]['recovering'] == 1, e2.args # due to observer recovery - channels = e2.args[2] - assert len(channels) == 1, channels - assert channels[0][0] == chan2.object_path, channels - assert channels[0][1] == channel2_properties, channels + assert e2.args[2] == chan2.object_path, e1.args + assert e2.args[3] == channel2_properties, e1.args + assert e2.args[5] == [], e2.args # no requests satisfied + assert e2.args[6]['recovering'] == 1, e2.args # due to observer recovery # Empathy indicates that it is ready to proceed q.dbus_return(e1.message, bus=empathy_bus, signature='') diff --git a/tests/twisted/dispatcher/some-delay-approvers.py b/tests/twisted/dispatcher/some-delay-approvers.py index af5e2b97..4fb6c6d5 100644 --- a/tests/twisted/dispatcher/some-delay-approvers.py +++ b/tests/twisted/dispatcher/some-delay-approvers.py @@ -91,7 +91,7 @@ def test(q, bus, mc): # Empathy, the observer, gets the channel to observe. Because it # has DelayApprovers=TRUE, Kopete should not have # AddDispatchOperation called on it until Empathy returns from - # ObserveChannels. Because Loggy has DelayApprovers=False, + # ObserveChannel. Because Loggy has DelayApprovers=False, # however, ADO can be called on Kopete before Loggy returns, but # again, only after Empathy returns. forbidden = [EventPattern('dbus-method-call', @@ -101,11 +101,11 @@ def test(q, bus, mc): e, l = q.expect_many(EventPattern('dbus-method-call', path=empathy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), EventPattern('dbus-method-call', path=loggy.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False), ) @@ -115,7 +115,7 @@ def test(q, bus, mc): call_async(q, cd_props, 'Get', cs.CD_IFACE_OP_LIST, 'DispatchOperations') event = q.expect('dbus-return', method='Get') - # Finally return from ObserveChannels from Empathy, so now we + # Finally return from ObserveChannel from Empathy, so now we # expect ADO to be called on Kopete. q.dbus_return(e.message, bus=bus, signature='') q.unforbid_events(forbidden) @@ -127,7 +127,7 @@ def test(q, bus, mc): q.dbus_return(e.message, bus=bus, signature='') - # Return from loggy's ObserveChannels. + # Return from loggy's ObserveChannel. q.dbus_return(l.message, bus=bus, signature='') # The user responds to Kopete diff --git a/tests/twisted/dispatcher/undispatchable.py b/tests/twisted/dispatcher/undispatchable.py index 8a18ec03..d98b9d93 100644 --- a/tests/twisted/dispatcher/undispatchable.py +++ b/tests/twisted/dispatcher/undispatchable.py @@ -94,7 +94,7 @@ def test(q, bus, mc): e = q.expect('dbus-method-call', path=client.object_path, - interface=cs.OBSERVER, method='ObserveChannels', + interface=cs.OBSERVER, method='ObserveChannel', handled=False) sync_dbus(bus, q, mc) diff --git a/tests/twisted/mctest.py b/tests/twisted/mctest.py index 3bfd66f6..444efb62 100644 --- a/tests/twisted/mctest.py +++ b/tests/twisted/mctest.py @@ -509,17 +509,15 @@ class SimulatedConnection(object): 'Channels': self.get_channel_details(), }, signature='a{sv}') - def NewChannels(self, channels): - for channel in channels: - assert not channel.announced - channel.announced = True - self.channels.append(channel) + def NewChannel(self, channel): + assert not channel.announced + channel.announced = True + self.channels.append(channel) self.q.dbus_emit(self.object_path, cs.CONN_IFACE_REQUESTS, - 'NewChannels', - [(channel.object_path, channel.immutable) - for channel in channels], - signature='a(oa{sv})') + 'NewChannel', + channel.object_path, channel.immutable, + signature='oa{sv}') def get_contact_attributes(self, h, ifaces): id = self.inspect_handles([h])[0] @@ -669,7 +667,7 @@ class SimulatedChannel(object): self.q.dbus_return(e.message, [], signature='a(uuus)') def announce(self): - self.conn.NewChannels([self]) + self.conn.NewChannel(self) def Close(self, e): if not self.closed: |