31
|
1 |
/*
|
|
2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* This is the source file for Connection Utilities test context.
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QObject>
|
|
19 |
#include <QSharedPointer>
|
|
20 |
#include <QTest>
|
|
21 |
#include <rconnmon.h>
|
|
22 |
#include <nifvar.h>
|
|
23 |
#include <cmmanager_shim.h>
|
|
24 |
|
|
25 |
#include "wlanqtutils.h"
|
|
26 |
#include "wlanqtutilstestcontext.h"
|
|
27 |
#include "wlanqtutilsap.h"
|
53
|
28 |
#include "wlanqtutilsiap.h"
|
31
|
29 |
#include "wlanqtutilsconnection.h"
|
|
30 |
|
|
31 |
// ---------------------------------------------------------
|
|
32 |
// class WlanQtUtilsCtxEsock
|
|
33 |
// ---------------------------------------------------------
|
|
34 |
|
|
35 |
WlanQtUtilsCtxEsock::WlanQtUtilsCtxEsock() :
|
|
36 |
startRetValue_(KErrNone)
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
WlanQtUtilsCtxEsock::~WlanQtUtilsCtxEsock()
|
|
41 |
{
|
|
42 |
}
|
|
43 |
|
|
44 |
void WlanQtUtilsCtxEsock::initialize()
|
|
45 |
{
|
|
46 |
startRetValue_ = KErrNone;
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------
|
|
50 |
// class WlanQtUtilsCtxActiveConn
|
|
51 |
// ---------------------------------------------------------
|
|
52 |
|
|
53 |
WlanQtUtilsCtxActiveConn::WlanQtUtilsCtxActiveConn() :
|
|
54 |
WlanQtUtilsConnection(), connMonBearerType_(EBearerUnknown), connMonConnectionStatus_(
|
|
55 |
KConnectionUninitialised), connMonWlanConnectionMode_(-1), connMonWlanSecurityMode_(-1),
|
|
56 |
applicationUids_()
|
|
57 |
{
|
|
58 |
}
|
|
59 |
|
|
60 |
WlanQtUtilsCtxActiveConn::~WlanQtUtilsCtxActiveConn()
|
|
61 |
{
|
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------
|
|
65 |
// class WlanQtUtilsCtxActiveConnections
|
|
66 |
// ---------------------------------------------------------
|
|
67 |
|
|
68 |
WlanQtUtilsCtxActiveConnections::WlanQtUtilsCtxActiveConnections() :
|
|
69 |
activeConnList_()
|
|
70 |
{
|
|
71 |
}
|
|
72 |
|
|
73 |
WlanQtUtilsCtxActiveConnections::~WlanQtUtilsCtxActiveConnections()
|
|
74 |
{
|
|
75 |
clearActiveConnList();
|
|
76 |
}
|
|
77 |
|
|
78 |
void WlanQtUtilsCtxActiveConnections::initialize()
|
|
79 |
{
|
|
80 |
clearActiveConnList();
|
|
81 |
}
|
|
82 |
|
|
83 |
void WlanQtUtilsCtxActiveConnections::createDefaultActiveConnList(int numberOfActiveConns,
|
|
84 |
int firstIapId)
|
|
85 |
{
|
|
86 |
clearActiveConnList();
|
|
87 |
for (int i = 0; i < numberOfActiveConns; i++) {
|
|
88 |
WlanQtUtilsCtxActiveConn *activeConn = new WlanQtUtilsCtxActiveConn();
|
|
89 |
|
|
90 |
activeConn->setConnectionId((i + 1) * 100);
|
|
91 |
activeConn->setIapId(firstIapId + i);
|
|
92 |
activeConn->connMonConnectionStatus_ = KLinkLayerOpen;
|
|
93 |
activeConn->setConnectionStatus(WlanQtUtils::ConnStatusConnected);
|
|
94 |
|
|
95 |
// WLAN connection.
|
|
96 |
activeConn->connMonBearerType_ = EBearerWLAN;
|
|
97 |
activeConn->connMonWlanSecurityMode_ = EConnMonSecurityOpen;
|
|
98 |
activeConn->connMonWlanConnectionMode_ = EConnMonInfraStructure;
|
|
99 |
activeConnList_.append(activeConn);
|
|
100 |
}
|
|
101 |
}
|
|
102 |
|
|
103 |
void WlanQtUtilsCtxActiveConnections::clearActiveConnList()
|
|
104 |
{
|
|
105 |
Q_FOREACH(WlanQtUtilsCtxActiveConn* activeConn, activeConnList_)
|
|
106 |
{
|
|
107 |
delete activeConn;
|
|
108 |
}
|
|
109 |
activeConnList_.clear();
|
|
110 |
}
|
|
111 |
|
|
112 |
void WlanQtUtilsCtxActiveConnections::verifyActiveConnList(
|
|
113 |
QList<WlanQtUtilsConnection*> activeConnList)
|
|
114 |
{
|
|
115 |
QCOMPARE(activeConnList.count(), activeConnList_.count());
|
|
116 |
|
|
117 |
for (int i = 0; i < activeConnList_.count(); i++) {
|
|
118 |
QCOMPARE(activeConnList[i]->connectionId(), activeConnList_[i]->connectionId());
|
|
119 |
QCOMPARE(activeConnList[i]->iapId(), activeConnList_[i]->iapId());
|
|
120 |
QCOMPARE(activeConnList[i]->connectionStatus(), activeConnList_[i]->connectionStatus());
|
|
121 |
}
|
|
122 |
}
|
|
123 |
|
|
124 |
WlanQtUtilsCtxActiveConn *WlanQtUtilsCtxActiveConnections::findActiveConn(uint connectionId) const
|
|
125 |
{
|
|
126 |
WlanQtUtilsCtxActiveConn *activeConn = NULL;
|
|
127 |
for (int i = 0; i < activeConnList_.count(); i++) {
|
|
128 |
if (activeConnList_[i]->connectionId() == connectionId) {
|
|
129 |
activeConn = activeConnList_[i];
|
|
130 |
}
|
|
131 |
}
|
|
132 |
Q_ASSERT(activeConn != NULL);
|
|
133 |
return activeConn;
|
|
134 |
}
|
|
135 |
|
|
136 |
// ---------------------------------------------------------
|
|
137 |
// class WlanQtUtilsWlanScanResult
|
|
138 |
// ---------------------------------------------------------
|
|
139 |
|
39
|
140 |
WlanQtUtilsWlanScan::WlanQtUtilsWlanScan() :
|
|
141 |
mScanResultIterator(0),
|
53
|
142 |
mWlanScanIapResultList(),
|
|
143 |
mWlanScanApResultList(),
|
|
144 |
mCompleteWlanIapScan(true),
|
|
145 |
mCompleteWlanApScan(true),
|
|
146 |
mIapScanRetValue(KErrNone),
|
|
147 |
mApScanRetValue(KErrNone)
|
31
|
148 |
{
|
|
149 |
}
|
|
150 |
|
39
|
151 |
WlanQtUtilsWlanScan::~WlanQtUtilsWlanScan()
|
31
|
152 |
{
|
53
|
153 |
clearWlanScanIapResultList();
|
|
154 |
clearWlanScanApResultList();
|
31
|
155 |
}
|
|
156 |
|
39
|
157 |
void WlanQtUtilsWlanScan::initialize()
|
31
|
158 |
{
|
53
|
159 |
clearWlanScanIapResultList();
|
|
160 |
clearWlanScanApResultList();
|
|
161 |
mCompleteWlanIapScan = true;
|
|
162 |
mCompleteWlanApScan = true;
|
|
163 |
mIapScanRetValue = KErrNone;
|
|
164 |
mApScanRetValue = KErrNone;
|
|
165 |
}
|
|
166 |
|
|
167 |
void WlanQtUtilsWlanScan::createDefaultWlanScanIapResultList(int numberOfWlanIaps)
|
|
168 |
{
|
|
169 |
clearWlanScanIapResultList();
|
|
170 |
|
|
171 |
for (int i = 0; i < numberOfWlanIaps; i++) {
|
|
172 |
QSharedPointer<WlanQtUtilsIap> iap(new WlanQtUtilsIap());
|
|
173 |
iap->setValue(WlanQtUtilsIap::ConfIdIapId, i);
|
|
174 |
iap->setValue(WlanQtUtilsIap::ConfIdName, "TestWlanAp" + QString::number(i + 1));
|
|
175 |
// ConfIdNetworkId?
|
|
176 |
iap->setValue(WlanQtUtilsAp::ConfIdSsid, "TestWlanAp" + QString::number(i + 1));
|
|
177 |
iap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 20);
|
|
178 |
iap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
|
|
179 |
iap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
|
|
180 |
iap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
|
|
181 |
mWlanScanIapResultList.append(iap);
|
|
182 |
}
|
31
|
183 |
}
|
|
184 |
|
53
|
185 |
void WlanQtUtilsWlanScan::clearWlanScanIapResultList()
|
|
186 |
{
|
|
187 |
mWlanScanIapResultList.clear();
|
|
188 |
}
|
|
189 |
|
|
190 |
void WlanQtUtilsWlanScan::verifyWlanScanIapResultList(
|
|
191 |
QList< QSharedPointer<WlanQtUtilsIap> > wlanIapList)
|
31
|
192 |
{
|
53
|
193 |
QCOMPARE(wlanIapList.count(), mWlanScanIapResultList.count());
|
|
194 |
|
|
195 |
for (int i = 0; i < mWlanScanIapResultList.count(); i++) {
|
|
196 |
QCOMPARE(
|
|
197 |
wlanIapList[i]->value(WlanQtUtilsIap::ConfIdIapId),
|
|
198 |
mWlanScanIapResultList[i]->value(WlanQtUtilsIap::ConfIdIapId));
|
|
199 |
QCOMPARE(
|
|
200 |
wlanIapList[i]->value(WlanQtUtilsAp::ConfIdSignalStrength),
|
|
201 |
mWlanScanIapResultList[i]->value(WlanQtUtilsAp::ConfIdSignalStrength));
|
|
202 |
//QCOMPARE(
|
|
203 |
// wlanIapList[i]->value(WlanQtUtilsAp::ConfIdSsid),
|
|
204 |
// mWlanScanApResultList[i]->value(WlanQtUtilsAp::ConfIdSsid));
|
|
205 |
}
|
|
206 |
}
|
|
207 |
|
|
208 |
|
|
209 |
void WlanQtUtilsWlanScan::createDefaultWlanScanApResultList(int numberOfWlanAps)
|
|
210 |
{
|
|
211 |
clearWlanScanApResultList();
|
|
212 |
|
31
|
213 |
for (int i = 0; i < numberOfWlanAps; i++) {
|
39
|
214 |
QSharedPointer<WlanQtUtilsAp> ap(new WlanQtUtilsAp());
|
31
|
215 |
ap->setValue(WlanQtUtilsAp::ConfIdSsid, "TestWlanAp" + QString::number(i + 1));
|
39
|
216 |
ap->setValue(WlanQtUtilsAp::ConfIdBssid, QByteArray("123456"));
|
31
|
217 |
ap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 20);
|
|
218 |
ap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
|
|
219 |
ap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
|
|
220 |
ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
|
39
|
221 |
ap->setValue(WlanQtUtilsAp::ConfIdWpsSupported, false);
|
53
|
222 |
mWlanScanApResultList.append(ap);
|
31
|
223 |
}
|
|
224 |
}
|
|
225 |
|
53
|
226 |
void WlanQtUtilsWlanScan::clearWlanScanApResultList()
|
31
|
227 |
{
|
53
|
228 |
mWlanScanApResultList.clear();
|
31
|
229 |
}
|
|
230 |
|
53
|
231 |
void WlanQtUtilsWlanScan::verifyWlanScanApResultList(
|
39
|
232 |
QList< QSharedPointer<WlanQtUtilsAp> > wlanApList)
|
31
|
233 |
{
|
53
|
234 |
QCOMPARE(wlanApList.count(), mWlanScanApResultList.count());
|
31
|
235 |
|
53
|
236 |
for (int i = 0; i < mWlanScanApResultList.count(); i++) {
|
39
|
237 |
QCOMPARE(
|
|
238 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdSsid),
|
53
|
239 |
mWlanScanApResultList[i]->value(WlanQtUtilsAp::ConfIdSsid));
|
39
|
240 |
QCOMPARE(
|
|
241 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdBssid),
|
53
|
242 |
mWlanScanApResultList[i]->value(WlanQtUtilsAp::ConfIdBssid));
|
39
|
243 |
QCOMPARE(
|
|
244 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdSignalStrength),
|
53
|
245 |
mWlanScanApResultList[i]->value(WlanQtUtilsAp::ConfIdSignalStrength));
|
39
|
246 |
QCOMPARE(
|
|
247 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdConnectionMode),
|
53
|
248 |
mWlanScanApResultList[i]->value(WlanQtUtilsAp::ConfIdConnectionMode));
|
39
|
249 |
QCOMPARE(
|
|
250 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdSecurityMode),
|
53
|
251 |
mWlanScanApResultList[i]->value(WlanQtUtilsAp::ConfIdSecurityMode));
|
39
|
252 |
QCOMPARE(
|
|
253 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdWpaPskUse),
|
53
|
254 |
mWlanScanApResultList[i]->value(WlanQtUtilsAp::ConfIdWpaPskUse));
|
39
|
255 |
QCOMPARE(
|
|
256 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdWpsSupported),
|
53
|
257 |
mWlanScanApResultList[i]->value(WlanQtUtilsAp::ConfIdWpsSupported));
|
31
|
258 |
}
|
|
259 |
}
|
|
260 |
|
|
261 |
// ---------------------------------------------------------
|
|
262 |
// class WlanQtUtilsCtxConnMon
|
|
263 |
// ---------------------------------------------------------
|
|
264 |
|
|
265 |
WlanQtUtilsCtxConnMon::WlanQtUtilsCtxConnMon() :
|
39
|
266 |
activeConnections_()
|
31
|
267 |
{
|
|
268 |
}
|
|
269 |
|
|
270 |
WlanQtUtilsCtxConnMon::~WlanQtUtilsCtxConnMon()
|
|
271 |
{
|
|
272 |
}
|
|
273 |
|
|
274 |
void WlanQtUtilsCtxConnMon::initialize()
|
|
275 |
{
|
|
276 |
activeConnections_.initialize();
|
|
277 |
}
|
|
278 |
|
|
279 |
// ---------------------------------------------------------
|
|
280 |
// class WlanQtUtilsCtxIct
|
|
281 |
// ---------------------------------------------------------
|
|
282 |
|
|
283 |
WlanQtUtilsCtxIct::WlanQtUtilsCtxIct()
|
|
284 |
{
|
|
285 |
}
|
|
286 |
|
|
287 |
WlanQtUtilsCtxIct::~WlanQtUtilsCtxIct()
|
|
288 |
{
|
|
289 |
}
|
|
290 |
|
|
291 |
void WlanQtUtilsCtxIct::initialize()
|
|
292 |
{
|
|
293 |
}
|
|
294 |
|
|
295 |
// ---------------------------------------------------------
|
|
296 |
// class WlanQtUtilsTestContext
|
|
297 |
// ---------------------------------------------------------
|
|
298 |
|
|
299 |
WlanQtUtilsTestContext::WlanQtUtilsTestContext() :
|
|
300 |
esock_(), connMon_(), ict_()
|
|
301 |
{
|
|
302 |
}
|
|
303 |
|
|
304 |
WlanQtUtilsTestContext::~WlanQtUtilsTestContext()
|
|
305 |
{
|
|
306 |
}
|
|
307 |
|
|
308 |
void WlanQtUtilsTestContext::initialize()
|
|
309 |
{
|
|
310 |
esock_.initialize();
|
|
311 |
connMon_.initialize();
|
|
312 |
ict_.initialize();
|
39
|
313 |
mScan.initialize();
|
31
|
314 |
}
|