2
* This file is part of ofono-qt
4
* Copyright (C) 2010-2011 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 <ofononetworkregistration.h>
32
class TestOfonoNetworkRegistration : public QObject
39
m = new OfonoNetworkRegistration(OfonoModem::ManualSelect, "/phonesim", this);
40
QCOMPARE(m->modem()->isValid(), true);
42
if (!m->modem()->powered()) {
43
m->modem()->setPowered(true);
46
if (!m->modem()->online()) {
47
m->modem()->setOnline(true);
50
QCOMPARE(m->isValid(), true);
53
void testOfonoNetworkRegistration()
55
QSignalSpy mode(m, SIGNAL(modeChanged(QString)));
56
QSignalSpy status(m, SIGNAL(statusChanged(QString)));
57
QSignalSpy lac(m, SIGNAL(locationAreaCodeChanged(uint)));
58
QSignalSpy cellId(m, SIGNAL(cellIdChanged(uint)));
59
QSignalSpy mcc(m, SIGNAL(mccChanged(QString)));
60
QSignalSpy mnc(m, SIGNAL(mncChanged(QString)));
61
QSignalSpy tech(m, SIGNAL(technologyChanged(QString)));
62
QSignalSpy name(m, SIGNAL(nameChanged(QString)));
63
QSignalSpy strength(m, SIGNAL(strengthChanged(uint)));
64
QSignalSpy base(m, SIGNAL(baseStationChanged(QString)));
66
QSignalSpy registerS(m, SIGNAL(registerComplete(bool)));
67
QSignalSpy scan(m, SIGNAL(scanComplete(bool, QStringList)));
68
QSignalSpy getOp(m, SIGNAL(getOperatorsComplete(bool, QStringList)));
70
QVERIFY(m->mode().length() > 0);
71
QCOMPARE(m->status(), QString("registered"));
72
QCOMPARE(m->mcc(), QString("234"));
73
QCOMPARE(m->mnc(), QString("01"));
74
QVERIFY(m->name().length() > 0);
75
QCOMPARE(m->strength(), uint(100));
79
QCOMPARE(scan.count(), 1);
80
QVariantList scanList = scan.takeFirst();
81
QCOMPARE(scanList.at(0).toBool(), true);
82
QStringList scanOpList = scanList.at(1).toStringList();
83
QVERIFY(scanOpList.count() > 0);
87
QCOMPARE(getOp.count(), 1);
88
QVariantList getList = getOp.takeFirst();
89
QCOMPARE(getList.at(0).toBool(), true);
90
QStringList getOpList = getList.at(1).toStringList();
91
QVERIFY(getOpList.count() > 0);
92
QCOMPARE(scanOpList, getOpList);
96
QCOMPARE(registerS.count(), 1);
97
QCOMPARE(registerS.takeFirst().at(0).toBool(), true);
98
QCOMPARE(m->mode(), QString("auto"));
100
m->modem()->setOnline(false);
102
QCOMPARE(m->isValid(), false);
103
m->modem()->setOnline(true);
105
QCOMPARE(status.count(), 1);
106
QCOMPARE(status.takeFirst().at(0).toString(), QString("registered"));
107
QCOMPARE(mcc.count(), 1);
108
QCOMPARE(mcc.takeFirst().at(0).toString(), QString("234"));
109
QCOMPARE(mnc.count(), 1);
110
QCOMPARE(mnc.takeFirst().at(0).toString(), QString("01"));
111
QCOMPARE(name.count(), 2);
112
QVERIFY(name.takeFirst().at(0).toString().length() > 0);
113
QVERIFY(name.takeFirst().at(0).toString().length() > 0);
114
QCOMPARE(strength.count(), 1);
115
QCOMPARE(strength.takeFirst().at(0).toUInt(), uint(100));
119
void cleanupTestCase()
126
OfonoNetworkRegistration *m;
129
QTEST_MAIN(TestOfonoNetworkRegistration)
130
#include "test_ofononetworkregistration.moc"