remove dep for doxygen
[profile/ivi/ofono-qt.git] / tests / test_ofonovoicecallmanager.cpp
1 /*
2  * This file is part of ofono-qt
3  *
4  * Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23
24 #include <QtTest/QtTest>
25 #include <QtCore/QObject>
26
27 #include <ofonovoicecallmanager.h>
28
29 #include <QtDebug>
30
31
32 class TestOfonoVoiceCallManager : public QObject
33 {
34     Q_OBJECT
35
36 private slots:
37     void initTestCase()
38     {
39         m = new OfonoVoiceCallManager(OfonoModem::ManualSelect, "/phonesim", this);
40         QCOMPARE(m->modem()->isValid(), true);  
41
42         if (!m->modem()->powered()) {
43             m->modem()->setPowered(true);
44             QTest::qWait(5000);
45         }
46         if (!m->modem()->online()) {
47             m->modem()->setOnline(true);
48             QTest::qWait(5000);
49         }
50         QCOMPARE(m->isValid(), true);
51     }
52
53     void testOfonoVoiceCallManager()
54     {
55         QVERIFY(m->emergencyNumbers().count() > 0);
56
57         QSignalSpy emergencyNumbers(m, SIGNAL(emergencyNumbersChanged(QStringList)));
58         QSignalSpy dialreg(m,SIGNAL(dialComplete(bool)));
59         QSignalSpy dspy(m, SIGNAL(callAdded(QString)));
60         QSignalSpy hupreg(m,SIGNAL(hangupAllComplete(bool)));
61         QSignalSpy tonereg(m,SIGNAL(sendTonesComplete(bool)));
62         QSignalSpy hspy(m, SIGNAL(callRemoved(QString)));
63
64         m->modem()->setPowered(false);
65         QTest::qWait(5000);
66         m->modem()->setPowered(true);
67         QTest::qWait(5000);
68         m->modem()->setOnline(true);
69         QTest::qWait(5000);
70
71         QCOMPARE(emergencyNumbers.count(), 1);
72         QVERIFY(emergencyNumbers.takeFirst().at(0).toStringList().count() > 0);
73         //Dial testing
74         m->dial("123","");
75         qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button";
76         QTest::qWait(15000);
77         QCOMPARE(dialreg.count(), 1);
78         QCOMPARE(dialreg.takeFirst().at(0).toBool(),true);
79         QCOMPARE(dspy.count(), 1);
80         //Tones testing
81         QTest::qWait(5000);
82         m->sendTones("1234");
83         QTest::qWait(5000);
84         QCOMPARE(tonereg.count(), 1);
85         QCOMPARE(tonereg.takeFirst().at(0).toBool(),true);
86         QTest::qWait(5000);
87         QStringList calls = m->getCalls();
88         QVERIFY(calls.size()>0);
89         //hangup testing
90         m->hangupAll();
91         QTest::qWait(5000);
92         QCOMPARE(hupreg.count(), 1);
93         QCOMPARE(hupreg.takeFirst().at(0).toBool(),true);
94         QCOMPARE(hspy.count(), 1);
95
96     }
97
98     void testoFonoVoiceCallManagerStep2()
99     {
100         // test dial failure and hangup of incoming alerting call
101         QSignalSpy dialreg(m,SIGNAL(dialComplete(bool)));
102         QSignalSpy hupreg(m,SIGNAL(hangupAllComplete(bool)));
103         QSignalSpy dspy(m, SIGNAL(callAdded(QString)));
104         QSignalSpy hspy(m, SIGNAL(callRemoved(QString)));
105
106
107         m->dial("199","");
108         QTest::qWait(5000);
109         QCOMPARE(dialreg.count(), 1);
110         QCOMPARE(dialreg.takeFirst().at(0).toBool(),false);
111         QTest::qWait(10000);
112         QCOMPARE(dspy.count(), 1);
113
114         //hangup the alerting call
115         m->hangupAll();
116         QTest::qWait(5000);
117         QCOMPARE(hupreg.count(), 1);
118         QCOMPARE(hupreg.takeFirst().at(0).toBool(),true);
119
120         QTest::qWait(10000);
121         QCOMPARE(hspy.count(), 1);
122
123     }
124
125     void cleanupTestCase()
126     {
127
128     }
129
130
131 private:
132     OfonoVoiceCallManager *m;
133 };
134
135 QTEST_MAIN(TestOfonoVoiceCallManager)
136 #include "test_ofonovoicecallmanager.moc"