|
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 header file for Wlan Qt Utilities test context. |
|
16 */ |
|
17 |
|
18 #ifndef WLANQTUTILSTESTCONTEXT_H |
|
19 #define WLANQTUTILSTESTCONTEXT_H |
|
20 |
|
21 #include <QObject> |
|
22 #include <QSharedPointer> |
|
23 #include "wlanqtutilsconnection.h" |
|
24 |
|
25 class WlanQtUtilsAp; |
|
26 |
|
27 /** |
|
28 * This is context for esock library. |
|
29 */ |
|
30 class WlanQtUtilsCtxEsock : public QObject |
|
31 { |
|
32 Q_OBJECT |
|
33 |
|
34 public: |
|
35 WlanQtUtilsCtxEsock(); |
|
36 ~WlanQtUtilsCtxEsock(); |
|
37 |
|
38 /** |
|
39 * Initializes context. |
|
40 */ |
|
41 void initialize(); |
|
42 |
|
43 /** Return value of RConnection::Start(). */ |
|
44 int startRetValue_; |
|
45 }; |
|
46 |
|
47 /** |
|
48 * This class is a helper class for testing purposes. It derives all properties of WlanQtUtilsConnection. |
|
49 * In addition, this class contains member variables for setting some Connection Monitor specific |
|
50 * values which cannot be easily generated from member variables of WlanQtUtilsConnection. |
|
51 * E.g., connection status has different enum in Connection Monitor and Wlan Qt Utilities. This class |
|
52 * enables setting both of those. Connmon version is set so that the stub can return it when |
|
53 * requested, and Wlan Qt Utilities version is used for verifying that tested code returns right |
|
54 * value. |
|
55 */ |
|
56 class WlanQtUtilsCtxActiveConn : public WlanQtUtilsConnection |
|
57 { |
|
58 public: |
|
59 WlanQtUtilsCtxActiveConn(); |
|
60 ~WlanQtUtilsCtxActiveConn(); |
|
61 |
|
62 /** Bearer type in connmon format. */ |
|
63 int connMonBearerType_; |
|
64 /** Connection status in connmon format. */ |
|
65 int connMonConnectionStatus_; |
|
66 /** WLAN connection mode in connmon format. */ |
|
67 int connMonWlanConnectionMode_; |
|
68 /** WLAN security mode in connmon format. */ |
|
69 int connMonWlanSecurityMode_; |
|
70 /** Application UIDs that map to application strings. */ |
|
71 QList<int> applicationUids_; |
|
72 }; |
|
73 |
|
74 /** |
|
75 * This class represents active connections. |
|
76 */ |
|
77 class WlanQtUtilsCtxActiveConnections : public QObject |
|
78 { |
|
79 Q_OBJECT |
|
80 |
|
81 public: |
|
82 WlanQtUtilsCtxActiveConnections(); |
|
83 ~WlanQtUtilsCtxActiveConnections(); |
|
84 |
|
85 /** |
|
86 * Initializes context. |
|
87 */ |
|
88 void initialize(); |
|
89 |
|
90 /** |
|
91 * Creates a list of active connections for scan results. |
|
92 * |
|
93 * @param[in] numberOfActiveConns Number of active connections that are created. |
|
94 * @param[in] firstIapId IAP ID of the first connection to be created. |
|
95 */ |
|
96 void createDefaultActiveConnList(int numberOfActiveConns, int firstIapId); |
|
97 |
|
98 /** |
|
99 * Verifies that the given active connection list returned by the real application matches |
|
100 * with the one in the context. |
|
101 * |
|
102 * @param[in] activeConnList Active connections that are verified against the context. |
|
103 */ |
|
104 void verifyActiveConnList(QList<WlanQtUtilsConnection *> activeConnList); |
|
105 |
|
106 /** |
|
107 * Finds an active connection matching with the given connection ID from the context. |
|
108 * Asserts if connection with given connection ID is not found. |
|
109 * |
|
110 * @param connectionId Connection ID. |
|
111 * @return Active connection. |
|
112 */ |
|
113 WlanQtUtilsCtxActiveConn *findActiveConn(uint connectionId) const; |
|
114 |
|
115 /** |
|
116 * List of active connections that RConnectionMonitor stub will return in response to |
|
117 * RConnectionMonitor::Get*Attribute() functions. |
|
118 */ |
|
119 QList<WlanQtUtilsCtxActiveConn *> activeConnList_; |
|
120 |
|
121 // TODO: We need return values for all different RConnectionMonitor::Get*Attribute() functions |
|
122 // to test error cases. |
|
123 |
|
124 private: |
|
125 |
|
126 /** |
|
127 * Destroys and clears the list of WLAN APs. |
|
128 */ |
|
129 void clearActiveConnList(); |
|
130 }; |
|
131 |
|
132 /** |
|
133 * This class represents WLAN functionality test context. E.g. APs that |
|
134 * represent the results of WLAN scanning are stored here. |
|
135 */ |
|
136 class WlanQtUtilsWlanScan : public QObject |
|
137 { |
|
138 Q_OBJECT |
|
139 |
|
140 public: |
|
141 WlanQtUtilsWlanScan(); |
|
142 ~WlanQtUtilsWlanScan(); |
|
143 |
|
144 /** |
|
145 * Initializes context. |
|
146 */ |
|
147 void initialize(); |
|
148 |
|
149 /** |
|
150 * Creates a list of WLAN IAPs for scan results. |
|
151 * |
|
152 * @param[in] numberOfWlanIaps Number of WLAN IAPs that are created. |
|
153 */ |
|
154 void createDefaultWlanScanIapResultList(int numberOfWlanIaps); |
|
155 |
|
156 /** |
|
157 * Verifies that the given WLAN IAP list returned by the real application matches |
|
158 * with the one in the context. |
|
159 * |
|
160 * @param[in] wlanIapList WLAN IAPs that are verified against the context. |
|
161 */ |
|
162 void verifyWlanScanIapResultList( |
|
163 QList< QSharedPointer<WlanQtUtilsIap> > wlanIapList); |
|
164 |
|
165 /** |
|
166 * Creates a list of WLAN APs for scan results. |
|
167 * |
|
168 * @param[in] numberOfWlanAps Number of WLAN APs that are created. |
|
169 */ |
|
170 void createDefaultWlanScanApResultList(int numberOfWlanAps); |
|
171 |
|
172 /** |
|
173 * Verifies that the given WLAN AP list returned by the real application matches |
|
174 * with the one in the context. |
|
175 * |
|
176 * @param[in] wlanApList WLAN APs that are verified against the context. |
|
177 */ |
|
178 void verifyWlanScanApResultList( |
|
179 QList< QSharedPointer<WlanQtUtilsAp> > wlanApList); // TODO: Maybe boolean return value |
|
180 |
|
181 // Scan result list iterator. Holds the current index, starting from zero (0). |
|
182 int mScanResultIterator; |
|
183 |
|
184 // List of WLAN IAPs that WLAN Management API stub will return when |
|
185 // requesting for wlan IAP scan results. |
|
186 QList< QSharedPointer<WlanQtUtilsIap> > mWlanScanIapResultList; |
|
187 |
|
188 // List of WLAN access points that WLAN Management API stub will return when |
|
189 // requesting for wlan scan results. |
|
190 QList< QSharedPointer<WlanQtUtilsAp> > mWlanScanApResultList; |
|
191 |
|
192 /** |
|
193 * Should IAP scan be completed immediately or not? |
|
194 */ |
|
195 bool mCompleteWlanIapScan; |
|
196 |
|
197 /** |
|
198 * Should AP scan be completed immediately or not? |
|
199 */ |
|
200 bool mCompleteWlanApScan; |
|
201 |
|
202 /** Return value of IAP scan request. */ |
|
203 int mIapScanRetValue; |
|
204 |
|
205 /** Return value of AP scan request. */ |
|
206 int mApScanRetValue; |
|
207 |
|
208 private: |
|
209 |
|
210 /** |
|
211 * Destroys and clears the list of WLAN IAPs. |
|
212 */ |
|
213 void clearWlanScanIapResultList(); |
|
214 |
|
215 /** |
|
216 * Destroys and clears the list of WLAN APs. |
|
217 */ |
|
218 void clearWlanScanApResultList(); |
|
219 }; |
|
220 |
|
221 /** |
|
222 * Test context for RConnectionMonitor. |
|
223 */ |
|
224 class WlanQtUtilsCtxConnMon : public QObject |
|
225 { |
|
226 Q_OBJECT |
|
227 |
|
228 public: |
|
229 WlanQtUtilsCtxConnMon(); |
|
230 ~WlanQtUtilsCtxConnMon(); |
|
231 |
|
232 /** |
|
233 * Initializes context. |
|
234 */ |
|
235 void initialize(); |
|
236 |
|
237 /** List of active connections. */ |
|
238 WlanQtUtilsCtxActiveConnections activeConnections_; |
|
239 }; |
|
240 |
|
241 /** |
|
242 * Test context for Internet connectivity test library. |
|
243 */ |
|
244 class WlanQtUtilsCtxIct : public QObject |
|
245 { |
|
246 Q_OBJECT |
|
247 |
|
248 public: |
|
249 WlanQtUtilsCtxIct(); |
|
250 ~WlanQtUtilsCtxIct(); |
|
251 |
|
252 /** |
|
253 * Initializes context. |
|
254 */ |
|
255 void initialize(); |
|
256 }; |
|
257 |
|
258 /** |
|
259 * Test context. The purpose of this context is to provide values that are used in stubs |
|
260 * and in verification of outputs in test cases. |
|
261 * |
|
262 * In stubs, context is used to verify the inputs of parameters and to set output |
|
263 * parameters into a specific value. |
|
264 * |
|
265 * In test cases, context is used to verify that the output parameters match with the once |
|
266 * set in the stub. |
|
267 */ |
|
268 class WlanQtUtilsTestContext : public QObject |
|
269 { |
|
270 Q_OBJECT |
|
271 |
|
272 public: |
|
273 WlanQtUtilsTestContext(); |
|
274 ~WlanQtUtilsTestContext(); |
|
275 |
|
276 /** |
|
277 * Initializes context. |
|
278 */ |
|
279 void initialize(); |
|
280 |
|
281 /** Context for esock library. */ |
|
282 WlanQtUtilsCtxEsock esock_; |
|
283 /** Context for connmon library. */ |
|
284 WlanQtUtilsCtxConnMon connMon_; |
|
285 /** Context for ICTS library. */ |
|
286 WlanQtUtilsCtxIct ict_; |
|
287 /** Context for scan results. */ |
|
288 WlanQtUtilsWlanScan mScan; |
|
289 }; |
|
290 |
|
291 #endif // WLANQTUTILSTESTCONTEXT_H |