2
* This file is part of ofono-qt
4
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: Alexander Kanavin <alex.kanavin@gmail.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 <qofono/qofononetworkregistration.h>
28
#include <qofono/qofononetworkoperator.h>
33
class TestQOfonoNetworkOperator : public QObject
40
m = new QOfonoNetworkRegistration(this);
41
m->setModemPath("/phonesim");
43
QCOMPARE(m->isValid(), true);
46
void testQOfonoNetworkOperator()
48
QSignalSpy scan(m, SIGNAL(scanComplete(bool, QStringList)));
51
QCOMPARE(scan.count(), 1);
52
QVariantList scanList = scan.takeFirst();
53
QCOMPARE(scanList.at(0).toBool(), true);
54
QStringList opIdList = scanList.at(1).toStringList();
55
QVERIFY(opIdList.count() > 0);
57
QList<QOfonoNetworkOperator> opList;
58
foreach(QString opId, opIdList)
60
QOfonoNetworkOperator op;
61
op.setOperatorPath(opId);
67
foreach(QOfonoNetworkOperator op, opList) {
68
if (op1 == -1 && op.status() == "current")
69
op1 = opList.indexOf(op);
70
if (op2 == -1 && op.status() == "available")
71
op2 = opList.indexOf(op);
75
QVERIFY(opList[op1].name().length() > 0);
76
QVERIFY(opList[op2].name().length() > 0);
77
QVERIFY(opList[op1].mcc().length() > 0);
78
QVERIFY(opList[op2].mcc().length() > 0);
79
QVERIFY(opList[op1].mnc().length() > 0);
80
QVERIFY(opList[op2].mnc().length() > 0);
81
QVERIFY(opList[op1].technologies().count() > 0);
82
QVERIFY(opList[op2].technologies().count() > 0);
84
QSignalSpy op1Register(&opList[op1], SIGNAL(registerComplete(bool)));
85
QSignalSpy op2Register(&opList[op2], SIGNAL(registerComplete(bool)));
86
QSignalSpy op1Status(&opList[op1], SIGNAL(statusChanged(QString)));
87
QSignalSpy op2Status(&opList[op2], SIGNAL(statusChanged(QString)));
89
QSignalSpy mode(m, SIGNAL(modeChanged(QString)));
90
QSignalSpy status(m, SIGNAL(statusChanged(QString)));
91
QSignalSpy lac(m, SIGNAL(locationAreaCodeChanged(uint)));
92
QSignalSpy cellId(m, SIGNAL(cellIdChanged(uint)));
93
QSignalSpy mcc(m, SIGNAL(mccChanged(QString)));
94
QSignalSpy mnc(m, SIGNAL(mncChanged(QString)));
95
QSignalSpy tech(m, SIGNAL(technologyChanged(QString)));
96
QSignalSpy name(m, SIGNAL(nameChanged(QString)));
97
QSignalSpy strength(m, SIGNAL(strengthChanged(uint)));
98
QSignalSpy base(m, SIGNAL(baseStationChanged(QString)));
100
opList[op2].registerOperator();
102
opList[op1].registerOperator();
105
QCOMPARE(op1Register.count(), 1);
106
QCOMPARE(op1Register.takeFirst().at(0).toBool(), true);
107
QCOMPARE(op2Register.count(), 1);
108
QCOMPARE(op2Register.takeFirst().at(0).toBool(), true);
109
QCOMPARE(op1Status.count(), 2);
110
QCOMPARE(op1Status.takeFirst().at(0).toString(), QString("available"));
111
QCOMPARE(op1Status.takeFirst().at(0).toString(), QString("current"));
112
QCOMPARE(op2Status.count(), 2);
113
QCOMPARE(op2Status.takeFirst().at(0).toString(), QString("current"));
114
QCOMPARE(op2Status.takeFirst().at(0).toString(), QString("available"));
116
QCOMPARE(mcc.count(), 2);
117
QCOMPARE(mnc.count(), 2);
118
QCOMPARE(name.count(), 2);
122
void cleanupTestCase()
129
QOfonoNetworkRegistration *m;
132
QTEST_MAIN(TestQOfonoNetworkOperator)
133
#include "tst_qofononetworkoperator.moc"