Add copyright notices to tests
[profile/ivi/ofono-qt.git] / tests / test_ofonocallforwarding.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 <ofonocallforwarding.h>
28
29 #include <QtDebug>
30
31
32 class TestOfonoCallForwarding : public QObject
33 {
34     Q_OBJECT
35
36 private slots:
37
38     void validityChanged(bool validity)
39     {
40         qDebug() << "ValidityChanged" << validity;
41     }
42     void voiceUnconditionalComplete(bool success, QString property)
43     {
44         qDebug() << "voiceUnconditionalComplete" << success <<  property;
45     }
46     void voiceBusyComplete(bool success, QString property)
47     {
48         qDebug() << "voiceBusyComplete" << success <<  property;
49     }
50     void voiceNoReplyComplete(bool success, QString property)
51     {
52         qDebug() << "voiceNoReplyComplete" << success <<  property;
53     }
54     void voiceNoReplyTimeoutComplete(bool success, ushort timeout)
55     {
56         qDebug() << "voiceNoReplyTimeoutComplete" << success <<  timeout;
57     }
58     void voiceNotReachableComplete(bool success, QString property)
59     {
60         qDebug() << "voiceNotReachableComplete" << success <<  property;
61     }
62
63     void voiceUnconditionalChanged(QString property)
64     {
65         qDebug() << "voiceUnconditionalChanged" << property;
66     }
67     void voiceBusyChanged(QString property)
68     {
69         qDebug() << "voiceBusyChanged" << property;
70     }
71     void voiceNoReplyChanged(QString property)
72     {
73         qDebug() << "voiceNoReplyChanged" << property;
74     }
75     void voiceNoReplyTimeoutChanged(ushort timeout)
76     {
77         qDebug() << "voiceNoReplyTimeoutChanged" << timeout;
78     }
79     void voiceNotReachableChanged(QString property)
80     {
81         qDebug() << "voiceNotReachableChanged" << property;
82     }
83
84     void disableAllComplete(bool success)
85     {
86         qDebug() << "disableAllComplete:" << success;
87     }
88
89
90     void initTestCase()
91     {
92         m = new OfonoCallForwarding(QString(), this);
93         connect(m, SIGNAL(validityChanged(bool)), this, 
94                 SLOT(validityChanged(bool)));
95         connect(m, SIGNAL(voiceUnconditionalChanged(QString)), this, 
96                 SLOT(voiceUnconditionalChanged(QString)));
97         connect(m, SIGNAL(voiceBusyChanged(QString)), this, 
98                 SLOT(voiceBusyChanged(QString)));
99         connect(m, SIGNAL(voiceNoReplyChanged(QString)), this, 
100                 SLOT(voiceNoReplyChanged(QString)));
101         connect(m, SIGNAL(voiceNoReplyTimeoutChanged(ushort)), this, 
102                 SLOT(voiceNoReplyTimeoutChanged(ushort)));
103         connect(m, SIGNAL(voiceNotReachableChanged(QString)), this, 
104                 SLOT(voiceNotReachableChanged(QString)));
105         connect(m, SIGNAL(voiceUnconditionalComplete(bool, QString)), this, 
106                 SLOT(voiceUnconditionalComplete(bool, QString)));
107         connect(m, SIGNAL(voiceBusyComplete(bool, QString)), this, 
108                 SLOT(voiceBusyComplete(bool, QString)));
109         connect(m, SIGNAL(voiceNoReplyComplete(bool, QString)), this, 
110                 SLOT(voiceNoReplyComplete(bool, QString)));
111         connect(m, SIGNAL(voiceNoReplyTimeoutComplete(bool, ushort)), this, 
112                 SLOT(voiceNoReplyTimeoutComplete(bool, ushort)));
113         connect(m, SIGNAL(voiceNotReachableComplete(bool, QString)), this, 
114                 SLOT(voiceNotReachableComplete(bool, QString)));
115         //FIXME: should connect to setSomethingFailed signals too
116     }
117
118     void testOfonoCallForwarding()
119     {
120         qDebug() << "validity:" << m->isValid();
121         m->requestVoiceUnconditional();
122         QTest::qWait(1000);
123         m->requestVoiceBusy();
124         QTest::qWait(1000);
125         m->requestVoiceNoReply();
126         QTest::qWait(1000);
127         m->requestVoiceNoReplyTimeout();
128         QTest::qWait(1000);
129         m->requestVoiceNotReachable();
130         QTest::qWait(1000);
131
132         qDebug() << "setVoiceBusy():";
133         m->setVoiceBusy("12345678");
134         qDebug() << "setVoiceNoReply():";
135         m->setVoiceNoReply("12345678");
136         qDebug() << "setVoiceNoReplyTimeout():";
137         m->setVoiceNoReplyTimeout(30);
138         qDebug() << "setVoiceNotReachable():";
139         m->setVoiceNotReachable("12345678");
140         qDebug() << "setVoiceUnconditional():";
141         m->setVoiceUnconditional("12345678");
142         QTest::qWait(1000);
143         qDebug() << "setVoiceBusy():";
144         m->setVoiceBusy("");
145         qDebug() << "setVoiceNoReply():";
146         m->setVoiceNoReply("");
147         qDebug() << "setVoiceNotReachable():";
148         m->setVoiceNotReachable("");
149         qDebug() << "setVoiceUnconditional():";
150         m->setVoiceUnconditional("");
151
152
153         connect(m, SIGNAL(disableAllComplete(bool)), 
154                 this, SLOT(disableAllComplete(bool)));
155         m->requestDisableAll("all");
156
157         QTest::qWait(120000);
158     }
159
160
161     void cleanupTestCase()
162     {
163
164     }
165
166
167 private:
168     OfonoCallForwarding *m;
169 };
170
171 QTEST_MAIN(TestOfonoCallForwarding)
172 #include "test_ofonocallforwarding.moc"