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 <ofonosupplementaryservices.h>
32 class TestOfonoSupplementaryServices : public QObject
41 m = new OfonoSupplementaryServices(OfonoModem::ManualSelect, "/phonesim", this);
42 QCOMPARE(m->modem()->isValid(), true);
44 if (!m->modem()->powered()) {
45 m->modem()->setPowered(true);
48 if (!m->modem()->online()) {
49 m->modem()->setOnline(true);
52 QCOMPARE(m->isValid(), true);
55 void testOfonoSupplementaryServices()
57 QSignalSpy notification(m, SIGNAL(notificationReceived(QString)));
58 QSignalSpy request(m, SIGNAL(requestReceived(QString)));
60 QSignalSpy state(m, SIGNAL(stateChanged(QString)));
62 QSignalSpy initiateUSSD(m, SIGNAL(initiateUSSDComplete(QString)));
63 QSignalSpy barring(m, SIGNAL(barringComplete(QString, QString, QVariantMap)));
64 QSignalSpy forwarding(m, SIGNAL(forwardingComplete(QString, QString, QVariantMap)));
65 QSignalSpy waiting(m, SIGNAL(waitingComplete(QString, QVariantMap)));
66 QSignalSpy callingLinePresentation(m, SIGNAL(callingLinePresentationComplete(QString, QString)));
67 QSignalSpy calledLinePresentation(m, SIGNAL(calledLinePresentationComplete(QString, QString)));
68 QSignalSpy callingLineRestriction(m, SIGNAL(callingLineRestrictionComplete(QString, QString)));
69 QSignalSpy calledLineRestriction(m, SIGNAL(calledLineRestrictionComplete(QString, QString)));
71 QSignalSpy initiateFailed(m, SIGNAL(initiateFailed()));
72 QSignalSpy respond(m, SIGNAL(respondComplete(bool, QString)));
73 QSignalSpy cancel(m, SIGNAL(cancelComplete(bool)));
75 QCOMPARE(m->state(), QString("idle"));
79 QCOMPARE(state.count(), 2);
80 QCOMPARE(state.takeFirst().at(0).toString(), QString("active"));
81 QCOMPARE(state.takeFirst().at(0).toString(), QString("idle"));
82 QCOMPARE(initiateUSSD.count(), 1);
83 QCOMPARE(initiateUSSD.takeFirst().at(0).toString(), QString("Thank you, your request is being processed. A message will be sent to your phone."));
87 QCOMPARE(cancel.count(), 1);
88 QCOMPARE(cancel.takeFirst().at(0).toBool(), false);
92 QCOMPARE(respond.count(), 1);
93 QCOMPARE(respond.takeFirst().at(0).toBool(), false);
97 QCOMPARE(state.count(), 2);
98 QCOMPARE(state.takeFirst().at(0).toString(), QString("active"));
99 QCOMPARE(state.takeFirst().at(0).toString(), QString("idle"));
100 QCOMPARE(initiateFailed.count(), 1);
101 initiateFailed.takeFirst();
103 m->initiate("*#331#");
105 QCOMPARE(barring.count(), 1);
106 QVariantList list = barring.takeFirst();
107 QCOMPARE(list.at(0).toString(), QString("interrogation"));
108 QCOMPARE(list.at(1).toString(), QString("InternationalOutgoing"));
109 QVariantMap map = list.at(2).toMap();
110 QCOMPARE(map.count(), 3);
111 QCOMPARE(map["DataInternationalOutgoing"].toString(), QString("disabled"));
113 m->initiate("*#002**11#");
115 QCOMPARE(forwarding.count(), 1);
116 list = forwarding.takeFirst();
117 QCOMPARE(list.at(0).toString(), QString("interrogation"));
118 QCOMPARE(list.at(1).toString(), QString("All"));
119 map = list.at(2).toMap();
120 QCOMPARE(map.count(), 5);
121 QCOMPARE(map["VoiceNoReplyTimeout"].toUInt(), uint(20));
123 m->initiate("*#43#");
125 QCOMPARE(waiting.count(), 1);
126 list = waiting.takeFirst();
127 QCOMPARE(list.at(0).toString(), QString("interrogation"));
128 map = list.at(1).toMap();
129 QCOMPARE(map.count(), 5);
130 QCOMPARE(map["DataAsyncCallWaiting"].toString(), QString("disabled"));
132 m->initiate("*#31#");
134 QCOMPARE(callingLineRestriction.count(), 1);
135 list = callingLineRestriction.takeFirst();
136 QCOMPARE(list.at(0).toString(), QString("interrogation"));
137 QCOMPARE(list.at(1).toString(), QString("disabled"));
139 m->initiate("*#30#");
141 QCOMPARE(callingLinePresentation.count(), 1);
142 list = callingLinePresentation.takeFirst();
143 QCOMPARE(list.at(0).toString(), QString("interrogation"));
144 QCOMPARE(list.at(1).toString(), QString("enabled"));
146 m->initiate("*#76#");
148 QCOMPARE(calledLinePresentation.count(), 1);
149 list = calledLinePresentation.takeFirst();
150 QCOMPARE(list.at(0).toString(), QString("interrogation"));
151 QCOMPARE(list.at(1).toString(), QString("enabled"));
153 m->initiate("*#77#");
155 QCOMPARE(calledLineRestriction.count(), 1);
156 list = calledLineRestriction.takeFirst();
157 QCOMPARE(list.at(0).toString(), QString("interrogation"));
158 QCOMPARE(list.at(1).toString(), QString("enabled"));
162 void cleanupTestCase()
169 OfonoSupplementaryServices *m;
172 QTEST_MAIN(TestOfonoSupplementaryServices)
173 #include "test_ofonosupplementaryservices.moc"