telepathy-mission-control: Add a regression test for NetworkManager's " not quite offline" states
Simon McVittie
smcv at kemper.freedesktop.org
Tue Sep 3 08:15:48 PDT 2013
Module: telepathy-mission-control
Branch: master
Commit: 5dbd8df6bd212ede2075dce3cbf3a6b5ebf4e8d3
URL: http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=5dbd8df6bd212ede2075dce3cbf3a6b5ebf4e8d3
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Tue Apr 30 17:08:08 2013 +0100
Add a regression test for NetworkManager's "not quite offline" states
We were only testing the intersection of ConnMan and NM functionality,
but NM actually has a bit more.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=56635
Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Reviewed-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
---
tests/twisted/Makefile.am | 3 +++
tests/twisted/account-manager/connectivity.py | 23 +++++++++++++++++++++++
tests/twisted/fakeconnectivity.py | 16 ++++++++++++----
3 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 7542e46..ed95405 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -147,7 +147,9 @@ endif
if HAVE_NM
HAVE_CONNECTIVITY_PYBOOL = True
+HAVE_NM_PYBOOL = True
else
+HAVE_NM_PYBOOL = False
if HAVE_CONNMAN
HAVE_CONNECTIVITY_PYBOOL = True
else
@@ -158,6 +160,7 @@ endif
config.py: Makefile
$(AM_V_GEN) { \
echo "HAVE_MCE = $(HAVE_MCE_PYBOOL)"; \
+ echo "HAVE_NM = $(HAVE_NM_PYBOOL)"; \
echo "HAVE_CONNECTIVITY = $(HAVE_CONNECTIVITY_PYBOOL)"; \
} > $@
diff --git a/tests/twisted/account-manager/connectivity.py b/tests/twisted/account-manager/connectivity.py
index 0f1c340..0198545 100644
--- a/tests/twisted/account-manager/connectivity.py
+++ b/tests/twisted/account-manager/connectivity.py
@@ -92,6 +92,29 @@ def test(q, bus, mc):
args=list(requested_presence[1:])),
])
+ if config.HAVE_NM:
+ # If NetworkManager tells us that it is going to disconnect soon,
+ # the connection should be banished. GNetworkMonitor can't tell us
+ # that; either it's online or it isn't.
+ mc.connectivity.go_indeterminate()
+ q.expect('dbus-method-call', method='Disconnect')
+
+ mc.connectivity.go_offline()
+
+ # When we turn the network back on, MC should try to sign us back on.
+ # In the process, our RequestedPresence should not have been
+ # trampled on, as below.
+ mc.connectivity.go_online()
+ expect_fakecm_connection(q, bus, mc, account, params,
+ has_presence=True,
+ expect_before_connect=[
+ EventPattern('dbus-method-call', method='SetPresence',
+ args=list(requested_presence[1:])),
+ ])
+
+ assertEquals(requested_presence,
+ account.Properties.Get(cs.ACCOUNT, 'RequestedPresence'))
+
# If we turn the network off, the connection should be banished.
mc.connectivity.go_offline()
q.expect('dbus-method-call', method='Disconnect')
diff --git a/tests/twisted/fakeconnectivity.py b/tests/twisted/fakeconnectivity.py
index c144452..ccc62e5 100644
--- a/tests/twisted/fakeconnectivity.py
+++ b/tests/twisted/fakeconnectivity.py
@@ -98,8 +98,11 @@ class FakeConnectivity(object):
def ConnMan_GetProperties(self, e):
self.q.dbus_return(e.message, self.Connman_props(), signature='a{sv}')
- def change_state(self, online):
- if online:
+ def change_state(self, online, indeterminate=False):
+ if indeterminate:
+ self.nm_state = self.NM_STATE_DISCONNECTING
+ # keep the previous ConnMan state
+ elif online:
self.nm_state = self.NM_STATE_CONNECTED_GLOBAL
self.connman_state = self.CONNMAN_ONLINE
else:
@@ -112,11 +115,16 @@ class FakeConnectivity(object):
self.q.dbus_emit(self.NM_PATH, self.NM_INTERFACE,
'StateChanged', self.nm_state,
signature='u')
- self.q.dbus_emit(self.CONNMAN_PATH, self.CONNMAN_INTERFACE,
- 'PropertyChanged', "State", self.connman_state, signature='sv')
+
+ if not indeterminate:
+ self.q.dbus_emit(self.CONNMAN_PATH, self.CONNMAN_INTERFACE,
+ 'PropertyChanged', "State", self.connman_state, signature='sv')
def go_online(self):
self.change_state(True)
def go_offline(self):
self.change_state(False)
+
+ def go_indeterminate(self):
+ self.change_state(None, True)
More information about the telepathy-commits
mailing list