Merge lp:~canonical-platform-qa/dialer-app/call-tests into lp:dialer-app

Proposed by Martin Pitt
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 66
Merged at revision: 65
Proposed branch: lp:~canonical-platform-qa/dialer-app/call-tests
Merge into: lp:dialer-app
Diff against target: 249 lines (+201/-0)
4 files modified
src/qml/HistoryPage/HistoryPage.qml (+2/-0)
src/qml/LiveCallPage/LiveCall.qml (+3/-0)
tests/autopilot/dialer_app/emulators.py (+3/-0)
tests/autopilot/dialer_app/tests/test_calls.py (+193/-0)
To merge this branch: bzr merge lp:~canonical-platform-qa/dialer-app/call-tests
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+189815@code.launchpad.net

Commit message

Add some incoming/outgoing call tests, using ofono-phonesim.

Description of the change

Add some incoming/outgoing call tests.

These need to be run with ofono-phonesim set up, which can either happen with
merely installing "ofono-phonesim-autostart", or installing ofono-phonesim,
xvfb, and ofono-scripts and running "sudo with-ofono-phonesim" before launching
the tests. If phonesim is not running, the tests are skipped (i. e. they won't
fail without phonesim).

This tests the whole dialer-app → libofono-qt → telephony-service → telepathy-ofono → ofono stack, but does not have any hardware requirements so this can easily run on x86 machines during CI testing.

I launch the tests with

  cd tests/autopilot
  autopilot run dialer_app

(not sure if there's a more standard way for that)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
66. By Martin Pitt

merge trunk

Revision history for this message
Martin Pitt (pitti) wrote :

Merged with latest trunk and re-tested on image 90, still working fine.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Martin Pitt (pitti) wrote :

ARM build failed with some weird "hudson.remoting.RequestAbortedException: hudson.remoting.RequestAbortedException: java.io.IOException: Unexpected termination of the channel", can you please retry?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qml/HistoryPage/HistoryPage.qml'
2--- src/qml/HistoryPage/HistoryPage.qml 2013-10-09 14:46:13 +0000
3+++ src/qml/HistoryPage/HistoryPage.qml 2013-10-10 09:12:21 +0000
4@@ -57,6 +57,8 @@
5
6 MultipleSelectionListView {
7 id: historyList
8+ objectName: "historyList"
9+
10 property int currentContactExpanded: -1
11 anchors.fill: parent
12 listModel: sortProxy
13
14=== modified file 'src/qml/LiveCallPage/LiveCall.qml'
15--- src/qml/LiveCallPage/LiveCall.qml 2013-10-02 22:00:53 +0000
16+++ src/qml/LiveCallPage/LiveCall.qml 2013-10-10 09:12:21 +0000
17@@ -28,6 +28,7 @@
18
19 Page {
20 id: liveCall
21+ objectName: "pageLiveCall"
22
23 property QtObject call: callManager.foregroundCall
24 property string dtmfEntry: ""
25@@ -115,6 +116,7 @@
26
27 StopWatch {
28 id: stopWatch
29+ objectName: "stopWatch"
30 time: call ? call.elapsedTime : 0
31 visible: false
32 }
33@@ -355,6 +357,7 @@
34
35 HangupButton {
36 id: hangupButton
37+ objectName: "hangupButton"
38
39 anchors.horizontalCenter: parent.horizontalCenter
40 anchors.verticalCenter: parent.verticalCenter
41
42=== modified file 'tests/autopilot/dialer_app/emulators.py'
43--- tests/autopilot/dialer_app/emulators.py 2013-08-21 20:31:27 +0000
44+++ tests/autopilot/dialer_app/emulators.py 2013-10-10 09:12:21 +0000
45@@ -50,3 +50,6 @@
46
47 def get_erase_button(self):
48 return self.select_single("CustomButton", objectName="eraseButton")
49+
50+ def get_call_button(self):
51+ return self.select_single(objectName="callButton")
52
53=== added file 'tests/autopilot/dialer_app/tests/test_calls.py'
54--- tests/autopilot/dialer_app/tests/test_calls.py 1970-01-01 00:00:00 +0000
55+++ tests/autopilot/dialer_app/tests/test_calls.py 2013-10-10 09:12:21 +0000
56@@ -0,0 +1,193 @@
57+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
58+# Copyright 2013 Canonical
59+# Author: Martin Pitt <martin.pitt@ubuntu.com>
60+#
61+# This file is part of dialer-app.
62+#
63+# dialer-app is free software: you can redistribute it and/or modify it
64+# under the terms of the GNU General Public License version 3, as published
65+# by the Free Software Foundation.
66+
67+"""Tests for the Dialer App using ofono-phonesim"""
68+
69+from __future__ import absolute_import
70+
71+import subprocess
72+import os
73+import time
74+
75+from autopilot.matchers import Eventually
76+from testtools.matchers import Equals, NotEquals
77+from testtools import skipUnless
78+
79+from dialer_app.tests import DialerAppTestCase
80+
81+# determine whether we are running with phonesim
82+try:
83+ out = subprocess.check_output(["/usr/share/ofono/scripts/list-modems"],
84+ stderr=subprocess.PIPE)
85+ have_phonesim = out.startswith("[ /phonesim ]")
86+except subprocess.CalledProcessError:
87+ have_phonesim = False
88+
89+
90+@skipUnless(have_phonesim,
91+ "this test needs to run under with-ofono-phonesim")
92+class TestCalls(DialerAppTestCase):
93+ """Tests for simulated phone calls."""
94+
95+ def setUp(self):
96+ # provide clean history
97+ self.history = os.path.expanduser(
98+ "~/.local/share/history-service/history.sqlite")
99+ if os.path.exists(self.history):
100+ subprocess.call(["pkill", "history-daemon"])
101+ os.rename(self.history, self.history + ".orig")
102+
103+ super(TestCalls, self).setUp()
104+ self.entry = self.main_view.dialer_page.get_keypad_entry()
105+ self.call_button = self.main_view.dialer_page.get_call_button()
106+ self.hangup_button = None
107+
108+ # should have an empty history at the beginning of each test
109+ self.history_list = self.app.select_single(objectName="historyList")
110+ self.assertThat(self.history_list.visible, Equals(False))
111+ self.assertThat(self.history_list.count, Equals(0))
112+
113+ self.keys = []
114+ for i in range(10):
115+ self.keys.append(self.main_view.dialer_page.get_keypad_key(str(i)))
116+
117+ def tearDown(self):
118+ super(TestCalls, self).tearDown()
119+
120+ # ensure that there are no leftover calls in case of failed tests
121+ subprocess.call(["/usr/share/ofono/scripts/hangup-all"])
122+
123+ # restore history
124+ if os.path.exists(self.history + ".orig"):
125+ subprocess.call(["pkill", "history-daemon"])
126+ os.rename(self.history + ".orig", self.history)
127+
128+ def test_outgoing_noanswer(self):
129+ """Outgoing call to a normal number, no answer"""
130+
131+ self.keypad_dial("144")
132+ self.wait_live_call_page("144")
133+ self.hangup()
134+
135+ # log should show call to "Unknown"
136+ self.assertThat(self.history_list.count, Equals(1))
137+ self.assertThat(self.history_list.select_single(
138+ "Label", text="Unknown"), NotEquals(None))
139+
140+ def test_outgoing_answer_local_hangup(self):
141+ """Outgoing call, remote answers, local hangs up"""
142+
143+ # 06123xx causes accept after xx seconds
144+ self.keypad_dial("0612302")
145+ self.wait_live_call_page("0612302")
146+
147+ # stop watch should start counting
148+ stop_watch = self.app.select_single(objectName="stopWatch")
149+ self.assertIn("00:0", stop_watch.elapsed)
150+
151+ # should still be connected after some time
152+ time.sleep(3)
153+ self.assertIn("00:0", stop_watch.elapsed)
154+
155+ self.hangup()
156+
157+ def test_outgoing_answer_remote_hangup(self):
158+ """Outgoing call, remote answers and hangs up"""
159+
160+ # 05123xx causes immediate accept and hangup after xx seconds
161+ self.keypad_dial("0512303")
162+ self.wait_live_call_page("0512303")
163+
164+ # stop watch should start counting
165+ stop_watch = self.app.select_single(objectName="stopWatch")
166+ self.assertIn("00:0", stop_watch.elapsed)
167+
168+ # after remote hangs up, should switch to call log page and show call
169+ # to "Unknown"
170+ fn = lambda: self.app.select_single(objectName="hangupButton")
171+ self.assertThat(fn, Eventually(Equals(None)))
172+ self.assertThat(self.history_list.visible, Eventually(Equals(True)))
173+ self.assertThat(self.history_list.count, Equals(1))
174+ self.assertThat(self.history_list.select_single(
175+ "Label", text="Unknown"), NotEquals(None))
176+
177+ def test_incoming(self):
178+ """Incoming call"""
179+
180+ # magic number 199 will cause a callback from 1234567; dialing 199
181+ # itself will fail, so quiesce the error
182+ subprocess.call(["/usr/share/ofono/scripts/dial-number", "199"],
183+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
184+
185+ # wait for incoming call, accept; it would be nicer to fake-click the
186+ # popup notification, but as this isn't generated by dialer-app it
187+ # isn't exposed to autopilot
188+ self.wait_for_incoming_call()
189+ subprocess.call(["/usr/share/ofono/scripts/answer-calls"],
190+ stdout=subprocess.PIPE)
191+
192+ # call back is from that number
193+ self.wait_live_call_page("1234567")
194+
195+ # stop watch should start counting
196+ stop_watch = self.app.select_single(objectName="stopWatch")
197+ self.assertIn("00:0", stop_watch.elapsed)
198+
199+ self.hangup()
200+
201+ #
202+ # Helper methods
203+ #
204+
205+ def keypad_dial(self, number):
206+ """Dial given number (string) on the keypad and call"""
207+ for digit in number:
208+ self.pointing_device.click_object(self.keys[int(digit)])
209+ self.assertThat(self.entry.value, Eventually(Equals(number)))
210+
211+ self.pointing_device.click_object(self.call_button)
212+
213+ def wait_live_call_page(self, number):
214+ """Wait until live call page gets visible
215+
216+ Sets self.hangup_button.
217+ """
218+ fn = lambda: self.app.select_single(objectName="hangupButton")
219+ self.assertThat(fn, Eventually(NotEquals(None)))
220+ self.hangup_button = self.app.select_single(objectName="hangupButton")
221+ self.assertThat(self.hangup_button.visible, Eventually(Equals(True)))
222+ self.assertThat(self.call_button.visible, Equals(False))
223+
224+ # should show called number in title page
225+ lcp = self.app.select_single(objectName="pageLiveCall")
226+ self.assertThat(lcp.title, Equals(number))
227+
228+ def wait_for_incoming_call(self):
229+ """Wait up to 5 s for an incoming phone call"""
230+
231+ timeout = 10
232+ while timeout >= 0:
233+ out = subprocess.check_output(
234+ ["/usr/share/ofono/scripts/list-calls"],
235+ stderr=subprocess.PIPE)
236+ if "State = incoming" in out:
237+ break
238+ timeout -= 1
239+ time.sleep(0.5)
240+ else:
241+ self.fail("timed out waiting for incoming phonesim call")
242+
243+ def hangup(self):
244+ self.pointing_device.click_object(self.hangup_button)
245+ fn = lambda: self.app.select_single(objectName="hangupButton")
246+ self.assertThat(fn, Eventually(Equals(None)))
247+
248+ # should switch to call log page
249+ self.assertThat(self.history_list.visible, Eventually(Equals(True)))

Subscribers

People subscribed via source and target branches