Merge lp:~unity-api-team/ubuntu-system-settings/mobile-data-switch into lp:ubuntu-system-settings

Proposed by Antti Kaijanmäki
Status: Merged
Approved by: Ken VanDine
Approved revision: 1664
Merged at revision: 1669
Proposed branch: lp:~unity-api-team/ubuntu-system-settings/mobile-data-switch
Merge into: lp:ubuntu-system-settings
Diff against target: 692 lines (+349/-122)
6 files modified
plugins/cellular/Components/DataMultiSim.qml (+111/-47)
plugins/cellular/Components/SingleSim.qml (+56/-16)
tests/autopilot/ubuntu_system_settings/__init__.py (+1/-4)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+60/-0)
tests/autopilot/ubuntu_system_settings/tests/connectivity.py (+60/-2)
tests/autopilot/ubuntu_system_settings/tests/test_cellular.py (+61/-53)
To merge this branch: bzr merge lp:~unity-api-team/ubuntu-system-settings/mobile-data-switch
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+293882@code.launchpad.net

Commit message

use Connectivity API for cellular data and roaming control.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Thanks, I've added a couple of comments.

review: Needs Fixing
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Maybe also see if this breaks autopilot tests?

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

> Maybe also see if this breaks autopilot tests?

Is your jenkins instance testing against all of the silo packages? If not, then they will break as the cellular page is trying to import Ubuntu.Connectivity 1.1, but the archive only contains 1.0.

That said, I did not touch the autopilot code at all, so if there was something related to the cellular data switches, that's probably broken now.

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

On 6 May 2016 at 13:51, Antti Kaijanmäki <email address hidden>
wrote:

> Is your jenkins instance testing against all of the silo packages?

​No, but should be easily runnable locally.

>
> That said, I did not touch the autopilot code at all, so if there was
> something related to the cellular data switches, that's probably broken now.
>

I believe there are several in test_cellular.py

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

Thanks for the comments! I will fix them ASAP. See my replies inline.

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

On 6 May 2016 at 14:02, Antti Kaijanmäki <email address hidden>
wrote:

> Thanks for the comments! I will fix them ASAP. See my replies inline.
>
> Diff comments:
>
> > + Switch {
> > + id: dataSwitch
> > + checked:
> ​​
> Connectivity.mobileDataEnabled
> > + enabled: simSelector.currentSim !== null
> > + function trigger() {
>
> This is due to
> https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1494387.
>
> This overrides the default onTriggered behavior of the Switch. By default
> the Switch assigns to checked property and breaks the binding of checked:
> Connectivity.mobileDataEnabled
>

​Please use the onTriggered as is and re-set the binding using
checked = Qt.binding(function () { return

Connectivity.mobileDataEnabled })​

> > + else {
> > + return i18n.tr("Insert a SIM, then restart
> the phone.")
> > + }
> > + }
> > + //enabled: model.Sim !== null //
> https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1577359
>
> Because the delegate should really have "enabled: false" when there is no
> SIM, but due to that rendering bug we can't set it. Once the bug is fixed,
> this code can be used.
>
>
Okay, please include that comment in the code.​

Thanks!

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

Comments amended.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) :
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Code looks good, but I can't run the autopilot tests due to [1] and let's replace rowCount with count. Thanks!

[1] http://pastebin.ubuntu.com/17585022/

review: Needs Fixing
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Awesome. Looks good, works well. Thank you!

review: Approve
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Ack string change (Antti says this exist already)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/cellular/Components/DataMultiSim.qml'
2--- plugins/cellular/Components/DataMultiSim.qml 2016-04-29 09:21:32 +0000
3+++ plugins/cellular/Components/DataMultiSim.qml 2016-06-22 16:42:46 +0000
4@@ -21,74 +21,138 @@
5 import SystemSettings 1.0
6 import Ubuntu.Components 1.3
7 import Ubuntu.Components.ListItems 1.3 as ListItem
8+import Ubuntu.Connectivity 1.0
9
10 Column {
11
12- property string prevOnlineModem: parent.prevOnlineModem
13+ SortFilterModel {
14+ id: sortedModems
15+ model: Connectivity.modems
16+ sort.property: "Index"
17+ sort.order: Qt.AscendingOrder
18+ }
19
20- function getNameFromIndex (index) {
21- var dummy = i18n.tr("Cellular data")
22- if (index === 0) {
23- return i18n.tr("Off");
24- } else if (index > 0) {
25- return sims[index - 1].title;
26+ ListItem.Standard {
27+ text: i18n.tr("Cellular data")
28+ control: Switch {
29+ id: dataSwitch
30+ objectName: "data"
31+ checked: Connectivity.mobileDataEnabled
32+ enabled: simSelector.currentSim !== null
33+ onTriggered: {
34+ Connectivity.mobileDataEnabled = checked
35+ /*
36+ * We do this binding here to workaround bug:
37+ * https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1494387
38+ *
39+ * The bug causes the checked binding to be overridden if plain onTriggered is used.
40+ */
41+ checked = Qt.binding(function() {
42+ return Connectivity.mobileDataEnabled
43+ })
44+ }
45 }
46 }
47
48- height: childrenRect.height
49-
50- SettingsItemTitle { text: i18n.tr("Cellular data:") }
51-
52 ListItem.ItemSelector {
53- id: use
54- objectName: "data"
55+ id: simSelector
56+ showDivider: false
57 expanded: true
58- model: {
59- // create a model of 'off' and all sim paths
60- var m = ['off'];
61- sims.forEach(function (sim) {
62- m.push(sim.path);
63- });
64- return m;
65- }
66+ model: sortedModems
67+ selectedIndex: -1
68+
69 delegate: OptionSelectorDelegate {
70- objectName: "use" + modelData
71- text: getNameFromIndex(index)
72+ objectName: "use/ril_" + (model.Index - 1)
73+ text: {
74+ if (model.Sim) {
75+ return sims[model.Index - 1].name + " (" +
76+ (model.Sim.PrimaryPhoneNumber !== "" ?
77+ model.Sim.PrimaryPhoneNumber : model.Sim.Imsi) + ")"
78+ }
79+ else {
80+ return i18n.tr("No SIM detected")
81+ }
82+ }
83+ subText: {
84+ if (model.Sim) {
85+ return ""
86+ }
87+ else {
88+ return i18n.tr("Insert a SIM, then restart the device.")
89+ }
90+ }
91+ enabled: model.Sim !== null
92 }
93- selectedIndex: {
94- if (prevOnlineModem) {
95- return model.indexOf(prevOnlineModem);
96+
97+ property var currentSim : null
98+ onSelectedIndexChanged: {
99+ if (selectedIndex === -1) {
100+ currentSim = null
101 } else {
102- return [true, sims[0].connMan.powered, sims[1].connMan.powered]
103- .lastIndexOf(true);
104- }
105- }
106-
107+ currentSim = model.get(selectedIndex).Sim
108+ }
109+ }
110+ onCurrentSimChanged: {
111+ if (currentSim !== null) {
112+ roaming.checked = Qt.binding(function() {
113+ return currentSim.DataRoamingEnabled
114+ })
115+ }
116+ }
117+
118+ function setSelectedIndex() {
119+ if (Connectivity.simForMobileData === null) {
120+ simSelector.selectedIndex = -1
121+ return
122+ }
123+
124+ for (var i = 0; i < sortedModems.count; i++) {
125+ if (sortedModems.get(i).Sim === Connectivity.simForMobileData) {
126+ simSelector.selectedIndex = i
127+ return
128+ }
129+ }
130+ simSelector.selectedIndex = -1
131+ }
132+ Connections {
133+ target: Connectivity
134+ onSimForMobileDataUpdated: {
135+ simSelector.setSelectedIndex()
136+ }
137+ }
138+ Component.onCompleted: {
139+ setSelectedIndex()
140+ }
141+
142+ onTriggered: {
143+ // @bug: https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1577351
144+ // Connectivity.simForMobileData = currentSim
145+ /*
146+ * There is a bug in onTriggered that causes it to be fired *before* selectedIndex has been updated
147+ * and thus there is no way of knowing what index was actually selected by the user.
148+ *
149+ * This is worked around below by using onDelegateClicked which gives us the missing index.
150+ */
151+ }
152 onDelegateClicked: {
153- // power all sims on or off
154- sims.forEach(function (sim) {
155- sim.connMan.powered = (model[index] === sim.path);
156- });
157+ var sim = sortedModems.get(index).Sim
158+ if (sim === null) {
159+ return
160+ }
161+ Connectivity.simForMobileData = sim
162 }
163 }
164
165 ListItem.Standard {
166- id: dataRoamingItem
167 text: i18n.tr("Data roaming")
168- enabled: use.selectedIndex !== 0
169 control: Switch {
170- id: dataRoamingControl
171+ id: roaming
172 objectName: "roaming"
173-
174- property bool serverChecked: poweredSim && poweredSim.connMan.roamingAllowed
175- onServerCheckedChanged: checked = serverChecked
176- Component.onCompleted: checked = serverChecked
177- onTriggered: {
178- if (poweredSim) {
179- poweredSim.connMan.roamingAllowed = checked;
180- }
181+ enabled: simSelector.currentSim !== null && dataSwitch.checked
182+ checked: simSelector.currentSim ? simSelector.currentSim.DataRoamingEnabled : false
183+ function trigger() {
184+ simSelector.currentSim.DataRoamingEnabled = !checked
185 }
186 }
187- showDivider: false
188 }
189 }
190
191=== modified file 'plugins/cellular/Components/SingleSim.qml'
192--- plugins/cellular/Components/SingleSim.qml 2015-08-21 14:03:29 +0000
193+++ plugins/cellular/Components/SingleSim.qml 2016-06-22 16:42:46 +0000
194@@ -19,12 +19,14 @@
195 */
196 import QtQuick 2.4
197 import SystemSettings 1.0
198+import Ubuntu.Connectivity 1.0
199 import Ubuntu.Components 1.3
200 import Ubuntu.Components.ListItems 1.3 as ListItem
201
202 Column {
203
204 objectName: "singleSim"
205+ id: singlesim
206
207 property var sim
208
209@@ -32,30 +34,68 @@
210 @prevOnlineModem path to modem that was online before this event */
211 signal umtsModemChanged (var sim, string prevOnlineModem);
212
213+ property var currentSim
214+ Component.onCompleted: {
215+ if (sortedModems.count === 1)
216+ {
217+ currentSim = sortedModems.get(0).Sim
218+ Connectivity.simForMobileData = currentSim
219+ }
220+ if (sortedModems.count === 2 &&
221+ (sortedModems.get(0).Sim === null ||
222+ sortedModems.get(1).Sim === null))
223+ {
224+ // Dual-SIM phone with only one sim present
225+ var sim = sortedModems.get(0).Sim
226+ if (sim === null)
227+ {
228+ sim = sortedModems.get(1).Sim
229+ }
230+ if (sim !== null)
231+ {
232+ currentSim = sim
233+ Connectivity.simForMobileData = sim
234+ }
235+ }
236+ }
237+ SortFilterModel {
238+ id: sortedModems
239+ model: Connectivity.modems
240+ sort.property: "Index"
241+ sort.order: Qt.AscendingOrder
242+ }
243+
244 ListItem.Standard {
245- id: selector
246- text: i18n.tr("Cellular data:")
247+ text: i18n.tr("Cellular data")
248 control: Switch {
249- id: dataControl
250- objectName: 'data'
251- property bool serverChecked: sim.connMan.powered
252- onServerCheckedChanged: checked = serverChecked
253- Component.onCompleted: checked = serverChecked
254- onTriggered: sim.connMan.powered = checked
255+ id: dataSwitch
256+ objectName: "data"
257+ checked: Connectivity.mobileDataEnabled
258+ enabled: singlesim.currentSim !== null
259+ onTriggered: {
260+ Connectivity.mobileDataEnabled = checked
261+ /*
262+ * We do this binding here to workaround bug:
263+ * https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1494387
264+ *
265+ * The bug causes the checked binding to be overridden if plain onTriggered is used.
266+ */
267+ checked = Qt.binding(function() {
268+ return Connectivity.mobileDataEnabled
269+ })
270+ }
271 }
272 }
273-
274 ListItem.Standard {
275- id: dataRoamingItem
276 text: i18n.tr("Data roaming")
277- enabled: sim.connMan.powered
278 control: Switch {
279- id: dataRoamingControl
280+ id: roaming
281 objectName: "roaming"
282- property bool serverChecked: sim.connMan.roamingAllowed
283- onServerCheckedChanged: checked = serverChecked
284- Component.onCompleted: checked = serverChecked
285- onTriggered: sim.connMan.roamingAllowed = checked
286+ enabled: singlesim.currentSim !== null && dataSwitch.checked
287+ checked: singlesim.currentSim.DataRoamingEnabled
288+ function trigger() {
289+ singlesim.currentSim.DataRoamingEnabled = !checked
290+ }
291 }
292 }
293
294
295=== modified file 'tests/autopilot/ubuntu_system_settings/__init__.py'
296--- tests/autopilot/ubuntu_system_settings/__init__.py 2016-04-26 13:35:49 +0000
297+++ tests/autopilot/ubuntu_system_settings/__init__.py 2016-06-22 16:42:46 +0000
298@@ -15,12 +15,12 @@
299 # You should have received a copy of the GNU Lesser General Public License
300 # along with this program. If not, see <http://www.gnu.org/licenses/>.
301
302-from time import sleep
303 from autopilot import introspection
304 from autopilot.exceptions import StateNotFoundError
305 from ubuntu_system_settings.utils.i18n import ugettext as _
306
307 import logging
308+from time import sleep
309 import autopilot.logging
310 import ubuntuuitoolkit
311 import ubuntu_system_settings.utils as utils
312@@ -228,9 +228,6 @@
313 def disable_data(self):
314 self._set_data(False)
315
316- def disable_datas(self):
317- self.select_sim_for_data('off')
318-
319 @autopilot.logging.log_action(logger.debug)
320 def _set_data(self, data):
321 chk = self.select_single(objectName='data')
322
323=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
324--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2016-04-07 13:20:40 +0000
325+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2016-06-22 16:42:46 +0000
326@@ -443,9 +443,67 @@
327
328 class CellularBaseTestCase(UbuntuSystemSettingsOfonoTestCase):
329
330+ connectivity_parameters = {
331+ 'Status': 'online'
332+ }
333+
334 def setUp(self):
335 """ Go to Cellular page """
336
337+ self.session_con = self.get_dbus(False)
338+
339+ if is_process_running(INDICATOR_NETWORK):
340+ _stop_process(INDICATOR_NETWORK)
341+ self.addCleanup(_start_process, INDICATOR_NETWORK)
342+
343+ ctv_tmpl = os.path.join(os.path.dirname(__file__), 'connectivity.py')
344+ (self.ctv_mock, self.obj_ctv) = self.spawn_server_template(
345+ ctv_tmpl, parameters=self.connectivity_parameters,
346+ stdout=subprocess.PIPE)
347+
348+ sleep(1)
349+
350+ self.ctv_private = dbus.Interface(
351+ self.session_con.get_object(CTV_IFACE, CTV_PRIV_OBJ),
352+ 'org.freedesktop.DBus.Properties')
353+
354+ sim = self.obj_ctv.AddSim("1234567890")
355+ self.ctv_private.Set(CON_IFACE,
356+ 'Sims',
357+ dbus.Array([sim],
358+ signature='o'))
359+ modem = self.obj_ctv.AddModem("0987654321", 1, sim)
360+ self.ctv_private.Set(CON_IFACE,
361+ 'Modems',
362+ dbus.Array([modem],
363+ signature='o'))
364+
365+ self.ctv_modem0 = dbus.Interface(
366+ self.session_con.get_object(CTV_IFACE, modem),
367+ 'org.freedesktop.DBus.Properties')
368+ self.ctv_sim0 = dbus.Interface(
369+ self.session_con.get_object(CTV_IFACE, sim),
370+ 'org.freedesktop.DBus.Properties')
371+
372+ if self.use_sims == 2:
373+ sim2 = self.obj_ctv.AddSim("2345678901")
374+ self.ctv_private.Set(CON_IFACE,
375+ 'Sims',
376+ dbus.Array([sim, sim2],
377+ signature='o'))
378+ modem2 = self.obj_ctv.AddModem("1098765432", 2, sim2)
379+ self.ctv_private.Set(CON_IFACE,
380+ 'Modems',
381+ dbus.Array([modem, modem2],
382+ signature='o'))
383+
384+ self.ctv_modem1 = dbus.Interface(
385+ self.session_con.get_object(CTV_IFACE, modem2),
386+ 'org.freedesktop.DBus.Properties')
387+ self.ctv_sim1 = dbus.Interface(
388+ self.session_con.get_object(CTV_IFACE, sim2),
389+ 'org.freedesktop.DBus.Properties')
390+
391 user_obj = '/user/foo'
392
393 self.accts_phone_props = {
394@@ -526,6 +584,8 @@
395 context.SetProperty(key, value)
396
397 def tearDown(self):
398+ self.ctv_mock.terminate()
399+ self.ctv_mock.wait()
400 self.mock_server.terminate()
401 self.mock_server.wait()
402 super(CellularBaseTestCase, self).tearDown()
403
404=== modified file 'tests/autopilot/ubuntu_system_settings/tests/connectivity.py'
405--- tests/autopilot/ubuntu_system_settings/tests/connectivity.py 2016-02-24 15:46:11 +0000
406+++ tests/autopilot/ubuntu_system_settings/tests/connectivity.py 2016-06-22 16:42:46 +0000
407@@ -21,6 +21,9 @@
408 PRIV_IFACE = 'com.ubuntu.connectivity1.Private'
409 PRIV_OBJ = '/com/ubuntu/connectivity1/Private'
410
411+MODEM_IFACE = 'com.ubuntu.connectivity1.Modem'
412+SIM_IFACE = 'com.ubuntu.connectivity1.Sim'
413+
414 NETS_IFACE = 'com.ubuntu.connectivity1.NetworkingStatus'
415 NETS_OBJ = '/com/ubuntu/connectivity1/NetworkingStatus'
416
417@@ -60,6 +63,48 @@
418 self.SetProperty(NETS_OBJ, NETS_IFACE, 'WifiEnabled', value)
419
420
421+@dbus.service.method(dbusmock.MOCK_IFACE,
422+ in_signature='s', out_signature='s')
423+def AddSim(self, iccid):
424+ path = "/com/ubuntu/connectivity1/sim/{}".format(iccid)
425+ self.AddObject(
426+ path,
427+ SIM_IFACE,
428+ {
429+ 'Iccid': dbus.String(iccid),
430+ 'PrimaryPhoneNumber': dbus.String("358401234567"),
431+ 'Locked': dbus.Boolean(False),
432+ 'Present': dbus.Boolean(True),
433+ 'Mcc': dbus.String("358"),
434+ 'Mnc': dbus.String("42"),
435+ 'PreferredLanguages': [dbus.String("en"), dbus.String("fi")],
436+ 'DataRoamingEnabled': dbus.Boolean(False),
437+ },
438+ [
439+ ('Unlock', '', '', ''),
440+ ]
441+ )
442+ return path
443+
444+
445+@dbus.service.method(dbusmock.MOCK_IFACE,
446+ in_signature='sis', out_signature='s')
447+def AddModem(self, serial, index, sim):
448+ path = "/com/ubuntu/connectivity1/modem/{}".format(serial)
449+ self.AddObject(
450+ path,
451+ MODEM_IFACE,
452+ {
453+ 'Index': dbus.Int32(index),
454+ 'Serial': dbus.String(serial),
455+ 'Sim': dbus.ObjectPath(sim)
456+ },
457+ [
458+ ]
459+ )
460+ return path
461+
462+
463 def add_openvpn_object(mock, path):
464 obj = dbusmock.get_object(path)
465 obj.AddProperties(VPN_CONN_OPENVPN_IFACE, {
466@@ -225,8 +270,21 @@
467 'HotspotAuth': _parameters.get(
468 'HotspotAuth', dbus.String('wpa-psk')
469 ),
470- 'VpnConnections': _parameters.get('VpnConnections',
471- dbus.Array([], signature='o'))
472+ 'VpnConnections': _parameters.get(
473+ 'VpnConnections', dbus.Array([], signature='o')
474+ ),
475+ 'MobileDataEnabled': _parameters.get(
476+ 'MobileDataEnabled', dbus.Boolean(False)
477+ ),
478+ 'SimForMobileData': _parameters.get(
479+ 'SimForMobileData', dbus.ObjectPath('/')
480+ ),
481+ 'Modems': _parameters.get(
482+ 'Modems', dbus.Array([], signature='o')
483+ ),
484+ 'Sims': _parameters.get(
485+ 'Sims', dbus.Array([], signature='o')
486+ )
487 },
488 [
489 (
490
491=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_cellular.py'
492--- tests/autopilot/ubuntu_system_settings/tests/test_cellular.py 2016-05-06 13:50:38 +0000
493+++ tests/autopilot/ubuntu_system_settings/tests/test_cellular.py 2016-06-22 16:42:46 +0000
494@@ -6,15 +6,19 @@
495 # by the Free Software Foundation.
496
497 import dbus
498+from time import sleep
499
500 from autopilot.introspection.dbus import StateNotFoundError
501 from autopilot.matchers import Eventually
502 from testtools.matchers import Equals, raises, StartsWith
503
504 from ubuntu_system_settings.tests import (
505- CellularBaseTestCase, CONNMAN_IFACE, RDO_IFACE,
506- NETREG_IFACE, ACCOUNTS_PHONE_IFACE)
507+ CellularBaseTestCase, RDO_IFACE,
508+ NETREG_IFACE, ACCOUNTS_PHONE_IFACE, CON_IFACE)
509
510+from ubuntu_system_settings.tests.connectivity import (
511+ SIM_IFACE as CTV_SIM_IFACE
512+)
513
514 DEV_IFACE = 'org.freedesktop.NetworkManager.Device'
515
516@@ -22,49 +26,46 @@
517 class CellularTestCase(CellularBaseTestCase):
518
519 def test_enable_data(self):
520+ self.ctv_private.Set(CON_IFACE, 'MobileDataEnabled', False)
521 self.cellular_page.enable_data()
522 self.assertThat(
523- lambda: self.modem_0.Get(CONNMAN_IFACE, 'Powered'),
524+ lambda: self.ctv_private.Get(CON_IFACE, 'MobileDataEnabled'),
525 Eventually(Equals(True))
526 )
527
528 def test_disable_data(self):
529+ self.ctv_private.Set(CON_IFACE, 'MobileDataEnabled', True)
530 self.cellular_page.disable_data()
531 self.assertThat(
532- lambda: self.modem_0.Get(CONNMAN_IFACE, 'Powered'),
533+ lambda: self.ctv_private.Get(CON_IFACE, 'MobileDataEnabled'),
534 Eventually(Equals(False))
535 )
536
537 def test_remote_manipulation_of_data(self):
538- self.modem_0.EmitSignal(
539- CONNMAN_IFACE,
540- 'PropertyChanged',
541- 'sv',
542- ['Powered', 'true'])
543-
544+ self.ctv_private.Set(CON_IFACE, 'MobileDataEnabled', True)
545 self.assertThat(lambda: self.cellular_page.get_data(),
546 Eventually(Equals(True)))
547-
548- self.modem_0.EmitSignal(
549- CONNMAN_IFACE,
550- 'PropertyChanged',
551- 'sv',
552- ['Powered', 'false'])
553-
554+ sleep(1)
555+ self.ctv_private.Set(CON_IFACE, 'MobileDataEnabled', False)
556+ sleep(1)
557 self.assertThat(lambda: self.cellular_page.get_data(),
558 Eventually(Equals(False)))
559
560 def test_enable_roaming(self):
561+ self.ctv_private.Set(CON_IFACE, 'MobileDataEnabled', True)
562+ self.ctv_sim0.Set(CTV_SIM_IFACE, 'DataRoamingEnabled', False)
563 self.cellular_page.enable_roaming()
564 self.assertThat(
565- lambda: self.modem_0.Get(CONNMAN_IFACE, 'RoamingAllowed'),
566+ lambda: self.ctv_sim0.Get(CTV_SIM_IFACE, 'DataRoamingEnabled'),
567 Eventually(Equals(True))
568 )
569
570 def test_disable_roaming(self):
571+ self.ctv_private.Set(CON_IFACE, 'MobileDataEnabled', True)
572+ self.ctv_sim0.Set(CTV_SIM_IFACE, 'DataRoamingEnabled', True)
573 self.cellular_page.disable_roaming()
574 self.assertThat(
575- lambda: self.modem_0.Get(CONNMAN_IFACE, 'RoamingAllowed'),
576+ lambda: self.ctv_sim0.Get(CTV_SIM_IFACE, 'DataRoamingEnabled'),
577 Eventually(Equals(False))
578 )
579
580@@ -97,36 +98,31 @@
581 use_sims = 2
582
583 def test_data_off(self):
584- self.cellular_page.disable_datas()
585- self.assertThat(
586- lambda: self.modem_0.Get(CONNMAN_IFACE, 'Powered'),
587- Eventually(Equals(False))
588- )
589- self.assertThat(
590- lambda: self.modem_1.Get(CONNMAN_IFACE, 'Powered'),
591+ self.ctv_private.Set(CON_IFACE, 'MobileDataEnabled', True)
592+ self.cellular_page.disable_data()
593+ self.assertThat(
594+ lambda: self.ctv_private.Get(CON_IFACE, 'MobileDataEnabled'),
595 Eventually(Equals(False))
596 )
597
598 def test_sim1_online(self):
599+ self.ctv_private.Set(CON_IFACE,
600+ 'SimForMobileData',
601+ dbus.ObjectPath("/"))
602 self.cellular_page.select_sim_for_data('/ril_0')
603 self.assertThat(
604- lambda: self.modem_0.Get(CONNMAN_IFACE, 'Powered'),
605- Eventually(Equals(True))
606- )
607- self.assertThat(
608- lambda: self.modem_1.Get(CONNMAN_IFACE, 'Powered'),
609- Eventually(Equals(False))
610+ lambda: self.ctv_private.Get(CON_IFACE, 'SimForMobileData'),
611+ Eventually(Equals(self.ctv_sim0.object_path))
612 )
613
614 def test_sim2_online(self):
615+ self.ctv_private.Set(CON_IFACE,
616+ 'SimForMobileData',
617+ dbus.ObjectPath("/"))
618 self.cellular_page.select_sim_for_data('/ril_1')
619 self.assertThat(
620- lambda: self.modem_0.Get(CONNMAN_IFACE, 'Powered'),
621- Eventually(Equals(False))
622- )
623- self.assertThat(
624- lambda: self.modem_1.Get(CONNMAN_IFACE, 'Powered'),
625- Eventually(Equals(True))
626+ lambda: self.ctv_private.Get(CON_IFACE, 'SimForMobileData'),
627+ Eventually(Equals(self.ctv_sim1.object_path))
628 )
629
630 def test_connection_type_on_sim1(self):
631@@ -228,7 +224,7 @@
632 raise e
633
634 def test_roaming_switch(self):
635- self.cellular_page.disable_datas()
636+ self.cellular_page.disable_data()
637 # assert roaming_switch is disabled
638 self.assertThat(
639 lambda: self.cellular_page.enable_roaming(timeout=1),
640@@ -236,26 +232,38 @@
641 )
642
643 def test_allow_roaming_sim_1(self):
644- sim = '/ril_0'
645- self.cellular_page.select_sim_for_data(sim)
646-
647- self.assertEqual(
648- False, self.modem_0.Get(CONNMAN_IFACE, 'RoamingAllowed'))
649+ self.ctv_private.Set(CON_IFACE, 'MobileDataEnabled', True)
650+ self.ctv_sim0.Set(CTV_SIM_IFACE, 'DataRoamingEnabled', False)
651+ self.ctv_private.Set(CON_IFACE,
652+ 'SimForMobileData',
653+ dbus.ObjectPath("/"))
654+ self.cellular_page.select_sim_for_data('/ril_0')
655+ self.assertThat(
656+ lambda: self.ctv_private.Get(CON_IFACE, 'SimForMobileData'),
657+ Eventually(Equals(self.ctv_sim0.object_path))
658+ )
659 self.cellular_page.enable_roaming()
660 self.assertThat(
661- lambda: self.modem_0.Get(CONNMAN_IFACE, 'RoamingAllowed'),
662- Eventually(Equals(True)))
663+ lambda: self.ctv_sim0.Get(CTV_SIM_IFACE, 'DataRoamingEnabled'),
664+ Eventually(Equals(True))
665+ )
666
667 def test_allow_roaming_sim_2(self):
668- sim = '/ril_1'
669- self.cellular_page.select_sim_for_data(sim)
670-
671- self.assertEqual(
672- False, self.modem_1.Get(CONNMAN_IFACE, 'RoamingAllowed'))
673+ self.ctv_private.Set(CON_IFACE, 'MobileDataEnabled', True)
674+ self.ctv_sim1.Set(CTV_SIM_IFACE, 'DataRoamingEnabled', False)
675+ self.ctv_private.Set(CON_IFACE,
676+ 'SimForMobileData',
677+ dbus.ObjectPath("/"))
678+ self.cellular_page.select_sim_for_data('/ril_1')
679+ self.assertThat(
680+ lambda: self.ctv_private.Get(CON_IFACE, 'SimForMobileData'),
681+ Eventually(Equals(self.ctv_sim1.object_path))
682+ )
683 self.cellular_page.enable_roaming()
684 self.assertThat(
685- lambda: self.modem_1.Get(CONNMAN_IFACE, 'RoamingAllowed'),
686- Eventually(Equals(True)))
687+ lambda: self.ctv_sim1.Get(CTV_SIM_IFACE, 'DataRoamingEnabled'),
688+ Eventually(Equals(True))
689+ )
690
691 def test_changing_default_sim_for_calls(self):
692 # click ask

Subscribers

People subscribed via source and target branches