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 <ofonosimmanager.h>
32 class TestOfonoSimManager : public QObject
38 void validityChanged(bool validity)
40 qDebug() << "ValidityChanged" << validity;
43 void presenceChanged(bool ispresent)
45 qDebug() << "presenceChanged" << ispresent;
47 void subscriberIdentityChanged(QString imsi)
49 qDebug() << "subscriberIdentityChanged" << imsi;
51 void mobileCountryCodeChanged(QString mcc)
53 qDebug() << "mobileCountryCodeChanged" << mcc;
55 void mobileNetworkCodeChanged(QString mnc)
57 qDebug() << "mobileNetworkCodeChanged" << mnc;
59 void subscriberNumbersChanged(QStringList msisdns)
61 qDebug() << "subscriberNumbersChanged" << msisdns;
63 void serviceNumbersChanged(QMap<QString, QString> sdns)
65 qDebug() << "serviceNumbersChanged" << sdns;
67 void pinRequiredChanged(QString pintype)
69 qDebug() << "pinRequiredChanged" << pintype;
71 void lockedPinsChanged(QStringList pins)
73 qDebug() << "lockedPinsChanged" << pins;
75 void cardIdentifierChanged(QString iccid)
77 qDebug() << "cardIdentifierChanged" << iccid;
79 void preferredLanguagesChanged(QStringList languages)
81 qDebug() << "preferredLanguagesChanged" << languages;
84 void enterPinComplete(bool success)
86 qDebug() << "enterPinComplete:" << success;
88 qDebug() << "Error name/message" << m->errorName() << m->errorMessage();
90 void resetPinComplete(bool success)
92 qDebug() << "resetPinComplete:" << success;
94 qDebug() << "Error name/message" << m->errorName() << m->errorMessage();
97 void changePinComplete(bool success)
99 qDebug() << "changePinComplete:" << success;
102 void lockPinComplete(bool success)
104 qDebug() << "lockPinComplete:" << success;
107 void unlockPinComplete(bool success)
109 qDebug() << "unlockPinComplete:" << success;
114 m = new OfonoSimManager(OfonoModem::AutomaticSelect, QString(), this);
115 connect(m, SIGNAL(validityChanged(bool)), this,
116 SLOT(validityChanged(bool)));
117 connect(m, SIGNAL(presenceChanged(bool)),
119 SLOT(presenceChanged(bool)));
120 connect(m, SIGNAL(subscriberIdentityChanged(QString)), this,
121 SLOT(subscriberIdentityChanged(QString)));
122 connect(m, SIGNAL(mobileCountryCodeChanged(QString)), this,
123 SLOT(mobileCountryCodeChanged(QString)));
124 connect(m, SIGNAL(mobileNetworkCodeChanged(QString)), this,
125 SLOT(mobileNetworkCodeChanged(QString)));
126 connect(m, SIGNAL(subscriberNumbersChanged(QStringList)), this,
127 SLOT(subscriberNumbersChanged(QStringList)));
128 connect(m, SIGNAL(serviceNumbersChanged(QMap<QString, QString>)), this,
129 SLOT(serviceNumbersChanged(QMap<QString, QString>)));
130 connect(m, SIGNAL(pinRequiredChanged(QString)), this,
131 SLOT(pinRequiredChanged(QString)));
132 connect(m, SIGNAL(lockedPinsChanged(QStringList)), this,
133 SLOT(lockedPinsChanged(QStringList)));
134 connect(m, SIGNAL(cardIdentifierChanged(QString)), this,
135 SLOT(cardIdentifierChanged(QString)));
136 connect(m, SIGNAL(preferredLanguagesChanged(QStringList)), this,
137 SLOT(preferredLanguagesChanged(QStringList)));
140 void testOfonoSimManager()
142 qDebug() << "validity:" << m->isValid();
143 qDebug() << "present():" << m->present();
144 qDebug() << "subscriberIdentity():" << m->subscriberIdentity();
145 qDebug() << "mobileCountryCode():" << m->mobileCountryCode();
146 qDebug() << "mobileNetworkCode():" << m->mobileNetworkCode();
147 qDebug() << "subscriberNumbers():" << m->subscriberNumbers();
148 qDebug() << "serviceNumbers():" << m->serviceNumbers();
149 qDebug() << "pinRequired():" << m->pinRequired();
150 qDebug() << "lockedPins():" << m->lockedPins();
151 qDebug() << "cardIdentifier():" << m->cardIdentifier();
152 qDebug() << "preferredLanguages():" << m->preferredLanguages();
154 /* If we are using phonesim */
155 if (m->subscriberIdentity() == "246813579") {
156 connect(m, SIGNAL(lockPinComplete(bool)),
157 this, SLOT(lockPinComplete(bool)));
158 connect(m, SIGNAL(unlockPinComplete(bool)),
159 this, SLOT(unlockPinComplete(bool)));
160 connect(m, SIGNAL(changePinComplete(bool)),
161 this, SLOT(changePinComplete(bool)));
163 if (m->pinRequired() == "pin") {
164 connect(m, SIGNAL(enterPinComplete(bool)),
165 this, SLOT(enterPinComplete(bool)));
166 m->enterPin("pin", "2468");
168 } else if (m->pinRequired() == "puk") {
169 connect(m, SIGNAL(resetPinComplete(bool)),
170 this, SLOT(resetPinComplete(bool)));
171 m->resetPin("puk", "13243546", "2468");
174 if (m->lockedPins().contains("pin")) {
175 m->unlockPin("pin", "2468");
177 m->lockPin("pin", "2468");
179 m->changePin("pin", "2468", "1234");
181 m->changePin("pin", "1234", "2468");
183 m->lockPin("pin", "2468");
185 m->changePin("pin", "2468", "1234");
187 m->changePin("pin", "1234", "2468");
189 m->unlockPin("pin", "2468");
192 QTest::qWait(120000);
196 void cleanupTestCase()
206 QTEST_MAIN(TestOfonoSimManager)
207 #include "test_ofonosimmanager.moc"