|
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: This file contains testclass implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <StifTestInterface.h> |
|
20 #include "FormatterRFSPluginTestModule.h" |
|
21 #include <SettingServerClient.h> |
|
22 |
|
23 #include <f32file.h> |
|
24 #include <rfsplugin.h> |
|
25 |
|
26 #include "formatterrfsplugincommon.h" |
|
27 _LIT( KExcludeListPath,"c:\\private\\100059C9\\" ); |
|
28 _LIT( KExcludeListName, "c:\\private\\100059C9\\excludelist.txt" ); |
|
29 _LIT( KExcludeListAppSpecFolder, "c:\\private\\102073ea\\excludes\\" ); |
|
30 _LIT( KExcludeListAppSpecName, "c:\\private\\102073ea\\excludes\\12345678.exc" ); |
|
31 _LIT8( KDefaultExcludeList, "c:\\*.*\n" ); |
|
32 _LIT( KExpectedScript, "2000F8F4:00000001;" ); |
|
33 |
|
34 // EXTERNAL DATA STRUCTURES |
|
35 //extern ?external_data; |
|
36 |
|
37 // EXTERNAL FUNCTION PROTOTYPES |
|
38 //extern ?external_function( ?arg_type,?arg_type ); |
|
39 |
|
40 // CONSTANTS |
|
41 //const ?type ?constant_var = ?constant; |
|
42 |
|
43 // MACROS |
|
44 //#define ?macro ?macro_def |
|
45 |
|
46 // LOCAL CONSTANTS AND MACROS |
|
47 //const ?type ?constant_var = ?constant; |
|
48 //#define ?macro_name ?macro_def |
|
49 |
|
50 // MODULE DATA STRUCTURES |
|
51 //enum ?declaration |
|
52 //typedef ?declaration |
|
53 |
|
54 // LOCAL FUNCTION PROTOTYPES |
|
55 //?type ?function_name( ?arg_type, ?arg_type ); |
|
56 |
|
57 // FORWARD DECLARATIONS |
|
58 //class ?FORWARD_CLASSNAME; |
|
59 |
|
60 // ============================= LOCAL FUNCTIONS =============================== |
|
61 // --------------------------------------------------------------------------- |
|
62 // CreateExcludeListFileL |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 static void CreateExcludeListFileL( const TDesC& aFile ) |
|
66 { |
|
67 RFs fs; |
|
68 TInt err = fs.Connect(); |
|
69 RDebug::Print(_L("Failed to connect to file server = %d"),err); |
|
70 User::LeaveIfError( err ); |
|
71 CleanupClosePushL( fs ); |
|
72 |
|
73 err = fs.MkDirAll(KExcludeListPath); |
|
74 if( err != KErrNone && err != KErrAlreadyExists ) |
|
75 { |
|
76 User::Leave( err ); |
|
77 } |
|
78 |
|
79 err = fs.MkDirAll( KExcludeListAppSpecFolder ); |
|
80 if( err != KErrNone && err != KErrAlreadyExists ) |
|
81 { |
|
82 User::Leave( err ); |
|
83 } |
|
84 RFile file; |
|
85 err = file.Replace( fs, aFile, EFileWrite ); |
|
86 RDebug::Print(_L("Failed to create file = %d"),err); |
|
87 User::LeaveIfError( err ); |
|
88 err = file.Write( KDefaultExcludeList ); |
|
89 RDebug::Print(_L("Failed to write exclude list = %d"),err); |
|
90 User::LeaveIfError( err ); |
|
91 |
|
92 file.Close(); |
|
93 |
|
94 CleanupStack::PopAndDestroy( &fs ); |
|
95 } |
|
96 |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // DeleteExcludeListFileL |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 static void DeleteExcludeListFileL( const TDesC& aFile ) |
|
103 { |
|
104 RFs fs; |
|
105 TInt err = fs.Connect(); |
|
106 RDebug::Print(_L("Failed to connect to file server = %d"),err); |
|
107 User::LeaveIfError( err ); |
|
108 CleanupClosePushL( fs ); |
|
109 |
|
110 err = fs.Delete( aFile ); |
|
111 |
|
112 CleanupStack::PopAndDestroy( &fs ); |
|
113 } |
|
114 |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // RunSecureFormatterL |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 static void RunSecureFormatterL() |
|
121 { |
|
122 RProcess process; |
|
123 CleanupClosePushL( process ); |
|
124 TInt err = process.Create( KSecureFormatter, KNullDesC ); |
|
125 RDebug::Print(_L("Failed to create process = %d"),err); |
|
126 User::LeaveIfError( err ); |
|
127 |
|
128 TRequestStatus status; |
|
129 process.Logon( status ); |
|
130 process.Resume(); |
|
131 User::WaitForRequest( status ); |
|
132 RDebug::Print(_L("secure formatter failed = %d"),err); |
|
133 |
|
134 CleanupStack::PopAndDestroy( &process ); |
|
135 } |
|
136 |
|
137 |
|
138 |
|
139 // ============================ MEMBER FUNCTIONS =============================== |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CFormatterRFSPluginTestModule::CFormatterRFSPluginTestModule |
|
143 // C++ default constructor can NOT contain any code, that |
|
144 // might leave. |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 CFormatterRFSPluginTestModule::CFormatterRFSPluginTestModule( |
|
148 CTestModuleIf& aTestModuleIf ): |
|
149 CScriptBase( aTestModuleIf ) |
|
150 { |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CFormatterRFSPluginTestModule::ConstructL |
|
155 // Symbian 2nd phase constructor can leave. |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CFormatterRFSPluginTestModule::ConstructL() |
|
159 { |
|
160 //Read logger settings to check whether test case name is to be |
|
161 //appended to log file name. |
|
162 RSettingServer settingServer; |
|
163 TInt ret = settingServer.Connect(); |
|
164 if(ret != KErrNone) |
|
165 { |
|
166 User::Leave(ret); |
|
167 } |
|
168 // Struct to StifLogger settigs. |
|
169 TLoggerSettings loggerSettings; |
|
170 // Parse StifLogger defaults from STIF initialization file. |
|
171 ret = settingServer.GetLoggerSettings(loggerSettings); |
|
172 if(ret != KErrNone) |
|
173 { |
|
174 User::Leave(ret); |
|
175 } |
|
176 // Close Setting server session |
|
177 settingServer.Close(); |
|
178 |
|
179 TFileName logFileName; |
|
180 |
|
181 if(loggerSettings.iAddTestCaseTitle) |
|
182 { |
|
183 TName title; |
|
184 TestModuleIf().GetTestCaseTitleL(title); |
|
185 logFileName.Format(KFormatterRFSPluginTestModuleLogFileWithTitle, &title); |
|
186 } |
|
187 else |
|
188 { |
|
189 logFileName.Copy(KFormatterRFSPluginTestModuleLogFile); |
|
190 } |
|
191 |
|
192 iLog = CStifLogger::NewL( KFormatterRFSPluginTestModuleLogPath, |
|
193 logFileName, |
|
194 CStifLogger::ETxt, |
|
195 CStifLogger::EFile, |
|
196 EFalse ); |
|
197 |
|
198 SendTestClassVersion(); |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CFormatterRFSPluginTestModule::NewL |
|
203 // Two-phased constructor. |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 CFormatterRFSPluginTestModule* CFormatterRFSPluginTestModule::NewL( |
|
207 CTestModuleIf& aTestModuleIf ) |
|
208 { |
|
209 CFormatterRFSPluginTestModule* self = new (ELeave) CFormatterRFSPluginTestModule( aTestModuleIf ); |
|
210 |
|
211 CleanupStack::PushL( self ); |
|
212 self->ConstructL(); |
|
213 CleanupStack::Pop(); |
|
214 |
|
215 return self; |
|
216 |
|
217 } |
|
218 |
|
219 // Destructor |
|
220 CFormatterRFSPluginTestModule::~CFormatterRFSPluginTestModule() |
|
221 { |
|
222 |
|
223 // Delete resources allocated from test methods |
|
224 Delete(); |
|
225 |
|
226 // Delete logger |
|
227 delete iLog; |
|
228 |
|
229 } |
|
230 |
|
231 |
|
232 void CFormatterRFSPluginTestModule::Delete() |
|
233 { |
|
234 |
|
235 } |
|
236 |
|
237 //----------------------------------------------------------------------------- |
|
238 // CFormatterRFSPluginTestModule::SendTestClassVersion |
|
239 // Method used to send version of test class |
|
240 //----------------------------------------------------------------------------- |
|
241 // |
|
242 void CFormatterRFSPluginTestModule::SendTestClassVersion() |
|
243 { |
|
244 TVersion moduleVersion; |
|
245 moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; |
|
246 moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; |
|
247 moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; |
|
248 |
|
249 TFileName moduleName; |
|
250 moduleName = _L("FormatterRFSPluginTestModule.dll"); |
|
251 |
|
252 TBool newVersionOfMethod = ETrue; |
|
253 TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); |
|
254 } |
|
255 |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CFormatterRFSPluginTestModule::RunMethodL |
|
259 // Run specified method. Contains also table of test mothods and their names. |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 TInt CFormatterRFSPluginTestModule::RunMethodL( |
|
263 CStifItemParser& aItem ) |
|
264 { |
|
265 |
|
266 static TStifFunctionInfo const KFunctions[] = |
|
267 { |
|
268 // Copy this line for every implemented function. |
|
269 // First string is the function name used in TestScripter script file. |
|
270 // Second is the actual implementation member function. |
|
271 // ENTRY( "Example", CFormatterRFSPluginTestModule::ExampleL ), |
|
272 //ADD NEW ENTRY HERE |
|
273 ENTRY( "SetupEmptyL", CFormatterRFSPluginTestModule::SetupEmptyL ), |
|
274 ENTRY( "SetupConditionalL", CFormatterRFSPluginTestModule::SetupConditionalL ), |
|
275 ENTRY( "SetupL", CFormatterRFSPluginTestModule::SetupL ), |
|
276 ENTRY( "SetupExcludeListOnlyL", CFormatterRFSPluginTestModule::SetupExcludeListOnlyL ), |
|
277 ENTRY( "SetupExcludeListL", CFormatterRFSPluginTestModule::SetupExcludeListL ), |
|
278 ENTRY( "SetupAppSpecExcludeListOnlyL", CFormatterRFSPluginTestModule::SetupAppSpecExcludeListOnlyL ), |
|
279 ENTRY( "SetupAppSpecExcludeListL", CFormatterRFSPluginTestModule::SetupAppSpecExcludeListL ), |
|
280 ENTRY( "Teardown", CFormatterRFSPluginTestModule::Teardown ), |
|
281 ENTRY( "TeardownExcludeList", CFormatterRFSPluginTestModule::TeardownExcludeList ), |
|
282 ENTRY( "TeardownAppSpecExcludeList", CFormatterRFSPluginTestModule::TeardownAppSpecExcludeList ), |
|
283 ENTRY( "TestConstructorL", CFormatterRFSPluginTestModule::TestConstructorL ), |
|
284 ENTRY( "TestConstructorNoMemoryL", CFormatterRFSPluginTestModule::TestConstructorNoMemoryL ), |
|
285 ENTRY( "TestRestoreConditionalL", CFormatterRFSPluginTestModule::TestRestoreConditionalL ), |
|
286 ENTRY( "TestRestoreL", CFormatterRFSPluginTestModule::TestRestoreL ), |
|
287 ENTRY( "TestRestoreWithExcludeListL", CFormatterRFSPluginTestModule::TestRestoreWithExcludeListL ), |
|
288 ENTRY( "TestRestoreNoMemoryL", CFormatterRFSPluginTestModule::TestRestoreNoMemoryL ), |
|
289 ENTRY( "TestGetScriptConditionalL", CFormatterRFSPluginTestModule::TestGetScriptConditionalL ), |
|
290 ENTRY( "TestGetScriptL", CFormatterRFSPluginTestModule::TestGetScriptL ), |
|
291 ENTRY( "TestGetScriptEmptyL", CFormatterRFSPluginTestModule::TestGetScriptEmptyL ), |
|
292 ENTRY( "TestCustomCommandL", CFormatterRFSPluginTestModule::TestCustomCommandL ), |
|
293 |
|
294 // [test cases entries] - Do not remove |
|
295 |
|
296 }; |
|
297 |
|
298 const TInt count = sizeof( KFunctions ) / |
|
299 sizeof( TStifFunctionInfo ); |
|
300 |
|
301 return RunInternalL( KFunctions, count, aItem ); |
|
302 |
|
303 } |
|
304 |
|
305 // ==========================TEST METHODS======================================= |
|
306 // --------------------------------------------------------------------------- |
|
307 // CFormatterRfsPluginTestSuite::SetupEmptyL |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 TInt CFormatterRFSPluginTestModule::SetupEmptyL(CStifItemParser& /*aItem*/) |
|
311 { |
|
312 iTestObj = NULL; |
|
313 return KErrNone; |
|
314 } |
|
315 |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // CFormatterRfsPluginTestSuite::SetupConditionalL |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 TInt CFormatterRFSPluginTestModule::SetupConditionalL(CStifItemParser& /*aItem*/) |
|
322 { |
|
323 AppExcludeListsExistL(); |
|
324 iTestObj = CRFSPlugin::NewL( TUid::Uid( 0x2001CB74 ) ); |
|
325 |
|
326 return KErrNone; |
|
327 } |
|
328 |
|
329 |
|
330 // --------------------------------------------------------------------------- |
|
331 // CFormatterRFSPluginTestModule::SetupL |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 TInt CFormatterRFSPluginTestModule::SetupL(CStifItemParser& aItem) |
|
335 { |
|
336 SetupEmptyL(aItem); |
|
337 iTestObj = CRFSPlugin::NewL( TUid::Uid( 0x2001CB74 ) ); |
|
338 |
|
339 return KErrNone; |
|
340 } |
|
341 |
|
342 |
|
343 // --------------------------------------------------------------------------- |
|
344 // CFormatterRFSPluginTestModule::SetupExcludeListOnlyL |
|
345 // --------------------------------------------------------------------------- |
|
346 // |
|
347 TInt CFormatterRFSPluginTestModule::SetupExcludeListOnlyL(CStifItemParser& /*aItem*/) |
|
348 { |
|
349 CreateExcludeListFileL( KExcludeListName ); |
|
350 return KErrNone; |
|
351 } |
|
352 |
|
353 |
|
354 // --------------------------------------------------------------------------- |
|
355 // CFormatterRFSPluginTestModule::SetupExcludeListL |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 TInt CFormatterRFSPluginTestModule::SetupExcludeListL(CStifItemParser& aItem) |
|
359 { |
|
360 CreateExcludeListFileL( KExcludeListName ); |
|
361 SetupL(aItem); |
|
362 return KErrNone; |
|
363 } |
|
364 |
|
365 |
|
366 // --------------------------------------------------------------------------- |
|
367 // CFormatterRFSPluginTestModule::SetupAppSpecExcludeListOnlyL |
|
368 // --------------------------------------------------------------------------- |
|
369 // |
|
370 TInt CFormatterRFSPluginTestModule::SetupAppSpecExcludeListOnlyL(CStifItemParser& aItem) |
|
371 { |
|
372 CreateExcludeListFileL( KExcludeListAppSpecName ); |
|
373 return KErrNone; |
|
374 } |
|
375 |
|
376 |
|
377 // --------------------------------------------------------------------------- |
|
378 // CFormatterRFSPluginTestModule::SetupAppSpecExcludeListL |
|
379 // --------------------------------------------------------------------------- |
|
380 // |
|
381 TInt CFormatterRFSPluginTestModule::SetupAppSpecExcludeListL(CStifItemParser& aItem) |
|
382 { |
|
383 CreateExcludeListFileL( KExcludeListAppSpecName ); |
|
384 SetupL(aItem); |
|
385 return KErrNone; |
|
386 } |
|
387 |
|
388 |
|
389 // --------------------------------------------------------------------------- |
|
390 // CFormatterRFSPluginTestModule::Teardown |
|
391 // --------------------------------------------------------------------------- |
|
392 // |
|
393 TInt CFormatterRFSPluginTestModule::Teardown(CStifItemParser& /*aItem*/) |
|
394 { |
|
395 delete iTestObj; |
|
396 iTestObj = NULL; |
|
397 return KErrNone; |
|
398 } |
|
399 |
|
400 |
|
401 // --------------------------------------------------------------------------- |
|
402 // CFormatterRFSPluginTestModule::TeardownExcludeList |
|
403 // --------------------------------------------------------------------------- |
|
404 // |
|
405 TInt CFormatterRFSPluginTestModule::TeardownExcludeList(CStifItemParser& aItem) |
|
406 { |
|
407 Teardown(aItem); |
|
408 TRAP_IGNORE( DeleteExcludeListFileL( KExcludeListName ) ); |
|
409 return KErrNone; |
|
410 } |
|
411 |
|
412 |
|
413 // --------------------------------------------------------------------------- |
|
414 // CFormatterRFSPluginTestModule::TeardownAppSpecExcludeList |
|
415 // --------------------------------------------------------------------------- |
|
416 // |
|
417 TInt CFormatterRFSPluginTestModule::TeardownAppSpecExcludeList(CStifItemParser& aItem) |
|
418 { |
|
419 Teardown(aItem); |
|
420 TRAP_IGNORE( DeleteExcludeListFileL( KExcludeListAppSpecName ) ); |
|
421 |
|
422 return KErrNone; |
|
423 } |
|
424 |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // CFormatterRFSPluginTestModule::TestConstructorL |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 TInt CFormatterRFSPluginTestModule::TestConstructorL(CStifItemParser& /*aItem*/) |
|
431 { |
|
432 STIF_ASSERT_NOT_LEAVES( iTestObj = CRFSPlugin::NewL( TUid::Uid( 0x2001CB74 ) ) ); |
|
433 STIF_ASSERT_NOT_NULL( iTestObj ); |
|
434 //delete iTestObj; |
|
435 //iTestObj = NULL; |
|
436 |
|
437 return KErrNone; |
|
438 } |
|
439 |
|
440 |
|
441 // --------------------------------------------------------------------------- |
|
442 // CFormatterRFSPluginTestModule::TestConstructorNoMemoryL |
|
443 // --------------------------------------------------------------------------- |
|
444 // |
|
445 TInt CFormatterRFSPluginTestModule::TestConstructorNoMemoryL(CStifItemParser& /*aItem*/) |
|
446 { |
|
447 STIF_ASSERT_LEAVES_WITH( KErrNoMemory, |
|
448 iTestObj = CRFSPlugin::NewL( TUid::Uid( 0x2001CB74 ) )); |
|
449 //EUNIT_ASSERT( !iTestObj ); |
|
450 STIF_ASSERT_NULL(iTestObj); |
|
451 return KErrNone; |
|
452 } |
|
453 |
|
454 |
|
455 // --------------------------------------------------------------------------- |
|
456 // CFormatterRFSPluginTestModule::TestRestoreConditionalL |
|
457 // --------------------------------------------------------------------------- |
|
458 // |
|
459 TInt CFormatterRFSPluginTestModule::TestRestoreConditionalL(CStifItemParser& aItem) |
|
460 { |
|
461 if( iAppSpecificFilesExist ) |
|
462 { |
|
463 TestRestoreNoMemoryL(aItem); |
|
464 } |
|
465 else |
|
466 { |
|
467 TestRestoreL(aItem); |
|
468 } |
|
469 return KErrNone; |
|
470 } |
|
471 |
|
472 |
|
473 // --------------------------------------------------------------------------- |
|
474 // CFormatterRFSPluginTestModule::TestRestoreL |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 TInt CFormatterRFSPluginTestModule::TestRestoreL(CStifItemParser& /*aItem*/) |
|
478 { |
|
479 STIF_ASSERT_NOT_LEAVES( iTestObj->RestoreFactorySettingsL( ENormalRfs ) ); |
|
480 STIF_ASSERT_NOT_LEAVES( iTestObj->RestoreFactorySettingsL( EDeepRfs ) ); |
|
481 STIF_ASSERT_NOT_LEAVES( iTestObj->RestoreFactorySettingsL( EInitRfs ) ); |
|
482 STIF_ASSERT_NOT_LEAVES( iTestObj->RestoreFactorySettingsL( static_cast<TRfsReason>( 100 ) ) ); |
|
483 |
|
484 return KErrNone; |
|
485 } |
|
486 |
|
487 |
|
488 // --------------------------------------------------------------------------- |
|
489 // CFormatterRFSPluginTestModule::TestRestoreWithExcludeListL |
|
490 // --------------------------------------------------------------------------- |
|
491 // |
|
492 TInt CFormatterRFSPluginTestModule::TestRestoreWithExcludeListL(CStifItemParser& /*aItem*/) |
|
493 { |
|
494 STIF_ASSERT_LEAVES_WITH( KErrPermissionDenied, iTestObj->RestoreFactorySettingsL( ENormalRfs )); |
|
495 STIF_ASSERT_LEAVES_WITH( KErrPermissionDenied, iTestObj->RestoreFactorySettingsL( EDeepRfs )); |
|
496 STIF_ASSERT_LEAVES_WITH( KErrPermissionDenied, iTestObj->RestoreFactorySettingsL( EInitRfs )); |
|
497 STIF_ASSERT_LEAVES_WITH( KErrPermissionDenied, iTestObj->RestoreFactorySettingsL( static_cast<TRfsReason>( 100 ) )); |
|
498 |
|
499 return KErrNone; |
|
500 } |
|
501 |
|
502 |
|
503 // --------------------------------------------------------------------------- |
|
504 // CFormatterRFSPluginTestModule::TestRestoreNoMemoryL |
|
505 // --------------------------------------------------------------------------- |
|
506 // |
|
507 TInt CFormatterRFSPluginTestModule::TestRestoreNoMemoryL(CStifItemParser& /*aItem*/) |
|
508 { |
|
509 STIF_ASSERT_LEAVES_WITH( KErrNoMemory, iTestObj->RestoreFactorySettingsL( ENormalRfs )); |
|
510 STIF_ASSERT_LEAVES_WITH( KErrNoMemory, iTestObj->RestoreFactorySettingsL( EDeepRfs )); |
|
511 STIF_ASSERT_LEAVES_WITH( KErrNoMemory, iTestObj->RestoreFactorySettingsL( EInitRfs )); |
|
512 STIF_ASSERT_LEAVES_WITH( KErrNoMemory, iTestObj->RestoreFactorySettingsL( static_cast<TRfsReason>( 100 ) )); |
|
513 |
|
514 return KErrNone; |
|
515 } |
|
516 |
|
517 |
|
518 // --------------------------------------------------------------------------- |
|
519 // CFormatterRFSPluginTestModule::TestGetScriptConditionalL |
|
520 // --------------------------------------------------------------------------- |
|
521 // |
|
522 TInt CFormatterRFSPluginTestModule::TestGetScriptConditionalL(CStifItemParser& aItem) |
|
523 { |
|
524 if( iAppSpecificFilesExist ) |
|
525 { |
|
526 TestGetScriptEmptyL(aItem); |
|
527 } |
|
528 else |
|
529 { |
|
530 TestGetScriptL(aItem); |
|
531 } |
|
532 |
|
533 return KErrNone; |
|
534 } |
|
535 |
|
536 |
|
537 // --------------------------------------------------------------------------- |
|
538 // CFormatterRFSPluginTestModule::TestGetScriptL |
|
539 // --------------------------------------------------------------------------- |
|
540 // |
|
541 TInt CFormatterRFSPluginTestModule::TestGetScriptL(CStifItemParser& /*aItem*/) |
|
542 { |
|
543 TBuf<256> path; |
|
544 TBuf<256> buf; |
|
545 buf.Copy(KExpectedScript); |
|
546 STIF_ASSERT_NOT_LEAVES( iTestObj->GetScriptL( ENormalRfs, path ) ); |
|
547 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
548 STIF_ASSERT_EQUALS( buf, path ); |
|
549 |
|
550 STIF_ASSERT_NOT_LEAVES( iTestObj->GetScriptL( EDeepRfs, path ) ); |
|
551 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
552 STIF_ASSERT_EQUALS( buf, path ); |
|
553 |
|
554 STIF_ASSERT_NOT_LEAVES( iTestObj->GetScriptL( EInitRfs, path ) ); |
|
555 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
556 STIF_ASSERT_EQUALS( buf, path ); |
|
557 |
|
558 STIF_ASSERT_NOT_LEAVES( iTestObj->GetScriptL( static_cast<TRfsReason>( 100 ), path ) ); |
|
559 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
560 STIF_ASSERT_EQUALS( buf, path ); |
|
561 |
|
562 return KErrNone; |
|
563 } |
|
564 |
|
565 |
|
566 // --------------------------------------------------------------------------- |
|
567 // CFormatterRFSPluginTestModule::TestGetScriptEmptyL |
|
568 // --------------------------------------------------------------------------- |
|
569 // |
|
570 TInt CFormatterRFSPluginTestModule::TestGetScriptEmptyL(CStifItemParser& /*aItem*/) |
|
571 { |
|
572 TBuf<256> path; |
|
573 TBuf<256> buf; |
|
574 buf.Copy(KNullDesC); |
|
575 |
|
576 STIF_ASSERT_NOT_LEAVES( iTestObj->GetScriptL( ENormalRfs, path ) ); |
|
577 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
578 STIF_ASSERT_EQUALS( buf, path); |
|
579 |
|
580 STIF_ASSERT_NOT_LEAVES( iTestObj->GetScriptL( EDeepRfs, path ) ); |
|
581 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
582 STIF_ASSERT_EQUALS( buf, path); |
|
583 |
|
584 STIF_ASSERT_NOT_LEAVES( iTestObj->GetScriptL( EInitRfs, path ) ); |
|
585 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
586 STIF_ASSERT_EQUALS( buf, path ); |
|
587 |
|
588 STIF_ASSERT_NOT_LEAVES( iTestObj->GetScriptL( static_cast<TRfsReason>( 100 ), path ) ); |
|
589 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
590 STIF_ASSERT_EQUALS( buf, path ); |
|
591 |
|
592 return KErrNone; |
|
593 } |
|
594 |
|
595 |
|
596 // --------------------------------------------------------------------------- |
|
597 // CFormatterRFSPluginTestModule::TestCustomCommandL |
|
598 // --------------------------------------------------------------------------- |
|
599 // |
|
600 TInt CFormatterRFSPluginTestModule::TestCustomCommandL(CStifItemParser& /*aItem*/) |
|
601 { |
|
602 TBuf<256> param1( KNullDesC ); |
|
603 STIF_ASSERT_NOT_LEAVES( iTestObj->ExecuteCustomCommandL( ENormalRfs, param1 ) ); |
|
604 TBuf<1> param2( KNullDesC ); |
|
605 STIF_ASSERT_NOT_LEAVES( iTestObj->ExecuteCustomCommandL( EDeepRfs, param2 ) ); |
|
606 STIF_ASSERT_NOT_LEAVES( iTestObj->ExecuteCustomCommandL( EInitRfs, param2 ) ); |
|
607 STIF_ASSERT_NOT_LEAVES( iTestObj->ExecuteCustomCommandL( static_cast<TRfsReason>( 100 ), param2 ) ); |
|
608 |
|
609 return KErrNone; |
|
610 } |
|
611 |
|
612 |
|
613 // --------------------------------------------------------------------------- |
|
614 // AppExcludeListsExistL |
|
615 // --------------------------------------------------------------------------- |
|
616 // |
|
617 void CFormatterRFSPluginTestModule::AppExcludeListsExistL() |
|
618 { |
|
619 RFs fs; |
|
620 TInt err = fs.Connect(); |
|
621 RDebug::Print(_L("Failed to connect to file server = %d"), err); |
|
622 User::LeaveIfError( err ); |
|
623 CleanupClosePushL( fs ); |
|
624 |
|
625 HBufC* buf = HBufC::NewLC( KMaxFileName ); |
|
626 TPtr bufPtr = buf->Des(); |
|
627 bufPtr.Append( KApplicationExcludeListPath ); |
|
628 bufPtr.Append( KApplicationExcludeListFileSearchPattern ); |
|
629 bufPtr[0] = fs.GetSystemDriveChar(); |
|
630 |
|
631 CDir* dirC = NULL; |
|
632 TInt errC = fs.GetDir( bufPtr, KEntryAttNormal, ESortNone, dirC ); |
|
633 CDir* dirZ = NULL; |
|
634 bufPtr[0] = KDefaultRom()[0]; |
|
635 TInt errZ = fs.GetDir( bufPtr, KEntryAttNormal, ESortNone, dirZ ); |
|
636 |
|
637 if( (errC == KErrNone && dirC->Count() ) || |
|
638 (errZ == KErrNone && dirZ->Count() ) ) |
|
639 { |
|
640 iAppSpecificFilesExist = ETrue; |
|
641 } |
|
642 else |
|
643 { |
|
644 iAppSpecificFilesExist = EFalse; |
|
645 } |
|
646 |
|
647 delete dirC; |
|
648 delete dirZ; |
|
649 CleanupStack::PopAndDestroy( buf ); |
|
650 CleanupStack::PopAndDestroy( &fs ); |
|
651 } |
|
652 |
|
653 |
|
654 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
655 |
|
656 // ----------------------------------------------------------------------------- |
|
657 // LibEntryL is a polymorphic Dll entry point. |
|
658 // Returns: CScriptBase: New CScriptBase derived object |
|
659 // ----------------------------------------------------------------------------- |
|
660 // |
|
661 EXPORT_C CScriptBase* LibEntryL( |
|
662 CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
663 { |
|
664 |
|
665 return ( CScriptBase* ) CFormatterRFSPluginTestModule::NewL( aTestModuleIf ); |
|
666 |
|
667 } |
|
668 |
|
669 // End of File |