Bug 26583

Summary: Allow channels to be dispatched before a connection is established
Product: Telepathy Reporter: Eitan Isaacson <eitan.isaacson>
Component: mission-controlAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium Keywords: patch
Version: git master   
Hardware: Other   
OS: All   
URL: http://git.collabora.co.uk/?p=user/eitan/telepathy-mission-control.git;a=summary
Whiteboard: review+
i915 platform: i915 features:
Attachments: Move _mcd_dispatcher_add_connection to an earlier stage.
Move _mcd_dispatcher_add_connection to an earlier stage.

Description Eitan Isaacson 2010-02-15 14:21:05 UTC
Currently the channel dispatcher is only set up after the Connection has been connected. There is a need for channels to be dispatched before this, specifically when a verification channel is received when a SSL certificate needs to be verified.
Comment 1 Eitan Isaacson 2010-02-17 12:27:41 UTC
Created attachment 33366 [details] [review]
Move _mcd_dispatcher_add_connection to an earlier stage.
Comment 2 Eitan Isaacson 2010-02-17 13:54:09 UTC
Created attachment 33369 [details] [review]
Move _mcd_dispatcher_add_connection to an earlier stage.
Comment 3 Simon McVittie 2010-02-18 03:46:40 UTC
Where's the git branch? Referencing gitweb is generally easier than attaching a series of diffs.

This functionality needs a regression test.

Please add the 'patch' keyword when this is ready for review.
Comment 4 Eitan Isaacson 2010-02-18 17:51:46 UTC
Since it was such a small change, I thought it would be easier to review as a patch. Here is the git branch:

http://git.collabora.co.uk/?p=user/eitan/telepathy-mission-control.git;a=summary

I just looked at the regression tests, and it's less than trivial, so once I learn how to write new tests, I'll do that and tag this report as 'patch'.
Comment 5 Eitan Isaacson 2010-02-25 15:00:55 UTC
Added a regression test, adjusted current tests, and made amendments where tests were sincerely failing.
Comment 6 Simon McVittie 2010-02-26 04:43:47 UTC
I'll have a look, thanks.

(Telepathy convention is usually to put the thing to be reviewed in the URL field of the bug, btw.)
Comment 7 Simon McVittie 2010-02-26 05:09:09 UTC
+    if (!priv->dispatching_started)
     _mcd_dispatcher_add_connection (priv->dispatcher, connection);

Indentation, please.

+    e = q.expect('dbus-signal', signal='StatusChanged')
+
+    # Connection should be in "Connecting" status for this test.
+    assert e.args == [cs.CONN_STATUS_CONNECTING, cs.CONN_STATUS_REASON_REQUESTED]

This seems suspicious: this signal was emitted by the SimulatedConnection, which is part of your test code, so you shouldn't have to expect() it. You can expect() a call to Connect() instead?

The code changes look good, though.
Comment 8 Eitan Isaacson 2010-02-26 08:42:03 UTC
(In reply to comment #7)
> +    if (!priv->dispatching_started)
>      _mcd_dispatcher_add_connection (priv->dispatcher, connection);
> 
> Indentation, please.

That file is very confusing. Right above that statement is a similar one with a tab indentation. Anyway, I fixed it to what I believe it should be in that file.

> 
> +    e = q.expect('dbus-signal', signal='StatusChanged')
> +
> +    # Connection should be in "Connecting" status for this test.
> +    assert e.args == [cs.CONN_STATUS_CONNECTING,
> cs.CONN_STATUS_REASON_REQUESTED]
> 
> This seems suspicious: this signal was emitted by the SimulatedConnection,
> which is part of your test code, so you shouldn't have to expect() it. You can
> expect() a call to Connect() instead?

Yeah, that's stupid. Fixed.

> 
> The code changes look good, though.
> 

Comment 9 Simon McVittie 2010-03-15 07:47:19 UTC
You still seem to be expect()ing StatusChanged. Why? The test script has full control over the SimulatedConnection's status, so this makes no sense.

Tests should be making expectations/assertions about what the code under test (MC) does, not about what the test harness does. The SimulatedConnection, and all other Python code in test/twisted/, is part of the test harness.

As I said previously, one event that it *would* make sense to expect() is the call to Connect(), which MC will do. This happens to cause StatusChanged as a side-effect of the SimulatedConnection's implementation of Connect.
Comment 10 Eitan Isaacson 2010-03-17 10:44:11 UTC
(In reply to comment #9)
> You still seem to be expect()ing StatusChanged. Why? The test script has full
> control over the SimulatedConnection's status, so this makes no sense.
> 

I left it there purely for readability reasons, the channel is dispatched when the connection is in Connecting status.

> As I said previously, one event that it *would* make sense to expect() is the
> call to Connect(), which MC will do. This happens to cause StatusChanged as a
> side-effect of the SimulatedConnection's implementation of Connect.
> 

I'll use that instead, should answer my goal above.
Comment 11 Simon McVittie 2010-04-06 11:45:13 UTC
This appears to be fixed in master.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.