Rewrite ModemManager test
[profile/ivi/ofono-qt.git] / tests / test_ofononetworkregistration.cpp
1 /*
2  * This file is part of ofono-qt
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
7  *
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.
11  *
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.
16  *
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
20  * 02110-1301 USA
21  *
22  */
23
24 #include <QtTest/QtTest>
25 #include <QtCore/QObject>
26
27 #include <ofononetworkregistration.h>
28
29 #include <QtDebug>
30
31
32 class TestOfonoNetworkRegistration : public QObject
33 {
34     Q_OBJECT
35
36 private slots:
37
38     void modeChanged(QString mode)
39     {
40         qDebug() << "modeChanged" << mode;
41     }
42
43     void statusChanged(QString status)
44     {
45         qDebug() << "statusChanged" << status;
46     }
47
48     void locationAreaCodeChanged(uint locationAreaCode)
49     {
50         qDebug() << "locationAreaCodeChanged" << locationAreaCode;
51     }
52
53     void cellIdChanged(uint cellId)
54     {
55         qDebug() << "cellIdChanged" << cellId;
56     }
57
58     void mccChanged(QString mcc)
59     {
60         qDebug() << "mccChanged" << mcc;
61     }
62
63     void mncChanged(QString mnc)
64     {
65         qDebug() << "mncChanged" << mnc;
66     }
67
68     void technologyChanged(QString technology)
69     {
70         qDebug() << "technologyChanged" << technology;
71     }
72
73     void nameChanged(QString name)
74     {
75         qDebug() << "nameChanged" << name;
76     }
77
78     void strengthChanged(uint strength)
79     {
80         qDebug() << "strengthChanged" << strength;
81     }
82
83     void baseStationChanged(QString baseStation)
84     {
85         qDebug() << "baseStationChanged" << baseStation;
86     }
87
88     void registerComplete(bool success)
89     {
90         qDebug() << "registerComplete:" << success;
91     }
92
93     void deregisterComplete(bool success)
94     {
95         qDebug() << "deregisterComplete:" << success;
96     }
97
98     void getOperatorsComplete(bool success, QStringList oplist)
99     {
100         qDebug() << "getOperatorsComplete:" << success << oplist;
101     }
102
103     void scanComplete(bool success, QStringList oplist)
104     {
105         qDebug() << "scanComplete:" << success << oplist;
106     }
107
108     void initTestCase()
109     {
110         m = new OfonoNetworkRegistration(OfonoModem::AutomaticSelect, QString(), this);
111
112         connect(m, SIGNAL(registerComplete(bool)), this, 
113                 SLOT(registerComplete(bool)));
114         connect(m, SIGNAL(deregisterComplete(bool)), this, 
115                 SLOT(deregisterComplete(bool)));
116     connect(m, SIGNAL(getOperatorsComplete(bool, QStringList)), 
117             this, SLOT(getOperatorsComplete(bool, QStringList)));
118     connect(m, SIGNAL(scanComplete(bool, QStringList)), 
119             this, SLOT(scanComplete(bool, QStringList)));
120
121         connect(m, SIGNAL(modeChanged(QString)), 
122                 this, SLOT(modeChanged(QString)));
123         connect(m, SIGNAL(statusChanged(QString)), 
124                 this, SLOT(statusChanged(QString)));
125         connect(m, SIGNAL(locationAreaCodeChanged(uint)), 
126                 this, SLOT(locationAreaCodeChanged(uint)));
127         connect(m, SIGNAL(cellIdChanged(uint)), 
128                 this, SLOT(cellIdChanged(uint)));
129         connect(m, SIGNAL(mccChanged(QString)), 
130                 this, SLOT(mccChanged(QString)));
131         connect(m, SIGNAL(mncChanged(QString)), 
132                 this, SLOT(mncChanged(QString)));
133         connect(m, SIGNAL(technologyChanged(QString)), 
134                 this, SLOT(technologyChanged(QString)));
135         connect(m, SIGNAL(nameChanged(QString)), 
136                 this, SLOT(nameChanged(QString)));
137         connect(m, SIGNAL(strengthChanged(uint)), 
138                 this, SLOT(strengthChanged(uint)));
139         connect(m, SIGNAL(baseStationChanged(QString)), 
140                 this, SLOT(baseStationChanged(QString)));
141
142     }
143
144     void testOfonoNetworkRegistration()
145     {
146         qDebug() << "mode():" << m->mode();
147         qDebug() << "status():" << m->status();
148         qDebug() << "lac():" << m->locationAreaCode();
149         qDebug() << "cellid():" << m->cellId();
150         qDebug() << "mobileCountryCode():" << m->mcc();
151         qDebug() << "mobileNetworkCode():" << m->mnc();
152         qDebug() << "technology():" << m->technology();
153         qDebug() << "name():" << m->name();
154         qDebug() << "strength():" << m->strength();
155         qDebug() << "baseStation():" << m->baseStation();
156         
157         m->requestGetOperators();
158         QTest::qWait(5000);
159
160         m->requestScan();
161         QTest::qWait(10000);
162         
163         m->requestDeregister();
164         QTest::qWait(10000);
165         m->requestRegister();
166
167         QTest::qWait(120000);
168     }
169
170
171     void cleanupTestCase()
172     {
173
174     }
175
176
177 private:
178     OfonoNetworkRegistration *m;
179 };
180
181 QTEST_MAIN(TestOfonoNetworkRegistration)
182 #include "test_ofononetworkregistration.moc"