First public contribution.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
23 #include "backup_std.h"
25 LOCAL_D CTrapCleanup* TheTrapCleanup=NULL;
26 LOCAL_D CActiveScheduler* TheActiveScheduler=NULL;
28 LOCAL_D RTest TheTest (_L("T_BaflDefect"));
31 _LIT(KServerLauncherProcess, "T_BackupServerLauncher");
32 _LIT(KServerName, "!BackupServer");
33 _LIT(KBURServerName,"baksrvs");
35 class RIpcServerCloseTest : public RSessionBase
37 public: // Constructors and destructor
40 * Constructor for performing 1st stage construction
42 RIpcServerCloseTest();
47 ~RIpcServerCloseTest();
52 void RunTestL(const TDesC& aTargetSrvName, TInt aNumber, TInt aArgCount);
55 RIpcServerCloseTest::RIpcServerCloseTest()
57 // No implementation required
60 RIpcServerCloseTest::~RIpcServerCloseTest()
65 void RIpcServerCloseTest::RunTestL(const TDesC& aTargetSrvName, TInt aNumber, TInt aArgCount)
67 TVersion version(0,0,0);
68 TInt err = KErrNotFound;
69 TInt numberOfAttempts = 3;
71 while(err!=KErrNone && numberOfAttempts>0)
73 err = CreateSession(aTargetSrvName, version, 200);
77 // wait then try again if err!=0
78 TheTest.Printf(_L("CreateSession returned: %d"), err);
84 TheTest(err == KErrNone);
86 HBufC8* buf = HBufC8::NewLC(255);
87 TPtr8 ptr = buf->Des();
88 ptr.Fill(Math::Random(),255);
92 for(TInt i = 0; i < aArgCount ;i++)
97 TheTest.Printf(_L("Sending request to: %d with %d args"), aNumber, aArgCount);
99 TRequestStatus status;
101 SendReceive(aNumber, args, status);
103 User::WaitForRequest(status);
105 TheTest.Printf(_L("Status value from sending request: %d with %d args"), status.Int(), aArgCount);
107 TheTest(status.Int() == KErrNotSupported);
109 CleanupStack::PopAndDestroy(buf);
112 //This function is used in the test code to kill backupSrv or the backuplauncher process.
113 // It creates a separate process to do this as killing a process requires
114 // PwrMgmt capability which we don't want to grant to all test exes.
115 TInt KillProcess(const TDesC& aProcessName)
117 _LIT(KProcessKiller, "t_processkiller");
120 TInt result = p.Create(KProcessKiller, aProcessName);
122 if(result == KErrNone)
124 // Asynchronous logon: completes when process terminates with process exit code
128 User::WaitForRequest(stat);
129 result = p.ExitReason();
136 TInt LaunchServer(RProcess& aServer)
138 TheTest.Printf(_L("Launching BackupServer...\n"));
140 TInt err = aServer.Create(KServerLauncherProcess, _L(""));
141 TheTest(err == KErrNone);
143 //Start server and wait until it is running
144 TRequestStatus serverStat;
145 aServer.SetJustInTime(false);
148 aServer.Rendezvous(serverStat);
149 User::WaitForRequest(serverStat);
151 err = serverStat.Int();
157 @SYMTestCaseID SYSLIB-BAFL-UT-4052
158 @SYMTestCaseDesc Tests BackupServer crashes under IPC fuzzing and freezes phone
159 @SYMTestPriority High
160 @SYMTestActions Calls BackupServer with EBakOpCodeCloseServer with 0-4 args. Verifies that server returns KErrNotSupported.
161 @SYMTestExpectedResults Server should not process the CloseServer message and should return KErrNotSupported
163 LOCAL_C void Defect_INC120743L()
165 TheTest.Next (_L ("Defect_INC120743L"));
170 TInt messageToTest = EBakOpCodeCloseServer;
172 //Clean up any chance of launcher or baksrvs still running
173 TInt err = KillProcess(KServerLauncherProcess);
174 if((err != KErrNotFound)&&(err != KErrDied))
176 User::LeaveIfError(err);
179 err = KillProcess(KBURServerName);
180 if((err != KErrNotFound)&&(err != KErrDied))
182 User::LeaveIfError(err);
185 TInt startedFlag = LaunchServer(server);
187 TheTest.Printf(_L("LaunchServer has returned: %d"), startedFlag);
189 TheTest(startedFlag == 0 || startedFlag == KErrAlreadyExists);
191 CTrapCleanup* cleanup=CTrapCleanup::New();
196 //Carry out each test with number of arguments 1 - 4
197 for(TInt argCount = 0; argCount <= 4; argCount++)
199 RIpcServerCloseTest closeTest;
201 TRAP(err,closeTest.RunTestL(KServerName, messageToTest, argCount));
213 @SYMTestCaseID SYSLIB-BAFL-CT-1390
214 @SYMTestCaseDesc Tests BaflUtils::PersistScreenCalibration
215 @SYMTestPriority Medium
216 @SYMTestActions Deletes screen calibration file, calls PersistScreenCalibration()
217 and checks that file now exists
218 @SYMTestExpectedResults Test must not fail
221 void Defect_DEF068052L()
223 TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-BAFL-CT-1390 Defect_DEF068052L "));
227 User::LeaveIfError (TheFs.Connect ());
228 ::CleanupClosePushL (TheFs);
230 const TInt KDriveLength = 2;
231 const TInt KScreenPathLength = 26;
232 const TInt KScreenPathLengthTemp = 30;
234 _LIT (KDriveColon, ":");
235 _LIT (KScreen, "\\System\\Data\\Screen.DAT");
236 _LIT (KScreenTemp, "\\System\\Data\\ScreenTemp.DAT");
238 // Find the system drive
239 TDriveNumber systemDrive = TheFs.GetSystemDrive();
241 // Set up a full file path name incorporating the system drive
242 // (for example if system drive is EDriveC pathname will be:
243 // C:\System\Data\Screen.DAT)
244 TBuf<KDriveLength+KScreenPathLength> screenFilePath;
245 screenFilePath.Append(systemDrive + 'A');
246 screenFilePath.Append(KDriveColon);
247 screenFilePath.Append(KScreen);
249 // Set up a full file path name to make a copy of the screen.dat
251 TBuf<KDriveLength+KScreenPathLengthTemp> screenFilePathTemp;
252 screenFilePathTemp.Append(systemDrive + 'A');
253 screenFilePathTemp.Append(KDriveColon);
254 screenFilePathTemp.Append(KScreenTemp);
256 // Make a copy of the screen.dat file (if it exists)
257 BaflUtils::CopyFile(TheFs, screenFilePath, screenFilePathTemp);
259 // Delete the Screen.DAT file (if it exists)
260 BaflUtils::DeleteFile(TheFs, screenFilePath);
262 // Saving Screen settings - call API to write the screen
263 // calibration to file
264 TDigitizerCalibration calib;
265 BaflUtils::PersistScreenCalibration(calib);
267 // Check if screen.dat file now exists
268 TBool exists = BaflUtils::FileExists(TheFs, screenFilePath);
271 TheTest.Printf(_L("Screen settings were saved in %S\n"), &screenFilePath);
273 // Cleaning up, restore files to original state
274 User::LeaveIfError(BaflUtils::DeleteFile(TheFs, screenFilePath));
275 BaflUtils::CopyFile(TheFs, screenFilePathTemp, screenFilePath);
276 BaflUtils::DeleteFile(TheFs, screenFilePathTemp);
277 CleanupStack::PopAndDestroy (&::TheFs);
283 @SYMTestCaseID SYSLIB-BAFL-CT-0487
284 @SYMTestCaseDesc Tests for defect number INC045169L
285 @SYMTestPriority High
286 @SYMTestActions Tests for creation of files
287 @SYMTestExpectedResults Tests must not fail
290 void Defect_INC045169L()
292 TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-BAFL-CT-0487 Defect_INC045169L "));
296 // find out the number of open handles
297 TInt startProcessHandleCount;
298 TInt startThreadHandleCount;
299 RThread ().HandleCount (startProcessHandleCount, startThreadHandleCount);
304 User::LeaveIfError (TheFs.Connect ());
305 ::CleanupClosePushL (TheFs);
308 // The Test Begins...
311 // Our test diectory and files...
312 _LIT (KDirectory, "C:\\System\\Data\\");
316 // When creating test file names be careful to use different
317 // combinations of charaters as you may get ambiguity!
318 // i.e. '.aaa' will find files '.a' or 'a' if on disk.
319 // similarly, 'abc158' will find files 'abc' or 'abc.'.
320 // Also, file name ending in a period will have them
321 // stripped off by the Fs, so 'abcd.' will give you 'abcd'
322 // Finally, don't have like names like 'abc.rsc' and 'abc.r'
325 _LIT (KFilename1, "c:"); // not supported
326 _LIT (KFilename2, "x"); // not supported
327 _LIT (KFilename3, "C:\\System\\Data\\a"); // not supported
328 _LIT (KFilename4, "C:\\System\\Data\\ab"); // not supported
329 _LIT (KFilename5, "C:\\System\\Data\\i.j"); // no 'i.01' available
330 _LIT (KFilename6, "C:\\System\\Data\\abc.r12345678901234567890"); // suffix too large
331 _LIT (KFilename7, "C:\\System\\Data\\"); // not supported
334 _LIT (KFilename10, "C:\\System\\Data\\cde");
335 _LIT (KFilename11, "C:\\System\\Data\\abc158");
336 _LIT (KFilename12, "C:\\System\\Data\\C01abc001");
337 _LIT (KFilename13, "C:\\System\\Data\\0123456789.012");
338 _LIT (KFilename14, "C:\\System\\Data\\0123");
339 _LIT (KFilename15, "C:\\System\\Data\\0123456789012");
340 _LIT (KFilename16, "C:\\System\\Data\\C.01a1");
341 _LIT (KFilename17, "C:\\System\\Data\\C.a0a1");
342 _LIT (KFilename18, "C:\\System\\Data\\.b");
343 _LIT (KFilename19, "C:\\System\\Data\\.ccc");
344 _LIT (KFilename20, "C:\\System\\Data\\rfg.3a");
345 _LIT (KFilename21, "C:\\System\\Data\\abc.r158");
346 _LIT (KFilename22, "C:\\System\\Data\\abc.rsc");
347 _LIT (KFilename23, "C:\\System\\Data\\efg.r");
348 _LIT (KFilename24, "C:\\System\\Data\\klmn.");
349 _LIT (KFilename25, "C:\\System\\Data\\jhgdfgd.123456789abc");
350 _LIT (KFilename26, "\\abc.r158");
351 _LIT (KFilename27, "abc.r158");
352 _LIT (KFilename28, "c:abc.r158");
357 _LIT (KLocale, "ELOCL.10");
358 _LIT (KNearestLang, "C:\\System\\Data\\abc.r10");
360 // Tidy the files if there...
361 // KFilename1 can't be created
362 BaflUtils::DeleteFile (TheFs, KFilename2);
363 BaflUtils::DeleteFile (TheFs, KFilename3);
364 BaflUtils::DeleteFile (TheFs, KFilename4);
365 BaflUtils::DeleteFile (TheFs, KFilename5);
366 BaflUtils::DeleteFile (TheFs, KFilename6);
368 // Do not delete KFileName7, there may be other
369 // files in this directory unrelated to this test
370 // which are required by other tests.
371 // See defect DEF108808
372 // BaflUtils::DeleteFile (TheFs, KFilename7);
374 BaflUtils::DeleteFile (TheFs, KFilename10);
375 BaflUtils::DeleteFile (TheFs, KFilename11);
376 BaflUtils::DeleteFile (TheFs, KFilename12);
377 BaflUtils::DeleteFile (TheFs, KFilename13);
378 BaflUtils::DeleteFile (TheFs, KFilename14);
379 BaflUtils::DeleteFile (TheFs, KFilename15);
380 BaflUtils::DeleteFile (TheFs, KFilename16);
381 BaflUtils::DeleteFile (TheFs, KFilename17);
382 BaflUtils::DeleteFile (TheFs, KFilename18);
383 BaflUtils::DeleteFile (TheFs, KFilename19);
384 BaflUtils::DeleteFile (TheFs, KFilename20);
385 BaflUtils::DeleteFile (TheFs, KFilename21);
386 BaflUtils::DeleteFile (TheFs, KFilename22);
387 BaflUtils::DeleteFile (TheFs, KFilename23);
389 BaflUtils::DeleteFile (TheFs, KFilename24);
391 // Windows strips off trailing periods
392 BaflUtils::DeleteFile (TheFs, _L("C:\\System\\Data\\klmn"));
394 BaflUtils::DeleteFile (TheFs, KFilename25);
395 BaflUtils::DeleteFile (TheFs, KFilename26);
396 BaflUtils::DeleteFile (TheFs, KFilename27);
397 BaflUtils::DeleteFile (TheFs, KFilename28);
398 BaflUtils::DeleteFile (TheFs, KNearestLang);
400 // Confirm the prerequisites for this test...
401 if (!BaflUtils::PathExists (TheFs, KDirectory))
403 BaflUtils::EnsurePathExistsL(TheFs, KDirectory);
406 // KFilename1 can't be created
407 TheTest (BaflUtils::FileExists (TheFs, KFilename2) == EFalse);
408 TheTest (BaflUtils::FileExists (TheFs, KFilename3) == EFalse);
409 TheTest (BaflUtils::FileExists (TheFs, KFilename4) == EFalse);
410 TheTest (BaflUtils::FileExists (TheFs, KFilename5) == EFalse);
411 TheTest (BaflUtils::FileExists (TheFs, KFilename6) == EFalse);
412 // KFilename7 can't be created, not a file
414 TheTest (BaflUtils::FileExists (TheFs, KFilename10) == EFalse);
415 TheTest (BaflUtils::FileExists (TheFs, KFilename11) == EFalse);
416 TheTest (BaflUtils::FileExists (TheFs, KFilename12) == EFalse);
417 TheTest (BaflUtils::FileExists (TheFs, KFilename13) == EFalse);
418 TheTest (BaflUtils::FileExists (TheFs, KFilename14) == EFalse);
419 TheTest (BaflUtils::FileExists (TheFs, KFilename15) == EFalse);
420 TheTest (BaflUtils::FileExists (TheFs, KFilename16) == EFalse);
421 TheTest (BaflUtils::FileExists (TheFs, KFilename17) == EFalse);
422 TheTest (BaflUtils::FileExists (TheFs, KFilename18) == EFalse);
423 TheTest (BaflUtils::FileExists (TheFs, KFilename19) == EFalse);
424 TheTest (BaflUtils::FileExists (TheFs, KFilename20) == EFalse);
425 TheTest (BaflUtils::FileExists (TheFs, KFilename21) == EFalse);
426 TheTest (BaflUtils::FileExists (TheFs, KFilename22) == EFalse);
427 TheTest (BaflUtils::FileExists (TheFs, KFilename23) == EFalse);
428 TheTest (BaflUtils::FileExists (TheFs, KFilename24) == EFalse);
429 TheTest (BaflUtils::FileExists (TheFs, KFilename25) == EFalse);
430 TheTest (BaflUtils::FileExists (TheFs, KFilename26) == EFalse);
431 TheTest (BaflUtils::FileExists (TheFs, KFilename27) == EFalse);
432 TheTest (BaflUtils::FileExists (TheFs, KFilename28) == EFalse);
433 TheTest (BaflUtils::FileExists (TheFs, KNearestLang) == EFalse);
435 // Create the files...
437 // KFilename1 can't be created
438 rFile.Create (TheFs, KFilename2, EFileRead);
440 rFile.Create (TheFs, KFilename3, EFileRead);
442 rFile.Create (TheFs, KFilename4, EFileRead);
444 rFile.Create (TheFs, KFilename5, EFileRead);
446 rFile.Create (TheFs, KFilename6, EFileRead);
448 rFile.Create (TheFs, KFilename7, EFileRead);
451 rFile.Create (TheFs, KFilename10, EFileRead);
453 rFile.Create (TheFs, KFilename11, EFileRead);
455 rFile.Create (TheFs, KFilename12, EFileRead);
457 rFile.Create (TheFs, KFilename13, EFileRead);
459 rFile.Create (TheFs, KFilename14, EFileRead);
461 rFile.Create (TheFs, KFilename15, EFileRead);
463 rFile.Create (TheFs, KFilename16, EFileRead);
465 rFile.Create (TheFs, KFilename17, EFileRead);
467 rFile.Create (TheFs, KFilename18, EFileRead);
469 rFile.Create (TheFs, KFilename19, EFileRead);
471 rFile.Create (TheFs, KFilename20, EFileRead);
473 rFile.Create (TheFs, KFilename21, EFileRead);
475 rFile.Create (TheFs, KFilename22, EFileRead);
477 rFile.Create (TheFs, KFilename23, EFileRead);
479 rFile.Create (TheFs, KFilename24, EFileRead);
481 rFile.Create (TheFs, KFilename25, EFileRead);
483 rFile.Create (TheFs, KFilename26, EFileRead);
485 rFile.Create (TheFs, KFilename27, EFileRead);
487 rFile.Create (TheFs, KFilename28, EFileRead);
489 rFile.Create (TheFs, KNearestLang, EFileRead);
492 TBuf <256> filename (KFilename1);
494 // Test the defect...
495 BaflUtils::NearestLanguageFile (TheFs, filename);
496 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename1, &filename);
497 TheTest(filename == KFilename1);
499 filename.Copy (KFilename2);
500 BaflUtils::NearestLanguageFile (TheFs, filename);
501 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename2, &filename);
502 TheTest(filename == _L("x"));
504 filename.Copy (KFilename3);
505 BaflUtils::NearestLanguageFile (TheFs, filename);
506 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename3, &filename);
507 TheTest(filename == KFilename3);
509 filename.Copy (KFilename4);
510 BaflUtils::NearestLanguageFile (TheFs, filename);
511 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename4, &filename);
512 TheTest(filename == KFilename4);
514 filename.Copy (KFilename5);
515 BaflUtils::NearestLanguageFile (TheFs, filename);
516 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename5, &filename);
517 TheTest(filename == KFilename5);
519 filename.Copy (KFilename6);
520 BaflUtils::NearestLanguageFile (TheFs, filename);
521 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename6, &filename);
522 TheTest(filename == KFilename6);
524 filename.Copy (KFilename7);
525 BaflUtils::NearestLanguageFile (TheFs, filename);
526 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename7, &filename);
527 TheTest(filename == KFilename7);
531 filename.Copy (KFilename10);
532 BaflUtils::NearestLanguageFile (TheFs, filename);
533 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename10, &filename);
534 TheTest(filename == KFilename10);
536 filename.Copy (KFilename11);
537 BaflUtils::NearestLanguageFile (TheFs, filename);
538 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename11, &filename);
539 TheTest(filename == KFilename11);
541 filename.Copy (KFilename12);
542 BaflUtils::NearestLanguageFile (TheFs, filename);
543 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename12, &filename);
544 TheTest(filename == KFilename12);
546 filename.Copy (KFilename13);
547 BaflUtils::NearestLanguageFile (TheFs, filename);
548 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename13, &filename);
549 TheTest(filename == KFilename13);
551 filename.Copy (KFilename14);
552 BaflUtils::NearestLanguageFile (TheFs, filename);
553 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename14, &filename);
554 TheTest(filename == KFilename14);
556 filename.Copy (KFilename15);
557 BaflUtils::NearestLanguageFile (TheFs, filename);
558 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename15, &filename);
559 TheTest(filename == KFilename15);
561 filename.Copy (KFilename16);
562 BaflUtils::NearestLanguageFile (TheFs, filename);
563 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename16, &filename);
564 TheTest(filename == KFilename16);
566 filename.Copy (KFilename17);
567 BaflUtils::NearestLanguageFile (TheFs, filename);
568 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename17, &filename);
569 TheTest(filename == KFilename17);
571 filename.Copy (KFilename18);
572 BaflUtils::NearestLanguageFile (TheFs, filename);
573 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename18, &filename);
574 TheTest(filename == KFilename18);
576 filename.Copy (KFilename19);
577 BaflUtils::NearestLanguageFile (TheFs, filename);
578 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename19, &filename);
579 TheTest(filename == KFilename19);
581 filename.Copy (KFilename20);
582 BaflUtils::NearestLanguageFile (TheFs, filename);
583 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename20, &filename);
584 TheTest(filename == KFilename20);
586 filename.Copy (KFilename21);
587 BaflUtils::NearestLanguageFile (TheFs, filename);
588 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename21, &filename);
589 TheTest(filename == KFilename21);
591 filename.Copy (KFilename22);
592 BaflUtils::NearestLanguageFile (TheFs, filename);
593 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename22, &filename);
594 TheTest(filename == KFilename22);
596 filename.Copy (KFilename23);
597 BaflUtils::NearestLanguageFile (TheFs, filename);
598 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename23, &filename);
599 TheTest(filename == KFilename23);
601 filename.Copy (KFilename24);
602 BaflUtils::NearestLanguageFile (TheFs, filename);
603 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename24, &filename);
604 TheTest(filename == KFilename24);
606 filename.Copy (KFilename25);
607 BaflUtils::NearestLanguageFile (TheFs, filename);
608 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename25, &filename);
609 TheTest(filename == KFilename25);
611 filename.Copy (KFilename26);
612 BaflUtils::NearestLanguageFile (TheFs, filename);
613 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename26, &filename);
614 TheTest(filename == KFilename26);
616 filename.Copy (KFilename27);
617 BaflUtils::NearestLanguageFile (TheFs, filename);
618 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename27, &filename);
619 TheTest(filename == KFilename27);
621 filename.Copy (KFilename28);
622 BaflUtils::NearestLanguageFile (TheFs, filename);
623 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename28, &filename);
624 TheTest(filename == KFilename28);
627 // Store the original locale settings so they can be restored at the
630 TExtendedLocale originalLocale;
631 originalLocale.LoadSystemSettings();
634 TExtendedLocale newLocale;
635 TBuf<50> libraryName;
637 libraryName.Format(KLocale);
639 TInt err = newLocale.LoadLocale(libraryName);
640 User::LeaveIfError (err);
642 newLocale.SaveSystemSettings();
643 User::After (5000000);
645 filename.Copy (KFilename1);
646 BaflUtils::NearestLanguageFile (TheFs, filename);
647 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename1, &filename);
648 TheTest(filename == KFilename1);
650 filename.Copy (KFilename2);
651 BaflUtils::NearestLanguageFile (TheFs, filename);
652 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename2, &filename);
653 TheTest(filename == _L("x"));
655 filename.Copy (KFilename3);
656 BaflUtils::NearestLanguageFile (TheFs, filename);
657 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename3, &filename);
658 TheTest(filename == KFilename3);
660 filename.Copy (KFilename4);
661 BaflUtils::NearestLanguageFile (TheFs, filename);
662 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename4, &filename);
663 TheTest(filename == KFilename4);
665 filename.Copy (KFilename5);
666 BaflUtils::NearestLanguageFile (TheFs, filename);
667 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename5, &filename);
668 TheTest(filename == KFilename5);
670 filename.Copy (KFilename6);
671 BaflUtils::NearestLanguageFile (TheFs, filename);
672 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename6, &filename);
673 TheTest(filename == KFilename6);
675 filename.Copy (KFilename7);
676 BaflUtils::NearestLanguageFile (TheFs, filename);
677 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename7, &filename);
678 TheTest(filename == KFilename7);
682 filename.Copy (KFilename10);
683 BaflUtils::NearestLanguageFile (TheFs, filename);
684 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename10, &filename);
685 TheTest(filename == KFilename10);
687 filename.Copy (KFilename11);
688 BaflUtils::NearestLanguageFile (TheFs, filename);
689 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename11, &filename);
690 TheTest(filename == KFilename11);
692 filename.Copy (KFilename12);
693 BaflUtils::NearestLanguageFile (TheFs, filename);
694 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename12, &filename);
695 TheTest(filename == KFilename12);
697 filename.Copy (KFilename13);
698 BaflUtils::NearestLanguageFile (TheFs, filename);
699 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename13, &filename);
700 TheTest(filename == KFilename13);
702 filename.Copy (KFilename14);
703 BaflUtils::NearestLanguageFile (TheFs, filename);
704 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename14, &filename);
705 TheTest(filename == KFilename14);
707 filename.Copy (KFilename15);
708 BaflUtils::NearestLanguageFile (TheFs, filename);
709 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename15, &filename);
710 TheTest(filename == KFilename15);
712 filename.Copy (KFilename16);
713 BaflUtils::NearestLanguageFile (TheFs, filename);
714 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename16, &filename);
715 TheTest(filename == KFilename16);
717 filename.Copy (KFilename17);
718 BaflUtils::NearestLanguageFile (TheFs, filename);
719 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename17, &filename);
720 TheTest(filename == KFilename17);
722 filename.Copy (KFilename18);
723 BaflUtils::NearestLanguageFile (TheFs, filename);
724 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename18, &filename);
725 TheTest(filename == KFilename18);
727 filename.Copy (KFilename19);
728 BaflUtils::NearestLanguageFile (TheFs, filename);
729 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename19, &filename);
730 TheTest(filename == KFilename19);
732 filename.Copy (KFilename20);
733 BaflUtils::NearestLanguageFile (TheFs, filename);
734 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename20, &filename);
735 TheTest(filename == KFilename20);
737 filename.Copy (KFilename21);
738 BaflUtils::NearestLanguageFile (TheFs, filename);
739 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename21, &filename);
740 TheTest(filename == KNearestLang);
742 filename.Copy (KFilename22);
743 BaflUtils::NearestLanguageFile (TheFs, filename);
744 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename22, &filename);
745 TheTest(filename == KNearestLang);
747 filename.Copy (KFilename23);
748 BaflUtils::NearestLanguageFile (TheFs, filename);
749 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename23, &filename);
750 TheTest(filename == KFilename23);
752 filename.Copy (KFilename24);
753 BaflUtils::NearestLanguageFile (TheFs, filename);
754 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename24, &filename);
755 TheTest(filename == KFilename24);
757 filename.Copy (KFilename25);
758 BaflUtils::NearestLanguageFile (TheFs, filename);
759 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename25, &filename);
760 TheTest(filename == KFilename25);
762 filename.Copy (KFilename26);
763 BaflUtils::NearestLanguageFile (TheFs, filename);
764 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename26, &filename);
765 TheTest(filename == KFilename26);
767 filename.Copy (KFilename27);
768 BaflUtils::NearestLanguageFile (TheFs, filename);
769 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename27, &filename);
770 TheTest(filename == KFilename27);
772 filename.Copy (KFilename28);
773 BaflUtils::NearestLanguageFile (TheFs, filename);
774 TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename28, &filename);
775 TheTest(filename == KFilename28);
778 // KFilename1 can't be created
779 BaflUtils::DeleteFile (TheFs, KFilename2);
780 BaflUtils::DeleteFile (TheFs, KFilename3);
781 BaflUtils::DeleteFile (TheFs, KFilename4);
782 BaflUtils::DeleteFile (TheFs, KFilename5);
783 BaflUtils::DeleteFile (TheFs, KFilename6);
785 // Do not delete KFileName7, there may be other
786 // files in this directory unrelated to this test
787 // which are required by other tests.
788 // See defect DEF108808
789 // BaflUtils::DeleteFile (TheFs, KFilename7);
791 BaflUtils::DeleteFile (TheFs, KFilename10);
792 BaflUtils::DeleteFile (TheFs, KFilename11);
793 BaflUtils::DeleteFile (TheFs, KFilename12);
794 BaflUtils::DeleteFile (TheFs, KFilename13);
795 BaflUtils::DeleteFile (TheFs, KFilename14);
796 BaflUtils::DeleteFile (TheFs, KFilename15);
797 BaflUtils::DeleteFile (TheFs, KFilename16);
798 BaflUtils::DeleteFile (TheFs, KFilename17);
799 BaflUtils::DeleteFile (TheFs, KFilename18);
800 BaflUtils::DeleteFile (TheFs, KFilename19);
801 BaflUtils::DeleteFile (TheFs, KFilename20);
802 BaflUtils::DeleteFile (TheFs, KFilename21);
803 BaflUtils::DeleteFile (TheFs, KFilename22);
804 BaflUtils::DeleteFile (TheFs, KFilename23);
806 BaflUtils::DeleteFile (TheFs, KFilename24);
808 // Windows strips off trailing periods
809 BaflUtils::DeleteFile (TheFs, _L("C:\\System\\Data\\klmn"));
811 BaflUtils::DeleteFile (TheFs, KFilename25);
812 BaflUtils::DeleteFile (TheFs, KFilename26);
813 BaflUtils::DeleteFile (TheFs, KFilename27);
814 BaflUtils::DeleteFile (TheFs, KFilename28);
815 BaflUtils::DeleteFile (TheFs, KNearestLang);
817 // Restore the original locale settings.
818 originalLocale.SaveSystemSettings();
820 CleanupStack::PopAndDestroy (&::TheFs);
825 // check that no handles have leaked
826 TInt endProcessHandleCount;
827 TInt endThreadHandleCount;
828 RThread ().HandleCount (endProcessHandleCount, endThreadHandleCount);
830 TheTest (startThreadHandleCount == endThreadHandleCount);
835 //===============================================================================
838 Initialise the cleanup stack and active scheduler
840 LOCAL_C void SetupL ()
842 TheTrapCleanup = CTrapCleanup::New ();
843 User::LeaveIfNull (TheTrapCleanup);
845 // Construct and install the active scheduler
846 TheActiveScheduler = new (ELeave) CActiveScheduler;
847 CActiveScheduler::Install (TheActiveScheduler);
853 LOCAL_C void CleanupL ()
855 delete TheActiveScheduler;
856 delete TheTrapCleanup;
863 LOCAL_C void DoTestsL ()
865 Defect_INC045169L ();
866 Defect_DEF068052L ();
868 Defect_INC120743L ();
871 GLDEF_C TInt E32Main ()
875 TheTest.Printf (_L ("\n"));
877 TheTest.Start (_L("Defect Tests "));
879 TRAPD (err, SetupL ());
880 TheTest (err == KErrNone);
882 TRAP (err, DoTestsL ());
883 TheTest (err == KErrNone);