1 /* |
|
2 * Copyright (c) 2002 - 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: UI_NewFileServiceTest test class for STIF Test Framework TestScripter. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // [INCLUDE FILES] - do not remove |
|
24 #include <e32svr.h> |
|
25 #include <StifParser.h> |
|
26 #include <Stiftestinterface.h> |
|
27 #include "UI_NewFileServiceTest.h" |
|
28 |
|
29 #include <coeaui.h> |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CUI_NewFileServiceTest::Delete |
|
35 // Delete here all resources allocated and opened from test methods. |
|
36 // Called from destructor. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 void CUI_NewFileServiceTest::Delete() |
|
40 { |
|
41 |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CUI_NewFileServiceTest::RunMethodL |
|
46 // Run specified method. Contains also table of test mothods and their names. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 TInt CUI_NewFileServiceTest::RunMethodL( |
|
50 CStifItemParser& aItem ) |
|
51 { |
|
52 |
|
53 static TStifFunctionInfo const KFunctions[] = |
|
54 { |
|
55 // Copy this line for every implemented function. |
|
56 // First string is the function name used in TestScripter script file. |
|
57 // Second is the actual implementation member function. |
|
58 |
|
59 // test cases for the header "NewFileServiceClient.h" |
|
60 ENTRY( "CNewFileServiceClientCreate", CUI_NewFileServiceTest::CNewFileServiceClientCreate ), |
|
61 ENTRY( "NewFileL", CUI_NewFileServiceTest::NewFileL ), |
|
62 ENTRY( "NewFileByUid", CUI_NewFileServiceTest::NewFileByUid ), |
|
63 ENTRY( "NewFileByRFile", CUI_NewFileServiceTest::NewFileByRFile ), |
|
64 ENTRY( "NewFileByRFileAndUid", CUI_NewFileServiceTest::NewFileByRFileAndUid ), |
|
65 // test cases for the header "CNewFileServiceBase.h" |
|
66 |
|
67 ENTRY( "CreateCDummyNewFileServiceBase", CUI_NewFileServiceTest::CreateCDummyNewFileServiceBase ), |
|
68 ENTRY( "DestroyCDummyNewFileServiceBase", CUI_NewFileServiceTest::DestroyCDummyNewFileServiceBase ), |
|
69 ENTRY( "CDummyNewFileServiceBaseGetErrorCode", CUI_NewFileServiceTest::CDummyNewFileServiceBaseGetErrorCode ), |
|
70 ENTRY( "CDummyNewFileServiceBaseSetErrorCode", CUI_NewFileServiceTest::CDummyNewFileServiceBaseSetErrorCode ), |
|
71 ENTRY( "CDummyNewFileServiceBaseServiceL", CUI_NewFileServiceTest::CDummyNewFileServiceBaseServiceL ), |
|
72 ENTRY( "CDummyNewFileServiceBaseHandleCompletedNewServiceL", CUI_NewFileServiceTest::CDummyNewFileServiceBaseHandleCompletedNewServiceL ), |
|
73 ENTRY( "CDummyNewFileServiceBaseGenericParams", CUI_NewFileServiceTest::CDummyNewFileServiceBaseGenericParams ) |
|
74 |
|
75 //ADD NEW ENTRY HERE |
|
76 // [test cases entries] - Do not remove |
|
77 }; |
|
78 |
|
79 const TInt count = sizeof( KFunctions ) / |
|
80 sizeof( TStifFunctionInfo ); |
|
81 |
|
82 return RunInternalL( KFunctions, count, aItem ); |
|
83 |
|
84 } |
|
85 |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CUI_NewFileServiceTest::CNewFileServiceClientCreate |
|
89 // NewClientL |
|
90 // (other items were commented in a header). |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 TInt CUI_NewFileServiceTest::CNewFileServiceClientCreate( CStifItemParser& /*aItem*/ ) |
|
94 { |
|
95 TInt err = KErrNone; |
|
96 iLog->Log(_L("CUI_NewFileServiceTest::CNewFileServiceClientCreate begin:")); |
|
97 |
|
98 TRAP(err,iNewFileServiceClient=NewFileServiceFactory::NewClientL()); |
|
99 |
|
100 iLog->Log(_L("CUI_NewFileServiceTest::CNewFileServiceClientCreate returned: %d"), err); |
|
101 return err; |
|
102 |
|
103 } |
|
104 |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CUI_NewFileServiceTest::NewFileL |
|
108 // ?implementation_description |
|
109 // (other items were commented in a header). |
|
110 // ----------------------------------------------------------------------------- |
|
111 |
|
112 TInt CUI_NewFileServiceTest::NewFileL( CStifItemParser& aItem ) |
|
113 { |
|
114 TInt err = KErrNone; |
|
115 TPtrC string; |
|
116 iLog->Log(_L("CUI_NewFileServiceTest::NewFileL begin:")); |
|
117 |
|
118 CDesCArray* files = new (ELeave)CDesCArrayFlat(1); |
|
119 |
|
120 CleanupStack::PushL(files); |
|
121 CAiwGenericParamList* iCAiwGenericParamList=CAiwGenericParamList::NewL(); |
|
122 |
|
123 |
|
124 while ( aItem.GetNextString( string ) == KErrNone ) |
|
125 { |
|
126 TBuf<120> KFrom; |
|
127 KFrom.Append(KNewFileServiceTestDataPath); |
|
128 KFrom.Append(string); |
|
129 files->AppendL(KFrom); |
|
130 iNewFileServiceClient=NewFileServiceFactory::NewClientL(); |
|
131 |
|
132 TRAP(err,iNewFileServiceClient->NewFileL(*files,iCAiwGenericParamList,ENewFileServiceAudio,ETrue)); |
|
133 |
|
134 |
|
135 } |
|
136 CleanupStack::PopAndDestroy(files); |
|
137 |
|
138 iLog->Log(_L("CUI_NewFileServiceTest::NewFileL returned: %d"), err); |
|
139 return err; |
|
140 |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CUI_NewFileServiceTest::NewFileByUid |
|
145 // ?implementation_description |
|
146 // (other items were commented in a header). |
|
147 // ----------------------------------------------------------------------------- |
|
148 |
|
149 TInt CUI_NewFileServiceTest::NewFileByUid( CStifItemParser& aItem ) |
|
150 { |
|
151 TInt err = KErrNone; |
|
152 TPtrC string; |
|
153 iLog->Log(_L("CUI_NewFileServiceTest::NewFileByUid begin:")); |
|
154 TUid uid = TUid::Uid(0x100058CA);//0x101F87A3 0x101F87A4 0x100058CA |
|
155 CDesCArray* files = new (ELeave)CDesCArrayFlat(1); |
|
156 CleanupStack::PushL(files); |
|
157 CAiwGenericParamList* iCAiwGenericParamList=CAiwGenericParamList::NewL(); |
|
158 |
|
159 |
|
160 while ( aItem.GetNextString( string ) == KErrNone ) |
|
161 { |
|
162 TBuf<120> KFrom; |
|
163 KFrom.Append(KNewFileServiceTestDataPath); |
|
164 KFrom.Append(string); |
|
165 files->AppendL(KFrom); |
|
166 iNewFileServiceClient=NewFileServiceFactory::NewClientL(); |
|
167 |
|
168 TRAP(err,iNewFileServiceClient->NewFileL(uid,*files,iCAiwGenericParamList,ENewFileServiceAudio,ETrue)); |
|
169 |
|
170 |
|
171 } |
|
172 CleanupStack::PopAndDestroy(files); |
|
173 |
|
174 iLog->Log(_L("CUI_NewFileServiceTest::NewFileByUid returned: %d"), err); |
|
175 return err; |
|
176 |
|
177 } |
|
178 |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CUI_NewFileServiceTest::NewFileByRFile |
|
182 // ?implementation_description |
|
183 // (other items were commented in a header). |
|
184 // ----------------------------------------------------------------------------- |
|
185 |
|
186 TInt CUI_NewFileServiceTest::NewFileByRFile( CStifItemParser& aItem ) |
|
187 { |
|
188 TInt err = KErrNone; |
|
189 TPtrC string; |
|
190 iLog->Log(_L("CUI_NewFileServiceTest::NewFileByRFile begin:")); |
|
191 |
|
192 CAiwGenericParamList* iCAiwGenericParamList=CAiwGenericParamList::NewL(); |
|
193 |
|
194 while ( aItem.GetNextString( string ) == KErrNone ) |
|
195 { |
|
196 TBuf<120> KFrom; |
|
197 KFrom.Append(KNewFileServiceTestDataPath); |
|
198 KFrom.Append(string); |
|
199 |
|
200 RFile file; |
|
201 RFs fs; |
|
202 fs.Connect(); |
|
203 file.Open(fs,KFrom,EFileShareAny|EFileWrite); |
|
204 iNewFileServiceClient=NewFileServiceFactory::NewClientL(); |
|
205 |
|
206 TRAP(err,iNewFileServiceClient->NewFileL(file,iCAiwGenericParamList,ENewFileServiceAudio)); |
|
207 file.Close(); |
|
208 fs.Close(); |
|
209 |
|
210 } |
|
211 |
|
212 iLog->Log(_L("CUI_NewFileServiceTest::NewFileByRFile returned: %d"), err); |
|
213 return err; |
|
214 |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CUI_NewFileServiceTest::NewFileByRFileAndUid |
|
219 // ?implementation_description |
|
220 // (other items were commented in a header). |
|
221 // ----------------------------------------------------------------------------- |
|
222 |
|
223 TInt CUI_NewFileServiceTest::NewFileByRFileAndUid( CStifItemParser& aItem ) |
|
224 { |
|
225 TInt err = KErrNone; |
|
226 TPtrC string; |
|
227 iLog->Log(_L("CUI_NewFileServiceTest::NewFileByRFileAndUid begin:")); |
|
228 TUid uid = TUid::Uid(0x100058CA); |
|
229 |
|
230 CAiwGenericParamList* iCAiwGenericParamList=CAiwGenericParamList::NewL(); |
|
231 |
|
232 |
|
233 while ( aItem.GetNextString( string ) == KErrNone ) |
|
234 { |
|
235 TBuf<120> KFrom; |
|
236 KFrom.Append(KNewFileServiceTestDataPath); |
|
237 KFrom.Append(string); |
|
238 |
|
239 RFile file; |
|
240 RFs fs; |
|
241 fs.Connect(); |
|
242 file.Open(fs,KFrom,EFileShareAny|EFileWrite); |
|
243 iNewFileServiceClient=NewFileServiceFactory::NewClientL(); |
|
244 |
|
245 TRAP(err,iNewFileServiceClient->NewFileL(uid,file,iCAiwGenericParamList,ENewFileServiceAudio)); |
|
246 file.Close(); |
|
247 fs.Close(); |
|
248 |
|
249 } |
|
250 |
|
251 |
|
252 iLog->Log(_L("CUI_NewFileServiceTest::NewFileByRFileAndUid returned: %d"), err); |
|
253 return err; |
|
254 |
|
255 } |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CUI_NewFileServiceTest::CreateCDummyNewFileServiceBase |
|
258 // Create CDummyNewFileServiceBase |
|
259 // (other items were commented in a header). |
|
260 // ----------------------------------------------------------------------------- |
|
261 |
|
262 TInt CUI_NewFileServiceTest::CreateCDummyNewFileServiceBase( CStifItemParser& /*aItem*/ ) |
|
263 { |
|
264 TInt err = KErrNone; |
|
265 iLog->Log(_L("CUI_NewFileServiceTest::CreateCDummyNewFileServiceBase begin:")); |
|
266 |
|
267 iDummyNewFileServiceBase = new (ELeave)CDummyNewFileServiceBase(); |
|
268 |
|
269 if ( iDummyNewFileServiceBase == NULL ) |
|
270 |
|
271 { |
|
272 err = KErrNotFound; |
|
273 iLog->Log(_L("CUI_NewFileServiceTest::CreateCDummyNewFileServiceBase returned: %d"), err); |
|
274 } |
|
275 |
|
276 return err; |
|
277 |
|
278 } |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CUI_NewFileServiceTest::DestroyCDummyNewFileServiceBase |
|
281 // Destroy CDummyNewFileServiceBase |
|
282 // (other items were commented in a header). |
|
283 // ----------------------------------------------------------------------------- |
|
284 |
|
285 TInt CUI_NewFileServiceTest::DestroyCDummyNewFileServiceBase( CStifItemParser& /*aItem*/ ) |
|
286 { |
|
287 TInt err = KErrNone; |
|
288 iLog->Log(_L("CUI_NewFileServiceTest::DestroyCDummyNewFileServiceBase begin:")); |
|
289 if ( iDummyNewFileServiceBase != NULL ) |
|
290 { |
|
291 delete iDummyNewFileServiceBase; |
|
292 iDummyNewFileServiceBase = NULL; |
|
293 } |
|
294 iLog->Log(_L("CUI_NewFileServiceTest::DestroyCDummyNewFileServiceBase returned: %d"), err); |
|
295 return err; |
|
296 } |
|
297 // ----------------------------------------------------------------------------- |
|
298 // CUI_NewFileServiceTest::CDummyNewFileServiceBaseGetErrorCode |
|
299 // CDummyNewFileServiceBase GetErrorCode |
|
300 // (other items were commented in a header). |
|
301 // ----------------------------------------------------------------------------- |
|
302 |
|
303 TInt CUI_NewFileServiceTest::CDummyNewFileServiceBaseGetErrorCode( CStifItemParser& /*aItem*/ ) |
|
304 { |
|
305 TInt err = KErrNone; |
|
306 TInt errcode = 0; |
|
307 iLog->Log(_L("CUI_NewFileServiceTest::CDummyNewFileServiceBaseGetErrorCode begin:")); |
|
308 |
|
309 errcode = iDummyNewFileServiceBase->GetErrorCode(); |
|
310 if ( errcode > 0 ) |
|
311 { |
|
312 err = KErrNotFound; |
|
313 iLog->Log(_L("CUI_NewFileServiceTest::CDummyNewFileServiceBaseGetErrorCode returned: %d"), err); |
|
314 } |
|
315 |
|
316 return err; |
|
317 } |
|
318 // ----------------------------------------------------------------------------- |
|
319 // CUI_NewFileServiceTest::CDummyNewFileServiceBaseSetErrorCode |
|
320 // CDummyNewFileServiceBase SetErrorCode |
|
321 // (other items were commented in a header). |
|
322 // ----------------------------------------------------------------------------- |
|
323 TInt CUI_NewFileServiceTest::CDummyNewFileServiceBaseSetErrorCode( CStifItemParser& aItem ) |
|
324 { |
|
325 TInt err = KErrNone; |
|
326 TInt errcode; |
|
327 TInt compare; |
|
328 iLog->Log(_L("CUI_NewFileServiceTest::CDummyNewFileServiceBaseSetErrorCode begin:")); |
|
329 while ( aItem.GetNextInt(errcode) == KErrNone ) |
|
330 { |
|
331 iDummyNewFileServiceBase->SetErrorCode(errcode); |
|
332 } |
|
333 |
|
334 compare = iDummyNewFileServiceBase->GetErrorCode(); |
|
335 |
|
336 if ( compare != errcode ) |
|
337 { |
|
338 err = KErrNotFound; |
|
339 iLog->Log(_L("CUI_NewFileServiceTest::CDummyNewFileServiceBaseSetErrorCode returned: %d"), err); |
|
340 } |
|
341 |
|
342 return err; |
|
343 } |
|
344 |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // CUI_NewFileServiceTest::CDummyNewFileServiceBaseServiceL |
|
348 // CDummyNewFileServiceBase ServiceL |
|
349 // (other items were commented in a header). |
|
350 // ----------------------------------------------------------------------------- |
|
351 |
|
352 TInt CUI_NewFileServiceTest::CDummyNewFileServiceBaseServiceL( CStifItemParser& /*aItem*/ ) |
|
353 { |
|
354 TInt err = KErrNone; |
|
355 iLog->Log(_L("CUI_NewFileServiceTest::CDummyNewFileServiceBaseServiceL begin:")); |
|
356 // RMessage2* msg = new(ELeave)RMessage2(); |
|
357 // HBufC* buf = HBufC::NewLC(100); |
|
358 // buf->Des().Append(_L("aa")); |
|
359 // TPtr ptr = buf->Des(); |
|
360 // ptr.Copy(_L("aa")); |
|
361 // message->ReadL(0,ptr); |
|
362 RMessage2* msg = new(ELeave)RMessage2(); |
|
363 HBufC* msg1 = HBufC::New( 20 ); |
|
364 TUint16 msgContent = ENewServiceIndexFileName; //(TUint8)3; |
|
365 msg1->Des().Copy( &msgContent ); |
|
366 TPtr msgPtr1 = msg1->Des(); |
|
367 msg->ReadL( msgContent,msgPtr1 ); |
|
368 |
|
369 iDummyNewFileServiceBase->ServiceLtest(*msg); |
|
370 CleanupStack::PopAndDestroy(); // msg1 |
|
371 //delete message; |
|
372 //delete buf; |
|
373 iLog->Log(_L("CUI_NewFileServiceTest::CDummyNewFileServiceBaseServiceL returned: %d"), err); |
|
374 |
|
375 |
|
376 return err; |
|
377 } |
|
378 |
|
379 // ----------------------------------------------------------------------------- |
|
380 // CUI_NewFileServiceTest::CDummyNewFileServiceBaseHandleCompletedNewServiceL |
|
381 // CDummyNewFileServiceBase HandleCompletedNewServiceL |
|
382 // (other items were commented in a header). |
|
383 // ----------------------------------------------------------------------------- |
|
384 |
|
385 TInt CUI_NewFileServiceTest::CDummyNewFileServiceBaseHandleCompletedNewServiceL( CStifItemParser& /*aItem*/ ) |
|
386 { |
|
387 TInt err = KErrNone; |
|
388 TBool tbool = ETrue; |
|
389 iLog->Log(_L("CUI_NewFileServiceTest::CDummyNewFileServiceBaseHandleCompletedNewServiceL begin:")); |
|
390 |
|
391 iDummyNewFileServiceBase->HandleCompletedNewServiceLtest(tbool); |
|
392 |
|
393 iLog->Log(_L("CUI_NewFileServiceTest::CDummyNewFileServiceBaseHandleCompletedNewServiceL returned: %d"), err); |
|
394 |
|
395 return err; |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CUI_NewFileServiceTest::CDummyNewFileServiceBaseGenericParams |
|
400 // CDummyNewFileServiceBase GenericParams |
|
401 // (other items were commented in a header). |
|
402 // ----------------------------------------------------------------------------- |
|
403 |
|
404 TInt CUI_NewFileServiceTest::CDummyNewFileServiceBaseGenericParams( CStifItemParser& /*aItem*/ ) |
|
405 { |
|
406 TInt err = KErrNone; |
|
407 iLog->Log(_L("CUI_NewFileServiceTest::CDummyNewFileServiceBaseGenericParams begin:")); |
|
408 |
|
409 iDummyNewFileServiceBase->GenericParamstest(); |
|
410 |
|
411 iLog->Log(_L("CUI_NewFileServiceTest::CDummyNewFileServiceBaseGenericParams returned: %d"), err); |
|
412 |
|
413 return err; |
|
414 } |
|