|
1 /* |
|
2 * Copyright (c) 2007 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: Implementation of the MT_MProEngProfileName test class. |
|
15 * |
|
16 */ |
|
17 |
|
18 //////////////////////////////////////////////////////////////////////// |
|
19 // MT_MProEngProfileName.cpp |
|
20 // |
|
21 |
|
22 // CLASS HEADER |
|
23 #include "MT_MProEngProfileName.h" |
|
24 |
|
25 // EXTERNAL INCLUDES |
|
26 #include <EUnitMacros.h> |
|
27 #include <MProEngProfileName.h> |
|
28 #include <MProEngProfile.h> |
|
29 #include <MProEngEngine.h> |
|
30 #include "MProfileEngineExtended.h" |
|
31 #include "MProfile.h" |
|
32 #include "MProfileName.h" |
|
33 #include "MProfileExtended.h" |
|
34 #include <ProEngFactory.h> |
|
35 #include <Profile.hrh> |
|
36 |
|
37 // INTERNAL INCLUDES |
|
38 #include "T_ProfileTestTools.h" |
|
39 |
|
40 MT_MProEngProfileName* MT_MProEngProfileName::NewL() |
|
41 { |
|
42 MT_MProEngProfileName* self = MT_MProEngProfileName::NewLC(); |
|
43 CleanupStack::Pop(); |
|
44 |
|
45 return self; |
|
46 } |
|
47 |
|
48 MT_MProEngProfileName* MT_MProEngProfileName::NewLC() |
|
49 { |
|
50 MT_MProEngProfileName* self = new( ELeave ) MT_MProEngProfileName(); |
|
51 CleanupStack::PushL( self ); |
|
52 |
|
53 self->ConstructL(); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 MT_MProEngProfileName::~MT_MProEngProfileName() |
|
60 { |
|
61 if( iInternalEngine ) |
|
62 { |
|
63 iInternalEngine->Release(); |
|
64 iInternalEngine = NULL; |
|
65 } |
|
66 if( iEngine ) |
|
67 { |
|
68 iEngine->Release(); |
|
69 iEngine = NULL; |
|
70 } |
|
71 } |
|
72 |
|
73 |
|
74 MT_MProEngProfileName::MT_MProEngProfileName() |
|
75 { |
|
76 } |
|
77 |
|
78 void MT_MProEngProfileName::ConstructL() |
|
79 { |
|
80 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
81 // It generates the test case table. |
|
82 CEUnitTestSuiteClass::ConstructL(); |
|
83 iInternalEngine = CreateProfileEngineExtendedL(); |
|
84 iEngine = ProEngFactory::NewEngineL(); |
|
85 } |
|
86 |
|
87 |
|
88 void MT_MProEngProfileName::SetupL() |
|
89 { |
|
90 iInternalProfile = iInternalEngine->ProfileL( iProfileId ); |
|
91 iProfile = iEngine->ProfileL( iProfileId ); |
|
92 } |
|
93 |
|
94 void MT_MProEngProfileName::Setup0L() |
|
95 { |
|
96 iProfileId = 0; |
|
97 SetupL(); |
|
98 } |
|
99 |
|
100 void MT_MProEngProfileName::Setup1L() |
|
101 { |
|
102 iProfileId = 1; |
|
103 SetupL(); |
|
104 } |
|
105 |
|
106 void MT_MProEngProfileName::Setup2L() |
|
107 { |
|
108 iProfileId = 2; |
|
109 SetupL(); |
|
110 } |
|
111 |
|
112 void MT_MProEngProfileName::Setup3L() |
|
113 { |
|
114 iProfileId = 3; |
|
115 SetupL(); |
|
116 } |
|
117 |
|
118 void MT_MProEngProfileName::Setup4L() |
|
119 { |
|
120 iProfileId = 4; |
|
121 SetupL(); |
|
122 } |
|
123 |
|
124 #ifdef __OFFLINE_MODE |
|
125 void MT_MProEngProfileName::Setup5L() |
|
126 { |
|
127 iProfileId = 5; |
|
128 SetupL(); |
|
129 } |
|
130 |
|
131 #endif // __OFFLINE_MODE |
|
132 #ifdef __DRIVE_MODE |
|
133 void MT_MProEngProfileName::Setup6L() |
|
134 { |
|
135 iProfileId = 6; |
|
136 SetupL(); |
|
137 } |
|
138 |
|
139 #endif // __DRIVE_MODE |
|
140 |
|
141 |
|
142 void MT_MProEngProfileName::Teardown() |
|
143 { |
|
144 if( iInternalProfile ) |
|
145 { |
|
146 iInternalProfile->Release(); |
|
147 iInternalProfile = NULL; |
|
148 } |
|
149 if( iProfile ) |
|
150 { |
|
151 iProfile->Release(); |
|
152 iProfile = NULL; |
|
153 } |
|
154 } |
|
155 |
|
156 |
|
157 void MT_MProEngProfileName::GetIdTestL() |
|
158 { |
|
159 MProEngProfileName& profileName( iProfile->ProfileName() ); |
|
160 const MProfileName& name( iInternalProfile->ProfileName() ); |
|
161 EUNIT_ASSERT( profileName.Id() == name.Id() ); |
|
162 } |
|
163 |
|
164 |
|
165 void MT_MProEngProfileName::GetNameTestL() |
|
166 { |
|
167 MProEngProfileName& profileName( iProfile->ProfileName() ); |
|
168 const MProfileName& name( iInternalProfile->ProfileName() ); |
|
169 EUNIT_ASSERT( profileName.Name().Compare( name.Name() ) == 0 ); |
|
170 } |
|
171 |
|
172 |
|
173 void MT_MProEngProfileName::SetNameTestL() |
|
174 { |
|
175 MProEngProfileName& profileName( iProfile->ProfileName() ); |
|
176 const TDesC& origName( profileName.Name() ); |
|
177 TInt err( profileName.SetNameL( KProEngMTTestName ) ); |
|
178 if( ( iProfileId != EProfileOffLineId ) && |
|
179 ( iProfileId != EProfileDriveId ) && |
|
180 ( iProfileId != EProfileGeneralId ) ) |
|
181 { |
|
182 EUNIT_ASSERT( err == KErrNone ); |
|
183 EUNIT_ASSERT( profileName.Name().Compare( KProEngMTTestName ) == 0 ); |
|
184 } |
|
185 else |
|
186 { |
|
187 EUNIT_ASSERT( err == KErrAccessDenied ); |
|
188 EUNIT_ASSERT( profileName.Name().Compare( origName ) == 0 ); |
|
189 } |
|
190 } |
|
191 |
|
192 EUNIT_BEGIN_TEST_TABLE( |
|
193 MT_MProEngProfileName, |
|
194 "Profile Name Wrapper Test cases.", |
|
195 "MODULE" ) |
|
196 |
|
197 EUNIT_TEST( |
|
198 "Get Profile ID 0 - test", |
|
199 "MProEngProfileName", |
|
200 "Id", |
|
201 "FUNCTIONALITY", |
|
202 Setup0L, |
|
203 GetIdTestL, |
|
204 Teardown) |
|
205 |
|
206 EUNIT_TEST( |
|
207 "Get Profile Name 0 - test", |
|
208 "MProEngProfileName", |
|
209 "Name", |
|
210 "FUNCTIONALITY", |
|
211 Setup0L, |
|
212 GetNameTestL, |
|
213 Teardown) |
|
214 |
|
215 EUNIT_TEST( |
|
216 "Set Profile Name 0 - test", |
|
217 "MProEngProfileName", |
|
218 "SetNameL", |
|
219 "FUNCTIONALITY", |
|
220 Setup0L, |
|
221 SetNameTestL, |
|
222 Teardown) |
|
223 |
|
224 EUNIT_TEST( |
|
225 "Get Profile ID 1 - test", |
|
226 "MProEngProfileName", |
|
227 "Id", |
|
228 "FUNCTIONALITY", |
|
229 Setup1L, |
|
230 GetIdTestL, |
|
231 Teardown) |
|
232 |
|
233 EUNIT_TEST( |
|
234 "Get Profile Name 1 - test", |
|
235 "MProEngProfileName", |
|
236 "Name", |
|
237 "FUNCTIONALITY", |
|
238 Setup1L, |
|
239 GetNameTestL, |
|
240 Teardown) |
|
241 |
|
242 EUNIT_TEST( |
|
243 "Set Profile Name 1 - test", |
|
244 "MProEngProfileName", |
|
245 "SetNameL", |
|
246 "FUNCTIONALITY", |
|
247 Setup1L, |
|
248 SetNameTestL, |
|
249 Teardown) |
|
250 |
|
251 EUNIT_TEST( |
|
252 "Get Profile ID 2 - test", |
|
253 "MProEngProfileName", |
|
254 "Id", |
|
255 "FUNCTIONALITY", |
|
256 Setup2L, |
|
257 GetIdTestL, |
|
258 Teardown) |
|
259 |
|
260 EUNIT_TEST( |
|
261 "Get Profile Name 2 - test", |
|
262 "MProEngProfileName", |
|
263 "Name", |
|
264 "FUNCTIONALITY", |
|
265 Setup2L, |
|
266 GetNameTestL, |
|
267 Teardown) |
|
268 |
|
269 EUNIT_TEST( |
|
270 "Set Profile Name 2 - test", |
|
271 "MProEngProfileName", |
|
272 "SetNameL", |
|
273 "FUNCTIONALITY", |
|
274 Setup2L, |
|
275 SetNameTestL, |
|
276 Teardown) |
|
277 |
|
278 EUNIT_TEST( |
|
279 "Get Profile ID 3 - test", |
|
280 "MProEngProfileName", |
|
281 "Id", |
|
282 "FUNCTIONALITY", |
|
283 Setup3L, |
|
284 GetIdTestL, |
|
285 Teardown) |
|
286 |
|
287 EUNIT_TEST( |
|
288 "Get Profile Name 3 - test", |
|
289 "MProEngProfileName", |
|
290 "Name", |
|
291 "FUNCTIONALITY", |
|
292 Setup3L, |
|
293 GetNameTestL, |
|
294 Teardown) |
|
295 |
|
296 EUNIT_TEST( |
|
297 "Set Profile Name 3 - test", |
|
298 "MProEngProfileName", |
|
299 "SetNameL", |
|
300 "FUNCTIONALITY", |
|
301 Setup3L, |
|
302 SetNameTestL, |
|
303 Teardown) |
|
304 |
|
305 EUNIT_TEST( |
|
306 "Get Profile ID 4 - test", |
|
307 "MProEngProfileName", |
|
308 "Id", |
|
309 "FUNCTIONALITY", |
|
310 Setup4L, |
|
311 GetIdTestL, |
|
312 Teardown) |
|
313 |
|
314 EUNIT_TEST( |
|
315 "Get Profile Name 4 - test", |
|
316 "MProEngProfileName", |
|
317 "Name", |
|
318 "FUNCTIONALITY", |
|
319 Setup4L, |
|
320 GetNameTestL, |
|
321 Teardown) |
|
322 |
|
323 EUNIT_TEST( |
|
324 "Set Profile Name 4 - test", |
|
325 "MProEngProfileName", |
|
326 "SetNameL", |
|
327 "FUNCTIONALITY", |
|
328 Setup4L, |
|
329 SetNameTestL, |
|
330 Teardown) |
|
331 |
|
332 #ifdef __OFFLINE_MODE |
|
333 EUNIT_TEST( |
|
334 "Get Profile ID 5 - test", |
|
335 "MProEngProfileName", |
|
336 "Id", |
|
337 "FUNCTIONALITY", |
|
338 Setup5L, |
|
339 GetIdTestL, |
|
340 Teardown) |
|
341 |
|
342 EUNIT_TEST( |
|
343 "Get Profile Name 5 - test", |
|
344 "MProEngProfileName", |
|
345 "Name", |
|
346 "FUNCTIONALITY", |
|
347 Setup5L, |
|
348 GetNameTestL, |
|
349 Teardown) |
|
350 |
|
351 EUNIT_TEST( |
|
352 "Set Profile Name 5 - test", |
|
353 "MProEngProfileName", |
|
354 "SetNameL", |
|
355 "FUNCTIONALITY", |
|
356 Setup5L, |
|
357 SetNameTestL, |
|
358 Teardown) |
|
359 #endif // __OFFLINE_MODE |
|
360 |
|
361 #ifdef __DRIVE_MODE |
|
362 EUNIT_TEST( |
|
363 "Get Profile ID 6 - test", |
|
364 "MProEngProfileName", |
|
365 "Id", |
|
366 "FUNCTIONALITY", |
|
367 Setup6L, |
|
368 GetIdTestL, |
|
369 Teardown) |
|
370 |
|
371 EUNIT_TEST( |
|
372 "Get Profile Name 6 - test", |
|
373 "MProEngProfileName", |
|
374 "Name", |
|
375 "FUNCTIONALITY", |
|
376 Setup6L, |
|
377 GetNameTestL, |
|
378 Teardown) |
|
379 |
|
380 EUNIT_TEST( |
|
381 "Set Profile Name 6 - test", |
|
382 "MProEngProfileName", |
|
383 "SetNameL", |
|
384 "FUNCTIONALITY", |
|
385 Setup6L, |
|
386 SetNameTestL, |
|
387 Teardown) |
|
388 #endif // __DRIVE_MODE |
|
389 |
|
390 EUNIT_END_TEST_TABLE |
|
391 |
|
392 |