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 <ofononetworkregistration.h>
28 #include <ofononetworkoperator.h>
33 class TestOfonoNetworkOperator : public QObject
40 m = new OfonoNetworkRegistration(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 testOfonoNetworkOperator()
56 QSignalSpy scan(m, SIGNAL(scanComplete(bool, QStringList)));
59 QCOMPARE(scan.count(), 1);
60 QVariantList scanList = scan.takeFirst();
61 QCOMPARE(scanList.at(0).toBool(), true);
62 QStringList opIdList = scanList.at(1).toStringList();
63 QVERIFY(opIdList.count() > 0);
65 QList<OfonoNetworkOperator> opList;
66 foreach(QString opId, opIdList)
68 opList << OfonoNetworkOperator(opId);
73 foreach(OfonoNetworkOperator op, opList) {
74 if (op1 == -1 && op.status() == "current")
75 op1 = opList.indexOf(op);
76 if (op2 == -1 && op.status() == "available")
77 op2 = opList.indexOf(op);
81 QVERIFY(opList[op1].name().length() > 0);
82 QVERIFY(opList[op2].name().length() > 0);
83 QVERIFY(opList[op1].mcc().length() > 0);
84 QVERIFY(opList[op2].mcc().length() > 0);
85 QVERIFY(opList[op1].mnc().length() > 0);
86 QVERIFY(opList[op2].mnc().length() > 0);
87 QVERIFY(opList[op1].technologies().count() > 0);
88 QVERIFY(opList[op2].technologies().count() > 0);
90 QSignalSpy op1Register(&opList[op1], SIGNAL(registerComplete(bool)));
91 QSignalSpy op2Register(&opList[op2], SIGNAL(registerComplete(bool)));
92 QSignalSpy op1Status(&opList[op1], SIGNAL(statusChanged(QString)));
93 QSignalSpy op2Status(&opList[op2], SIGNAL(statusChanged(QString)));
95 QSignalSpy mode(m, SIGNAL(modeChanged(QString)));
96 QSignalSpy status(m, SIGNAL(statusChanged(QString)));
97 QSignalSpy lac(m, SIGNAL(locationAreaCodeChanged(uint)));
98 QSignalSpy cellId(m, SIGNAL(cellIdChanged(uint)));
99 QSignalSpy mcc(m, SIGNAL(mccChanged(QString)));
100 QSignalSpy mnc(m, SIGNAL(mncChanged(QString)));
101 QSignalSpy tech(m, SIGNAL(technologyChanged(QString)));
102 QSignalSpy name(m, SIGNAL(nameChanged(QString)));
103 QSignalSpy strength(m, SIGNAL(strengthChanged(uint)));
104 QSignalSpy base(m, SIGNAL(baseStationChanged(QString)));
106 opList[op2].registerOp();
108 opList[op1].registerOp();
111 QCOMPARE(op1Register.count(), 1);
112 QCOMPARE(op1Register.takeFirst().at(0).toBool(), true);
113 QCOMPARE(op2Register.count(), 1);
114 QCOMPARE(op2Register.takeFirst().at(0).toBool(), true);
115 QCOMPARE(op1Status.count(), 2);
116 QCOMPARE(op1Status.takeFirst().at(0).toString(), QString("available"));
117 QCOMPARE(op1Status.takeFirst().at(0).toString(), QString("current"));
118 QCOMPARE(op2Status.count(), 2);
119 QCOMPARE(op2Status.takeFirst().at(0).toString(), QString("current"));
120 QCOMPARE(op2Status.takeFirst().at(0).toString(), QString("available"));
122 QCOMPARE(mcc.count(), 2);
123 QCOMPARE(mnc.count(), 2);
124 QCOMPARE(name.count(), 2);
128 void cleanupTestCase()
135 OfonoNetworkRegistration *m;
138 QTEST_MAIN(TestOfonoNetworkOperator)
139 #include "test_ofononetworkoperator.moc"