Add copyright notices to tests
[profile/ivi/ofono-qt.git] / tests / test_ofonocallbarring.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 <ofonocallbarring.h>
28
29 #include <QtDebug>
30
31
32 class TestOfonoCallBarring : public QObject
33 {
34     Q_OBJECT
35
36 public slots:
37
38     void validityChanged(bool validity)
39     {
40         qDebug() << "ValidityChanged" << validity;
41     }
42
43     void voiceIncomingComplete(bool success, QString barrings)
44     {
45         qDebug() << "voiceIncomingComplete" << success << barrings;
46     }
47
48     void voiceOutgoingComplete(bool success, QString barrings)
49     {
50         qDebug() << "voiceOutgoingComplete" << success << barrings;
51     }
52
53     void voiceIncomingChanged(QString barrings)
54     {
55         qDebug() << "voiceIncomingChanged" << barrings;
56     }
57
58     void voiceOutgoingChanged(QString barrings)
59     {
60         qDebug() << "voiceOutgoingChanged" << barrings;
61     }
62
63     void setVoiceIncomingFailed()
64     {
65         qDebug() << "setVoiceIncomingFailed" << m->errorName() << m->errorMessage();
66     }
67
68     void setVoiceOutgoingFailed()
69     {
70         qDebug() << "setVoiceOutgoingFailed" << m->errorName() << m->errorMessage();
71     }
72
73     void incomingBarringInEffect()
74     {
75         qDebug() << "incomingBarringInEffect signal";
76     }
77
78     void outgoingBarringInEffect()
79     {
80         qDebug() << "outgoingBarringInEffect signal";
81     }
82
83
84     void disableAllComplete(bool success)
85     {
86         qDebug() << "disableAllComplete:" << success;
87     }
88
89     void changePasswordComplete(bool success)
90     {
91         qDebug() << "changePasswordComplete:" << success;
92     }
93
94 private slots:
95
96     void initTestCase()
97     {
98         m = new OfonoCallBarring(QString(), this);
99         connect(m, SIGNAL(validityChanged(bool)), this, 
100                 SLOT(validityChanged(bool)));
101         connect(m, SIGNAL(voiceIncomingComplete(bool, QString)), this, 
102                 SLOT(voiceIncomingComplete(bool, QString)));
103         connect(m, SIGNAL(voiceOutgoingComplete(bool, QString)), this, 
104                 SLOT(voiceOutgoingComplete(bool, QString)));
105         connect(m, SIGNAL(voiceIncomingChanged(QString)), this, 
106                 SLOT(voiceIncomingChanged(QString)));
107         connect(m, SIGNAL(voiceOutgoingChanged(QString)), this, 
108                 SLOT(voiceOutgoingChanged(QString)));
109         connect(m, SIGNAL(setVoiceIncomingFailed()), this, 
110                 SLOT(setVoiceIncomingFailed()));
111         connect(m, SIGNAL(setVoiceOutgoingFailed()), this, 
112                 SLOT(setVoiceOutgoingFailed()));
113         connect(m, SIGNAL(incomingBarringInEffect()), this, 
114                 SLOT(incomingBarringInEffect()));
115         connect(m, SIGNAL(outgoingBarringInEffect()), this, 
116                 SLOT(outgoingBarringInEffect()));
117         // Wait for properties to arrive...
118         QTest::qWait(1000);
119     }
120
121     void testOfonoCallbarring()
122     {
123         qDebug() << "validity:" << m->isValid();
124         m->requestVoiceIncoming();
125         QTest::qWait(5000);
126         m->requestVoiceOutgoing();
127         QTest::qWait(5000);
128
129         qDebug() << "setVoiceIncoming(always)";
130         m->setVoiceIncoming("always", "3579");
131         QTest::qWait(1000);
132         qDebug() << "setVoiceOutgoing(international)";
133         m->setVoiceOutgoing("international", "3579");
134         QTest::qWait(1000);
135
136         connect(m, SIGNAL(disableAllComplete(bool)), 
137                 this, SLOT(disableAllComplete(bool)));
138         m->requestDisableAll("3579");
139         QTest::qWait(1000);
140         m->requestVoiceIncoming();
141         QTest::qWait(5000);
142         m->requestVoiceOutgoing();
143         QTest::qWait(5000);
144
145         connect(m, SIGNAL(changePasswordComplete(bool)), 
146                 this, SLOT(changePasswordComplete(bool)));
147         m->requestChangePassword("3579", "1234");
148         QTest::qWait(1000);
149         m->requestChangePassword("1234", "3579");
150
151         QTest::qWait(2000);
152     }
153
154
155     void cleanupTestCase()
156     {
157
158     }
159
160
161 private:
162     OfonoCallBarring *m;
163 };
164
165 QTEST_MAIN(TestOfonoCallBarring)
166 #include "test_ofonocallbarring.moc"