on xenial help sign in
[BROKEN] commit to merge upstream
commitb14aeb0082829fee2910109ea285c74d750d551a authorJosh Arenson <joshua.arenson@canonical.com> dateMon 18 May 2015, 11:11 (11 years ago) parentab8f277
5 files changed+130−3
debian/control+2−1 qml/Wizard/Pages/20-sim.qml+8 tests/CMakeLists.txt+2−2 tests/autopilot/unity8/settings_wizard/phonesim_manager.py+96 tests/autopilot/unity8/settings_wizard/tests/test_settings_wizard.py+22
debian/control+2−1
@@ -145,7 +145,7 @@ Depends: autopilot-qt5 (>= 1.4),
145145 gir1.2-notify-0.7,
146146 libqt5test5,
147147 libqt5widgets5,
148− ofono-phonesim-autostart,
148+ ofono-phonesim,
149149 python3-autopilot,
150150 python3-evdev,
151151 python3-fixtures,
@@ -156,6 +156,7 @@ Depends: autopilot-qt5 (>= 1.4),
156156 unity8 (= ${source:Version}),
157157 unity8-fake-env (= ${source:Version}),
158158 url-dispatcher-tools,
159+ xvfb,
159160 ${misc:Depends},
160161 ${python3:Depends},
161162 ${shlibs:Depends},
qml/Wizard/Pages/20-sim.qml+8
@@ -30,6 +30,14 @@ LocalComponents.Page {
3030 && (manager.modems.length < 2 || simManager1.ready))
3131 skip: !manager.available || manager.modems.length === 0 || simManager0.present || simManager1.present
3232
33+ Component.onCompleted: {
34+ console.log("----- JOSH skip status -----")
35+ console.log("JOSH nmanager.available:" + manager.available)
36+ console.log("JOSH nmanager.modems.length:"+ manager.modems.length)
37+ console.log("JOSH simManager0.ready:" + simManager0.ready)
38+ console.log("JOSH simManager1.ready:" + simManager1.ready)
39+ }
40+
3341 OfonoManager {
3442 id: manager
3543 property bool ready: false
tests/CMakeLists.txt+2−2
@@ -10,7 +10,7 @@ add_dependencies(qmltests qmlunittests qmluitests)
1010add_subdirectory(libs)
1111add_subdirectory(qmltests)
1212add_subdirectory(mocks)
13−add_subdirectory(whitespace)
14−add_subdirectory(plugins)
13+#add_subdirectory(whitespace)
14+#add_subdirectory(plugins)
1515add_subdirectory(utils)
1616add_subdirectory(uqmlscene)
tests/autopilot/unity8/settings_wizard/phonesim_manager.pynew file+96
@@ -0,0 +1,96 @@
1+#!/usr/bin/python -tt
2+
3+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
4+#
5+# Unity Indicators Autopilot Test Suite
6+# Copyright (C) 2014 Canonical
7+#
8+# This program is free software: you can redistribute it and/or modify
9+# it under the terms of the GNU General Public License as published by
10+# the Free Software Foundation, either version 3 of the License, or
11+# (at your option) any later version.
12+#
13+# This program is distributed in the hope that it will be useful,
14+# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+# GNU General Public License for more details.
17+#
18+# You should have received a copy of the GNU General Public License
19+# along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
21+
22+from __future__ import absolute_import
23+
24+import dbus
25+import subprocess
26+from time import sleep
27+
28+
29+class PhonesimManager(object):
30+
31+ def __init__(self, sims, exe=None):
32+ if exe is None:
33+ self.phonesim_exe = '/usr/bin/ofono-phonesim'
34+ else:
35+ self.phonesim_exe = exe
36+ self.sims = sims
37+ self.sim_processes = {}
38+ self.system_bus = dbus.SystemBus()
39+ self.ofono = self.system_bus.get_object('org.ofono', '/')
40+ self.phonesim_manager = dbus.Interface(
41+ self.ofono,
42+ 'org.ofono.phonesim.Manager'
43+ )
44+
45+ def start_phonesim_processes(self):
46+ for simname, simport, conffile in self.sims:
47+ cmd = ['/usr/bin/xvfb-run', '-a', self.phonesim_exe, '-p', str(simport), conffile]
48+ p = subprocess.Popen(cmd)
49+ self.sim_processes[simname] = p
50+ # give the processes some time to start
51+ sleep(1)
52+
53+ def shutdown(self):
54+ for p in self.sim_processes.values():
55+ p.kill()
56+ self.sim_processes = {}
57+
58+ def reset_ofono(self):
59+ self.phonesim_manager.Reset()
60+
61+ def remove_all_ofono(self):
62+ self.phonesim_manager.RemoveAll()
63+
64+ def add_ofono(self, name):
65+ for simname, simport, _ in self.sims:
66+ if name == simname:
67+ self.phonesim_manager.Add(simname, '127.0.0.1', str(simport))
68+ return
69+ raise RuntimeError('Tried to add unknown modem %s.' % name)
70+
71+ def power_on(self, sim_name):
72+ sim = self.system_bus.get_object('org.ofono', '/'+sim_name)
73+ modem = dbus.Interface(sim, dbus_interface='org.ofono.Modem')
74+ modem.SetProperty('Powered', True)
75+ sleep(1)
76+
77+ def power_off(self, sim_name):
78+ sim = self.system_bus.get_object('org.ofono', '/'+sim_name)
79+ modem = dbus.Interface(sim, dbus_interface='org.ofono.Modem')
80+ modem.SetProperty('Powered', False)
81+ sleep(1)
82+
83+ def get_required_pin(self, sim_name):
84+ sim = self.system_bus.get_object('org.ofono', '/'+sim_name)
85+ interface = dbus.Interface(sim, dbus_interface='org.ofono.SimManager')
86+ return str(interface.GetProperties()['PinRequired'])
87+
88+
89+if __name__ == '__main__':
90+ sims = [('sim1', 12345, '/usr/share/phonesim/default.xml'),
91+ ('sim2', 12346, '/usr/share/phonesim/default.xml')]
92+ m = PhonesimManager(sims)
93+ m.start_phonesim_processes()
94+ import pdb
95+ pdb.set_trace()
96+ m.shutdown()
tests/autopilot/unity8/settings_wizard/tests/test_settings_wizard.py+22
@@ -1,22 +1,44 @@
1+import os
2+import sysconfig
13
24from unity8.settings_wizard import fixture_setup
35from unity8.settings_wizard.emulators.settings_wizard import Wizard
6+from unity8.settings_wizard.phonesim_manager import PhonesimManager
47from unity8.shell import tests
58
69DEFAULT_LANGUAGE = 'English (United States)'
710DEFAULT_SECURITY_METHOD = 'Passcode'
811
12+import pdb
13+
914
1015class SkipThroughSettingsWizardTestCase(tests.UnityTestCase):
1116 """ Autopilot test for completing settings wizard """
1217
1318 def setUp(self):
1419 super().setUp()
20+ phonesim_datadir = os.getenv('INDICATOR_NETWORK_PHONESIM_DATA')
21+ if phonesim_datadir is None:
22+ phonesim_datadir = sysconfig.get_config_var('datarootdir') + \
23+ '/indicator-network/phonesim'
24+
25+ sims = [('sim1',
26+ 23456,
27+ phonesim_datadir + '/pin-unlock.xml')]
28+ self.phonesim_manager = PhonesimManager(sims)
1529 self.wizard_helper = self.useFixture(
1630 fixture_setup.SettingsWizard(True))
31+ self.phonesim_manager.start_phonesim_processes()
32+ self.phonesim_manager.remove_all_ofono()
33+ self.phonesim_manager.add_ofono('sim1')
34+ self.phonesim_manager.power_on('sim1')
35+ pdb.set_trace()
1736 self.unity = self.launch_unity()
1837 self.wizard = self._get_settings_wizard()
1938
39+ def tearDown(self):
40+ self.phonesim_manager.shutdown()
41+
2042 def _get_settings_wizard(self):
2143 return self.unity.wait_select_single(Wizard)
2244