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"
|
|
28 |
#include "wlanqtutilsconnection.h"
|
|
29 |
|
|
30 |
// ---------------------------------------------------------
|
|
31 |
// class WlanQtUtilsCtxEsock
|
|
32 |
// ---------------------------------------------------------
|
|
33 |
|
|
34 |
WlanQtUtilsCtxEsock::WlanQtUtilsCtxEsock() :
|
|
35 |
startRetValue_(KErrNone)
|
|
36 |
{
|
|
37 |
}
|
|
38 |
|
|
39 |
WlanQtUtilsCtxEsock::~WlanQtUtilsCtxEsock()
|
|
40 |
{
|
|
41 |
}
|
|
42 |
|
|
43 |
void WlanQtUtilsCtxEsock::initialize()
|
|
44 |
{
|
|
45 |
startRetValue_ = KErrNone;
|
|
46 |
}
|
|
47 |
|
|
48 |
// ---------------------------------------------------------
|
|
49 |
// class WlanQtUtilsCtxActiveConn
|
|
50 |
// ---------------------------------------------------------
|
|
51 |
|
|
52 |
WlanQtUtilsCtxActiveConn::WlanQtUtilsCtxActiveConn() :
|
|
53 |
WlanQtUtilsConnection(), connMonBearerType_(EBearerUnknown), connMonConnectionStatus_(
|
|
54 |
KConnectionUninitialised), connMonWlanConnectionMode_(-1), connMonWlanSecurityMode_(-1),
|
|
55 |
applicationUids_()
|
|
56 |
{
|
|
57 |
}
|
|
58 |
|
|
59 |
WlanQtUtilsCtxActiveConn::~WlanQtUtilsCtxActiveConn()
|
|
60 |
{
|
|
61 |
}
|
|
62 |
|
|
63 |
// ---------------------------------------------------------
|
|
64 |
// class WlanQtUtilsCtxActiveConnections
|
|
65 |
// ---------------------------------------------------------
|
|
66 |
|
|
67 |
WlanQtUtilsCtxActiveConnections::WlanQtUtilsCtxActiveConnections() :
|
|
68 |
activeConnList_()
|
|
69 |
{
|
|
70 |
}
|
|
71 |
|
|
72 |
WlanQtUtilsCtxActiveConnections::~WlanQtUtilsCtxActiveConnections()
|
|
73 |
{
|
|
74 |
clearActiveConnList();
|
|
75 |
}
|
|
76 |
|
|
77 |
void WlanQtUtilsCtxActiveConnections::initialize()
|
|
78 |
{
|
|
79 |
clearActiveConnList();
|
|
80 |
}
|
|
81 |
|
|
82 |
void WlanQtUtilsCtxActiveConnections::createDefaultActiveConnList(int numberOfActiveConns,
|
|
83 |
int firstIapId)
|
|
84 |
{
|
|
85 |
clearActiveConnList();
|
|
86 |
for (int i = 0; i < numberOfActiveConns; i++) {
|
|
87 |
WlanQtUtilsCtxActiveConn *activeConn = new WlanQtUtilsCtxActiveConn();
|
|
88 |
|
|
89 |
activeConn->setConnectionId((i + 1) * 100);
|
|
90 |
activeConn->setIapId(firstIapId + i);
|
|
91 |
activeConn->connMonConnectionStatus_ = KLinkLayerOpen;
|
|
92 |
activeConn->setConnectionStatus(WlanQtUtils::ConnStatusConnected);
|
|
93 |
|
|
94 |
// WLAN connection.
|
|
95 |
activeConn->connMonBearerType_ = EBearerWLAN;
|
|
96 |
activeConn->connMonWlanSecurityMode_ = EConnMonSecurityOpen;
|
|
97 |
activeConn->connMonWlanConnectionMode_ = EConnMonInfraStructure;
|
|
98 |
activeConnList_.append(activeConn);
|
|
99 |
}
|
|
100 |
}
|
|
101 |
|
|
102 |
void WlanQtUtilsCtxActiveConnections::clearActiveConnList()
|
|
103 |
{
|
|
104 |
Q_FOREACH(WlanQtUtilsCtxActiveConn* activeConn, activeConnList_)
|
|
105 |
{
|
|
106 |
delete activeConn;
|
|
107 |
}
|
|
108 |
activeConnList_.clear();
|
|
109 |
}
|
|
110 |
|
|
111 |
void WlanQtUtilsCtxActiveConnections::verifyActiveConnList(
|
|
112 |
QList<WlanQtUtilsConnection*> activeConnList)
|
|
113 |
{
|
|
114 |
QCOMPARE(activeConnList.count(), activeConnList_.count());
|
|
115 |
|
|
116 |
for (int i = 0; i < activeConnList_.count(); i++) {
|
|
117 |
QCOMPARE(activeConnList[i]->connectionId(), activeConnList_[i]->connectionId());
|
|
118 |
QCOMPARE(activeConnList[i]->iapId(), activeConnList_[i]->iapId());
|
|
119 |
QCOMPARE(activeConnList[i]->connectionStatus(), activeConnList_[i]->connectionStatus());
|
|
120 |
}
|
|
121 |
}
|
|
122 |
|
|
123 |
WlanQtUtilsCtxActiveConn *WlanQtUtilsCtxActiveConnections::findActiveConn(uint connectionId) const
|
|
124 |
{
|
|
125 |
WlanQtUtilsCtxActiveConn *activeConn = NULL;
|
|
126 |
for (int i = 0; i < activeConnList_.count(); i++) {
|
|
127 |
if (activeConnList_[i]->connectionId() == connectionId) {
|
|
128 |
activeConn = activeConnList_[i];
|
|
129 |
}
|
|
130 |
}
|
|
131 |
Q_ASSERT(activeConn != NULL);
|
|
132 |
return activeConn;
|
|
133 |
}
|
|
134 |
|
|
135 |
// ---------------------------------------------------------
|
|
136 |
// class WlanQtUtilsWlanScanResult
|
|
137 |
// ---------------------------------------------------------
|
|
138 |
|
39
|
139 |
WlanQtUtilsWlanScan::WlanQtUtilsWlanScan() :
|
|
140 |
mScanResultIterator(0),
|
|
141 |
mWlanScanResultList(),
|
|
142 |
mCompleteWlanScan(true),
|
|
143 |
mScanRetValue(KErrNone)
|
31
|
144 |
{
|
|
145 |
}
|
|
146 |
|
39
|
147 |
WlanQtUtilsWlanScan::~WlanQtUtilsWlanScan()
|
31
|
148 |
{
|
|
149 |
clearWlanScanResultList();
|
|
150 |
}
|
|
151 |
|
39
|
152 |
void WlanQtUtilsWlanScan::initialize()
|
31
|
153 |
{
|
|
154 |
clearWlanScanResultList();
|
39
|
155 |
mCompleteWlanScan = true;
|
|
156 |
mScanRetValue = KErrNone;
|
31
|
157 |
}
|
|
158 |
|
39
|
159 |
void WlanQtUtilsWlanScan::createDefaultWlanScanResultList(int numberOfWlanAps)
|
31
|
160 |
{
|
|
161 |
clearWlanScanResultList();
|
|
162 |
for (int i = 0; i < numberOfWlanAps; i++) {
|
39
|
163 |
QSharedPointer<WlanQtUtilsAp> ap(new WlanQtUtilsAp());
|
31
|
164 |
ap->setValue(WlanQtUtilsAp::ConfIdSsid, "TestWlanAp" + QString::number(i + 1));
|
39
|
165 |
ap->setValue(WlanQtUtilsAp::ConfIdBssid, QByteArray("123456"));
|
31
|
166 |
ap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 20);
|
|
167 |
ap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
|
|
168 |
ap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
|
|
169 |
ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
|
39
|
170 |
ap->setValue(WlanQtUtilsAp::ConfIdWpsSupported, false);
|
|
171 |
mWlanScanResultList.append(ap);
|
31
|
172 |
}
|
|
173 |
}
|
|
174 |
|
39
|
175 |
void WlanQtUtilsWlanScan::clearWlanScanResultList()
|
31
|
176 |
{
|
39
|
177 |
mWlanScanResultList.clear();
|
31
|
178 |
}
|
|
179 |
|
39
|
180 |
void WlanQtUtilsWlanScan::verifyWlanScanResultList(
|
|
181 |
QList< QSharedPointer<WlanQtUtilsAp> > wlanApList)
|
31
|
182 |
{
|
39
|
183 |
QCOMPARE(wlanApList.count(), mWlanScanResultList.count());
|
31
|
184 |
|
39
|
185 |
for (int i = 0; i < mWlanScanResultList.count(); i++) {
|
|
186 |
QCOMPARE(
|
|
187 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdSsid),
|
|
188 |
mWlanScanResultList[i]->value(WlanQtUtilsAp::ConfIdSsid));
|
|
189 |
QCOMPARE(
|
|
190 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdBssid),
|
|
191 |
mWlanScanResultList[i]->value(WlanQtUtilsAp::ConfIdBssid));
|
|
192 |
QCOMPARE(
|
|
193 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdSignalStrength),
|
|
194 |
mWlanScanResultList[i]->value(WlanQtUtilsAp::ConfIdSignalStrength));
|
|
195 |
QCOMPARE(
|
|
196 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdConnectionMode),
|
|
197 |
mWlanScanResultList[i]->value(WlanQtUtilsAp::ConfIdConnectionMode));
|
|
198 |
QCOMPARE(
|
|
199 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdSecurityMode),
|
|
200 |
mWlanScanResultList[i]->value(WlanQtUtilsAp::ConfIdSecurityMode));
|
|
201 |
QCOMPARE(
|
|
202 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdWpaPskUse),
|
|
203 |
mWlanScanResultList[i]->value(WlanQtUtilsAp::ConfIdWpaPskUse));
|
|
204 |
QCOMPARE(
|
|
205 |
wlanApList[i]->value(WlanQtUtilsAp::ConfIdWpsSupported),
|
|
206 |
mWlanScanResultList[i]->value(WlanQtUtilsAp::ConfIdWpsSupported));
|
31
|
207 |
}
|
|
208 |
}
|
|
209 |
|
|
210 |
// ---------------------------------------------------------
|
|
211 |
// class WlanQtUtilsCtxConnMon
|
|
212 |
// ---------------------------------------------------------
|
|
213 |
|
|
214 |
WlanQtUtilsCtxConnMon::WlanQtUtilsCtxConnMon() :
|
39
|
215 |
activeConnections_()
|
31
|
216 |
{
|
|
217 |
}
|
|
218 |
|
|
219 |
WlanQtUtilsCtxConnMon::~WlanQtUtilsCtxConnMon()
|
|
220 |
{
|
|
221 |
}
|
|
222 |
|
|
223 |
void WlanQtUtilsCtxConnMon::initialize()
|
|
224 |
{
|
|
225 |
activeConnections_.initialize();
|
|
226 |
}
|
|
227 |
|
|
228 |
// ---------------------------------------------------------
|
|
229 |
// class WlanQtUtilsCtxIct
|
|
230 |
// ---------------------------------------------------------
|
|
231 |
|
|
232 |
WlanQtUtilsCtxIct::WlanQtUtilsCtxIct()
|
|
233 |
{
|
|
234 |
}
|
|
235 |
|
|
236 |
WlanQtUtilsCtxIct::~WlanQtUtilsCtxIct()
|
|
237 |
{
|
|
238 |
}
|
|
239 |
|
|
240 |
void WlanQtUtilsCtxIct::initialize()
|
|
241 |
{
|
|
242 |
}
|
|
243 |
|
|
244 |
// ---------------------------------------------------------
|
|
245 |
// class WlanQtUtilsTestContext
|
|
246 |
// ---------------------------------------------------------
|
|
247 |
|
|
248 |
WlanQtUtilsTestContext::WlanQtUtilsTestContext() :
|
|
249 |
esock_(), connMon_(), ict_()
|
|
250 |
{
|
|
251 |
}
|
|
252 |
|
|
253 |
WlanQtUtilsTestContext::~WlanQtUtilsTestContext()
|
|
254 |
{
|
|
255 |
}
|
|
256 |
|
|
257 |
void WlanQtUtilsTestContext::initialize()
|
|
258 |
{
|
|
259 |
esock_.initialize();
|
|
260 |
connMon_.initialize();
|
|
261 |
ict_.initialize();
|
39
|
262 |
mScan.initialize();
|
31
|
263 |
}
|