|
1 /* |
|
2 * Copyright (c) 2009 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 |
|
23 #include "wlanqtutilsactiveconn.h" |
|
24 |
|
25 class WlanQtUtilsWlanAp; |
|
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 WlanQtUtilsActiveConn. |
|
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 WlanQtUtilsActiveConn. |
|
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 WlanQtUtilsActiveConn |
|
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<WlanQtUtilsActiveConn *> 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 APs that represent the results of WLAN scanning triggered by |
|
134 * RConnectionMonitor::GetPckgAttribute() |
|
135 */ |
|
136 class WlanQtUtilsWlanScanResult : public QObject |
|
137 { |
|
138 Q_OBJECT |
|
139 |
|
140 public: |
|
141 WlanQtUtilsWlanScanResult(); |
|
142 ~WlanQtUtilsWlanScanResult(); |
|
143 |
|
144 /** |
|
145 * Initializes context. |
|
146 */ |
|
147 void initialize(); |
|
148 |
|
149 /** |
|
150 * Creates a list of WLAN APs for scan results. |
|
151 * |
|
152 * @param[in] numberOfWlanAps Number of WLAN APs that are created. |
|
153 */ |
|
154 void createDefaultWlanScanResultList(int numberOfWlanAps); |
|
155 |
|
156 /** |
|
157 * Verifies that the given WLAN AP list returned by the real application matches |
|
158 * with the one in the context. |
|
159 * |
|
160 * @param[in] wlanApList WLAN APs that are verified against the context. |
|
161 */ |
|
162 void verifyWlanScanResultList(QList<WlanQtUtilsWlanAp *> wlanApList); // TODO: Maybe boolean return value |
|
163 |
|
164 /** |
|
165 * List of WLAN access points that RConnectionMonitor stub will return in response to |
|
166 * RConnectionMonitor::GetPckgAttribute(). |
|
167 */ |
|
168 QList<WlanQtUtilsWlanAp *> wlanScanResultList_; |
|
169 |
|
170 private: |
|
171 |
|
172 /** |
|
173 * Destroys and clears the list of WLAN APs. |
|
174 */ |
|
175 void clearWlanScanResultList(); |
|
176 }; |
|
177 |
|
178 /** |
|
179 * Test context for RConnectionMonitor. |
|
180 */ |
|
181 class WlanQtUtilsCtxConnMon : public QObject |
|
182 { |
|
183 Q_OBJECT |
|
184 |
|
185 public: |
|
186 WlanQtUtilsCtxConnMon(); |
|
187 ~WlanQtUtilsCtxConnMon(); |
|
188 |
|
189 /** |
|
190 * Initializes context. |
|
191 */ |
|
192 void initialize(); |
|
193 |
|
194 /** Results of WLAN scanning. */ |
|
195 WlanQtUtilsWlanScanResult wlanScanResult_; |
|
196 |
|
197 /** List of active connections. */ |
|
198 WlanQtUtilsCtxActiveConnections activeConnections_; |
|
199 }; |
|
200 |
|
201 /** |
|
202 * Test context for Internet connectivity test library. |
|
203 */ |
|
204 class WlanQtUtilsCtxIct : public QObject |
|
205 { |
|
206 Q_OBJECT |
|
207 |
|
208 public: |
|
209 WlanQtUtilsCtxIct(); |
|
210 ~WlanQtUtilsCtxIct(); |
|
211 |
|
212 /** |
|
213 * Initializes context. |
|
214 */ |
|
215 void initialize(); |
|
216 }; |
|
217 |
|
218 /** |
|
219 * Test context. The purpose of this context is to provide values that are used in stubs |
|
220 * and in verification of outputs in test cases. |
|
221 * |
|
222 * In stubs, context is used to verify the inputs of parameters and to set output |
|
223 * parameters into a specific value. |
|
224 * |
|
225 * In test cases, context is used to verify that the output parameters match with the once |
|
226 * set in the stub. |
|
227 */ |
|
228 class WlanQtUtilsTestContext : public QObject |
|
229 { |
|
230 Q_OBJECT |
|
231 |
|
232 public: |
|
233 WlanQtUtilsTestContext(); |
|
234 ~WlanQtUtilsTestContext(); |
|
235 |
|
236 /** |
|
237 * Initializes context. |
|
238 */ |
|
239 void initialize(); |
|
240 |
|
241 /** Context for esock library. */ |
|
242 WlanQtUtilsCtxEsock esock_; |
|
243 /** Context for connmon library. */ |
|
244 WlanQtUtilsCtxConnMon connMon_; |
|
245 /** Context for ICTS library. */ |
|
246 WlanQtUtilsCtxIct ict_; |
|
247 }; |
|
248 |
|
249 #endif /* WLANQTUTILSTESTCONTEXT_H */ |
|
250 |