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

Subscribers

People subscribed via source and target branches