7a08576c29925071455fe60838c03666c20b6148
[profile/ivi/ofono-qt.git] / tests / test_ofonocallsettings.cpp
1 /*
2  * This file is part of ofono-qt
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Alexander Kanavin <alexander.kanavin@nokia.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
38     void validityChanged(bool validity)
39     {
40         qDebug() << "ValidityChanged" << validity;
41     }
42
43     void callingLinePresentationComplete(bool success, QString setting)
44     {
45         qDebug() << "callingLinePresentationComplete" << success << setting;
46     }
47     void calledLinePresentationComplete(bool success, QString setting)
48     {
49         qDebug() << "calledLinePresentationComplete" << success << setting;
50     }
51     void calledLineRestrictionComplete(bool success, QString setting)
52     {
53         qDebug() << "calledLineRestrictionComplete" << success << setting;
54     }
55     void callingLineRestrictionComplete(bool success, QString setting)
56     {
57         qDebug() << "callingLineRestrictionComplete" << success << setting;
58     }
59     void hideCallerIdComplete(bool success, QString setting)
60     {
61         qDebug() << "hideCallerIdComplete" << success << setting;
62     }
63     void voiceCallWaitingComplete(bool success, QString setting)
64     {
65         qDebug() << "voiceCallWaitingComplete" << success << setting;
66     }
67
68     void callingLinePresentationChanged(QString setting)
69     {
70         qDebug() << "callingLinePresentationChanged" << setting;
71     }
72     void calledLinePresentationChanged(QString setting)
73     {
74         qDebug() << "calledLinePresentationChanged" << setting;
75     }
76     void calledLineRestrictionChanged(QString setting)
77     {
78         qDebug() << "calledLineRestrictionChanged" << setting;
79     }
80     void callingLineRestrictionChanged(QString setting)
81     {
82         qDebug() << "callingLineRestrictionChanged" << setting;
83     }
84     void hideCallerIdChanged(QString setting)
85     {
86         qDebug() << "hideCallerIdChanged" << setting;
87     }
88     void voiceCallWaitingChanged(QString setting)
89     {
90         qDebug() << "voiceCallWaitingChanged" << setting;
91     }
92
93     void setHideCallerIdFailed()
94     {
95         qDebug() << "setHideCallerIdFailed";
96     }
97     void setVoiceCallWaitingFailed()
98     {
99         qDebug() << "setVoiceCallWaitingFailed";
100     }
101
102     void initTestCase()
103     {
104         m = new OfonoCallSettings(OfonoModem::AutomaticSelect, QString(), this);
105         connect(m, SIGNAL(validityChanged(bool)), this, 
106                 SLOT(validityChanged(bool)));
107         connect(m, SIGNAL(callingLinePresentationChanged(QString)), this, 
108                 SLOT(callingLinePresentationChanged(QString)));
109         connect(m, SIGNAL(calledLinePresentationChanged(QString)), this, 
110                 SLOT(calledLinePresentationChanged(QString)));
111         connect(m, SIGNAL(calledLineRestrictionChanged(QString)), this, 
112                 SLOT(calledLineRestrictionChanged(QString)));
113         connect(m, SIGNAL(callingLineRestrictionChanged(QString)), this, 
114                 SLOT(callingLineRestrictionChanged(QString)));
115         connect(m, SIGNAL(hideCallerIdChanged(QString)), this, 
116                 SLOT(hideCallerIdChanged(QString)));
117         connect(m, SIGNAL(voiceCallWaitingChanged(QString)), this, 
118                 SLOT(voiceCallWaitingChanged(QString)));
119         connect(m, SIGNAL(setHideCallerIdFailed()), this, 
120                 SLOT(setHideCallerIdFailed()));
121         connect(m, SIGNAL(setVoiceCallWaitingFailed()), this, 
122                 SLOT(setVoiceCallWaitingFailed()));
123
124         connect(m, SIGNAL(callingLinePresentationComplete( bool, QString)), this, 
125                 SLOT(callingLinePresentationComplete( bool, QString)));
126         connect(m, SIGNAL(calledLinePresentationComplete( bool, QString)), this, 
127                 SLOT(calledLinePresentationComplete( bool, QString)));
128         connect(m, SIGNAL(calledLineRestrictionComplete( bool, QString)), this, 
129                 SLOT(calledLineRestrictionComplete( bool, QString)));
130         connect(m, SIGNAL(callingLineRestrictionComplete( bool, QString)), this, 
131                 SLOT(callingLineRestrictionComplete( bool, QString)));
132         connect(m, SIGNAL(hideCallerIdComplete( bool, QString)), this, 
133                 SLOT(hideCallerIdComplete( bool, QString)));
134         connect(m, SIGNAL(voiceCallWaitingComplete( bool, QString)), this, 
135                 SLOT(voiceCallWaitingComplete( bool, QString)));
136
137     }
138
139     void testOfonoCallSettings()
140     {
141         qDebug() << "validity:" << m->isValid();
142         m->requestCallingLinePresentation();
143         QTest::qWait(1000);
144         m->requestCalledLinePresentation();
145         QTest::qWait(1000);
146         m->requestCalledLineRestriction();
147         QTest::qWait(1000);
148         m->requestCallingLineRestriction();
149         QTest::qWait(1000);
150         m->requestHideCallerId();
151         QTest::qWait(1000);
152         m->requestVoiceCallWaiting();
153         QTest::qWait(1000);
154         qDebug() << "setHideCallerId(enabled):";
155         m->setHideCallerId("enabled");
156         qDebug() << "setVoiceCallWaiting(enabled):";
157         m->setVoiceCallWaiting("enabled");
158         qDebug() << "setHideCallerId(disabled):";
159         m->setHideCallerId("disabled");
160         qDebug() << "setVoiceCallWaiting(disabled):";
161         m->setVoiceCallWaiting("disabled");
162
163         QTest::qWait(120000);
164     }
165
166
167     void cleanupTestCase()
168     {
169
170     }
171
172
173 private:
174     OfonoCallSettings *m;
175 };
176
177 QTEST_MAIN(TestOfonoCallSettings)
178 #include "test_ofonocallsettings.moc"