remove dep for doxygen
[profile/ivi/ofono-qt.git] / tests / test_ofonocallsettings.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 <ofonocallsettings.h>
28
29 #include <QtDebug>
30
31
32 class TestOfonoCallSettings : public QObject
33 {
34     Q_OBJECT
35
36 private slots:
37     void initTestCase()
38     {
39         m = new OfonoCallSettings(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 testOfonoCallSettings()
54     {
55         QSignalSpy callingLinePresentationComplete(m, SIGNAL(callingLinePresentationComplete(bool, QString)));
56         QSignalSpy calledLinePresentationComplete(m, SIGNAL(calledLinePresentationComplete(bool, QString)));
57         QSignalSpy callingNamePresentationComplete(m, SIGNAL(callingNamePresentationComplete(bool, QString)));
58         QSignalSpy connectedLinePresentationComplete(m, SIGNAL(connectedLinePresentationComplete(bool, QString)));
59         QSignalSpy connectedLineRestrictionComplete(m, SIGNAL(connectedLineRestrictionComplete(bool, QString)));
60         QSignalSpy callingLineRestrictionComplete(m, SIGNAL(callingLineRestrictionComplete(bool, QString)));
61         QSignalSpy hideCallerIdComplete(m, SIGNAL(hideCallerIdComplete(bool, QString)));
62         QSignalSpy voiceCallWaitingComplete(m, SIGNAL(voiceCallWaitingComplete(bool, QString)));
63
64         QSignalSpy callingLinePresentationChanged(m, SIGNAL(callingLinePresentationChanged(QString)));        
65         QSignalSpy calledLinePresentationChanged(m, SIGNAL(calledLinePresentationChanged(QString)));        
66         QSignalSpy callingNamePresentationChanged(m, SIGNAL(callingNamePresentationChanged(QString)));        
67         QSignalSpy connectedLinePresentationChanged(m, SIGNAL(connectedLinePresentationChanged(QString)));
68         QSignalSpy connectedLineRestrictionChanged(m, SIGNAL(connectedLineRestrictionChanged(QString)));
69         QSignalSpy callingLineRestrictionChanged(m, SIGNAL(callingLineRestrictionChanged(QString)));        
70         QSignalSpy hideCallerIdChanged(m, SIGNAL(hideCallerIdChanged(QString)));        
71         QSignalSpy voiceCallWaitingChanged(m, SIGNAL(voiceCallWaitingChanged(QString)));        
72
73         QSignalSpy setHideCallerIdFailed(m, SIGNAL(setHideCallerIdFailed()));
74         QSignalSpy setVoiceCallWaitingFailed(m, SIGNAL(setVoiceCallWaitingFailed()));
75
76         m->requestCallingLinePresentation();
77         QTest::qWait(5000);
78         QCOMPARE(callingLinePresentationComplete.count(), 1);
79         QVariantList list = callingLinePresentationComplete.takeFirst();
80         QCOMPARE(list.at(0).toBool(), true);
81         QCOMPARE(list.at(1).toString(), QString("enabled"));
82         QVERIFY(callingLinePresentationChanged.count() > 0);    
83         QCOMPARE(callingLinePresentationChanged.takeFirst().at(0).toString(), QString("enabled"));      
84         m->requestCalledLinePresentation();
85         QTest::qWait(1000);
86         QCOMPARE(calledLinePresentationComplete.count(), 1);
87         list = calledLinePresentationComplete.takeFirst();
88         QCOMPARE(list.at(0).toBool(), true);
89         QCOMPARE(list.at(1).toString(), QString("enabled"));
90         QVERIFY(calledLinePresentationChanged.count() > 0);     
91         QCOMPARE(calledLinePresentationChanged.takeFirst().at(0).toString(), QString("enabled"));       
92         m->requestCallingNamePresentation();
93         QTest::qWait(5000);
94         QCOMPARE(callingNamePresentationComplete.count(), 1);
95         list = callingNamePresentationComplete.takeFirst();
96         QCOMPARE(list.at(0).toBool(), true);
97         QCOMPARE(list.at(1).toString(), QString("enabled"));
98         QVERIFY(callingNamePresentationChanged.count() > 0);    
99         QCOMPARE(callingNamePresentationChanged.takeFirst().at(0).toString(), QString("enabled"));      
100         m->requestConnectedLinePresentation();
101         QTest::qWait(1000);
102         QCOMPARE(connectedLinePresentationComplete.count(), 1);
103         list = connectedLinePresentationComplete.takeFirst();
104         QCOMPARE(list.at(0).toBool(), true);
105         QCOMPARE(list.at(1).toString(), QString("enabled"));
106         QVERIFY(connectedLinePresentationChanged.count() > 0);
107         QCOMPARE(connectedLinePresentationChanged.takeFirst().at(0).toString(), QString("enabled"));
108         m->requestConnectedLineRestriction();
109         QTest::qWait(1000);
110         QCOMPARE(connectedLineRestrictionComplete.count(), 1);
111         list = connectedLineRestrictionComplete.takeFirst();
112         QCOMPARE(list.at(0).toBool(), true);
113         QCOMPARE(list.at(1).toString(), QString("enabled"));
114         QVERIFY(connectedLineRestrictionChanged.count() > 0);
115         QCOMPARE(connectedLineRestrictionChanged.takeFirst().at(0).toString(), QString("enabled"));
116         m->requestCallingLineRestriction();
117         QTest::qWait(1000);
118         QCOMPARE(callingLineRestrictionComplete.count(), 1);
119         list = callingLineRestrictionComplete.takeFirst();
120         QCOMPARE(list.at(0).toBool(), true);
121         QCOMPARE(list.at(1).toString(), QString("on"));
122         QVERIFY(callingLineRestrictionChanged.count() > 0);     
123         QCOMPARE(callingLineRestrictionChanged.takeFirst().at(0).toString(), QString("on"));    
124         m->requestHideCallerId();
125         QTest::qWait(1000);
126         QCOMPARE(hideCallerIdComplete.count(), 1);
127         list = hideCallerIdComplete.takeFirst();
128         QCOMPARE(list.at(0).toBool(), true);
129         QCOMPARE(list.at(1).toString(), QString("default"));
130         QVERIFY(hideCallerIdChanged.count() > 0);       
131         QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("default"));
132         m->requestVoiceCallWaiting();
133         QTest::qWait(1000);
134         QCOMPARE(voiceCallWaitingComplete.count(), 1);
135         list = voiceCallWaitingComplete.takeFirst();
136         QCOMPARE(list.at(0).toBool(), true);
137         QCOMPARE(list.at(1).toString(), QString("enabled"));
138         QVERIFY(voiceCallWaitingChanged.count() > 0);   
139         QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("enabled"));
140         
141         m->setHideCallerId("abc");
142         QTest::qWait(1000);
143         QCOMPARE(setHideCallerIdFailed.count(), 1);
144         setHideCallerIdFailed.takeFirst();
145         m->setVoiceCallWaiting("abc");
146         QTest::qWait(1000);
147         QCOMPARE(setVoiceCallWaitingFailed.count(), 1);
148         setVoiceCallWaitingFailed.takeFirst();
149         
150         hideCallerIdChanged.clear();
151         m->setHideCallerId("enabled");
152         QTest::qWait(1000);
153         m->setHideCallerId("default");
154         QTest::qWait(1000);
155         QCOMPARE(hideCallerIdChanged.count(), 2);       
156         QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("enabled"));
157         QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("default"));
158         
159         voiceCallWaitingChanged.clear();        
160         m->setVoiceCallWaiting("disabled");
161         QTest::qWait(5000);
162         m->setVoiceCallWaiting("enabled");
163         QTest::qWait(5000);
164         QCOMPARE(voiceCallWaitingChanged.count(), 2);   
165         QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("disabled"));
166         QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("enabled"));
167     }
168
169
170     void cleanupTestCase()
171     {
172
173     }
174
175
176 private:
177     OfonoCallSettings *m;
178 };
179
180 QTEST_MAIN(TestOfonoCallSettings)
181 #include "test_ofonocallsettings.moc"