2 * This file is part of ofono-qt
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
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.
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.
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
24 #include <QtTest/QtTest>
25 #include <QtCore/QObject>
27 #include <ofonocallbarring.h>
32 class TestOfonoCallBarring : public QObject
40 m = new OfonoCallBarring(OfonoModem::ManualSelect, "/phonesim", this);
41 QCOMPARE(m->modem()->isValid(), true);
43 if (!m->modem()->powered()) {
44 m->modem()->setPowered(true);
47 if (!m->modem()->online()) {
48 m->modem()->setOnline(true);
51 QCOMPARE(m->isValid(), true);
54 void testOfonoCallbarring()
56 QSignalSpy voiceIncomingComplete(m, SIGNAL(voiceIncomingComplete(bool, QString)));
57 QSignalSpy voiceOutgoingComplete(m, SIGNAL(voiceOutgoingComplete(bool, QString)));
58 QSignalSpy voiceIncomingChanged(m, SIGNAL(voiceIncomingChanged(QString)));
59 QSignalSpy voiceOutgoingChanged(m, SIGNAL(voiceOutgoingChanged(QString)));
60 QSignalSpy setVoiceIncomingFailed(m, SIGNAL(setVoiceIncomingFailed()));
61 QSignalSpy setVoiceOutgoingFailed(m, SIGNAL(setVoiceOutgoingFailed()));
63 // These two are unused until we support a voicecall API
64 QSignalSpy incomingBarringInEffect(m, SIGNAL(incomingBarringInEffect()));
65 QSignalSpy outgoingBarringInEffect(m, SIGNAL(outgoingBarringInEffect()));
67 QSignalSpy changePasswordComplete(m, SIGNAL(changePasswordComplete(bool)));
68 QSignalSpy disableAllComplete(m, SIGNAL(disableAllComplete(bool)));
69 QSignalSpy disableAllIncomingComplete(m, SIGNAL(disableAllIncomingComplete(bool)));
70 QSignalSpy disableAllOutgoingComplete(m, SIGNAL(disableAllOutgoingComplete(bool)));
72 m->requestVoiceIncoming();
74 QCOMPARE(voiceIncomingComplete.count(), 1);
75 QVariantList list = voiceIncomingComplete.takeFirst();
76 QCOMPARE(list.at(0).toBool(), true);
77 QCOMPARE(list.at(1).toString(), QString("disabled"));
78 QCOMPARE(voiceIncomingChanged.count(), 1);
79 QCOMPARE(voiceIncomingChanged.takeFirst().at(0).toString(), QString("disabled"));
80 m->requestVoiceOutgoing();
82 QCOMPARE(voiceOutgoingComplete.count(), 1);
83 list = voiceOutgoingComplete.takeFirst();
84 QCOMPARE(list.at(0).toBool(), true);
85 QCOMPARE(list.at(1).toString(), QString("disabled"));
86 QCOMPARE(voiceOutgoingChanged.count(), 1);
87 QCOMPARE(voiceOutgoingChanged.takeFirst().at(0).toString(), QString("disabled"));
89 m->setVoiceIncoming("always", "0000");
91 QCOMPARE(setVoiceIncomingFailed.count(), 1);
92 setVoiceIncomingFailed.takeFirst();
93 m->setVoiceOutgoing("always", "0000");
95 QCOMPARE(setVoiceOutgoingFailed.count(), 1);
96 setVoiceOutgoingFailed.takeFirst();
98 m->setVoiceIncoming("always", "3579");
100 QCOMPARE(voiceIncomingChanged.count(), 1);
101 QCOMPARE(voiceIncomingChanged.takeFirst().at(0).toString(), QString("always"));
102 m->setVoiceOutgoing("international", "3579");
104 QCOMPARE(voiceOutgoingChanged.count(), 1);
105 QCOMPARE(voiceOutgoingChanged.takeFirst().at(0).toString(), QString("international"));
107 m->disableAllIncoming("3579");
109 QCOMPARE(disableAllIncomingComplete.count(), 1);
110 QCOMPARE(disableAllIncomingComplete.takeFirst().at(0).toBool(), false);
111 QCOMPARE(m->errorName(), QString("org.ofono.Error.Failed"));
112 QCOMPARE(m->errorMessage(), QString("Operation failed"));
113 m->disableAllOutgoing("3579");
115 QCOMPARE(disableAllOutgoingComplete.count(), 1);
116 QCOMPARE(disableAllOutgoingComplete.takeFirst().at(0).toBool(), false);
117 QCOMPARE(m->errorName(), QString("org.ofono.Error.Failed"));
118 QCOMPARE(m->errorMessage(), QString("Operation failed"));
119 m->disableAll("3579");
121 QCOMPARE(disableAllComplete.count(), 1);
122 QCOMPARE(disableAllComplete.takeFirst().at(0).toBool(), true);
123 QCOMPARE(voiceIncomingChanged.count(), 1);
124 QCOMPARE(voiceIncomingChanged.takeFirst().at(0).toString(), QString("disabled"));
125 QCOMPARE(voiceOutgoingChanged.count(), 1);
126 QCOMPARE(voiceOutgoingChanged.takeFirst().at(0).toString(), QString("disabled"));
128 m->changePassword("3579", "1234");
130 m->changePassword("1234", "3579");
132 QCOMPARE(changePasswordComplete.count(), 2);
133 QCOMPARE(changePasswordComplete.takeFirst().at(0).toBool(), true);
134 QCOMPARE(changePasswordComplete.takeFirst().at(0).toBool(), true);
138 void cleanupTestCase()
148 QTEST_MAIN(TestOfonoCallBarring)
149 #include "test_ofonocallbarring.moc"