sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "backup_std.h" sl@0: sl@0: LOCAL_D CTrapCleanup* TheTrapCleanup=NULL; sl@0: LOCAL_D CActiveScheduler* TheActiveScheduler=NULL; sl@0: sl@0: LOCAL_D RTest TheTest (_L("T_BaflDefect")); sl@0: LOCAL_D RFs TheFs; sl@0: sl@0: _LIT(KServerLauncherProcess, "T_BackupServerLauncher"); sl@0: _LIT(KServerName, "!BackupServer"); sl@0: _LIT(KBURServerName,"baksrvs"); sl@0: sl@0: class RIpcServerCloseTest : public RSessionBase sl@0: { sl@0: public: // Constructors and destructor sl@0: sl@0: /** sl@0: * Constructor for performing 1st stage construction sl@0: */ sl@0: RIpcServerCloseTest(); sl@0: sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: ~RIpcServerCloseTest(); sl@0: sl@0: /** sl@0: * Performs test steps sl@0: */ sl@0: void RunTestL(const TDesC& aTargetSrvName, TInt aNumber, TInt aArgCount); sl@0: }; sl@0: sl@0: RIpcServerCloseTest::RIpcServerCloseTest() sl@0: { sl@0: // No implementation required sl@0: } sl@0: sl@0: RIpcServerCloseTest::~RIpcServerCloseTest() sl@0: { sl@0: Close(); sl@0: } sl@0: sl@0: void RIpcServerCloseTest::RunTestL(const TDesC& aTargetSrvName, TInt aNumber, TInt aArgCount) sl@0: { sl@0: TVersion version(0,0,0); sl@0: TInt err = KErrNotFound; sl@0: TInt numberOfAttempts = 3; sl@0: sl@0: while(err!=KErrNone && numberOfAttempts>0) sl@0: { sl@0: err = CreateSession(aTargetSrvName, version, 200); sl@0: sl@0: if(err!=KErrNone) sl@0: { sl@0: // wait then try again if err!=0 sl@0: TheTest.Printf(_L("CreateSession returned: %d"), err); sl@0: User::After(1000000); sl@0: numberOfAttempts--; sl@0: } sl@0: } sl@0: sl@0: TheTest(err == KErrNone); sl@0: sl@0: HBufC8* buf = HBufC8::NewLC(255); sl@0: TPtr8 ptr = buf->Des(); sl@0: ptr.Fill(Math::Random(),255); sl@0: sl@0: TIpcArgs args; sl@0: sl@0: for(TInt i = 0; i < aArgCount ;i++) sl@0: { sl@0: args.Set(i,&ptr); sl@0: } sl@0: sl@0: TheTest.Printf(_L("Sending request to: %d with %d args"), aNumber, aArgCount); sl@0: sl@0: TRequestStatus status; sl@0: sl@0: SendReceive(aNumber, args, status); sl@0: sl@0: User::WaitForRequest(status); sl@0: sl@0: TheTest.Printf(_L("Status value from sending request: %d with %d args"), status.Int(), aArgCount); sl@0: sl@0: TheTest(status.Int() == KErrNotSupported); sl@0: sl@0: CleanupStack::PopAndDestroy(buf); sl@0: } sl@0: sl@0: //This function is used in the test code to kill backupSrv or the backuplauncher process. sl@0: // It creates a separate process to do this as killing a process requires sl@0: // PwrMgmt capability which we don't want to grant to all test exes. sl@0: TInt KillProcess(const TDesC& aProcessName) sl@0: { sl@0: _LIT(KProcessKiller, "t_processkiller"); sl@0: TRequestStatus stat; sl@0: RProcess p; sl@0: TInt result = p.Create(KProcessKiller, aProcessName); sl@0: sl@0: if(result == KErrNone) sl@0: { sl@0: // Asynchronous logon: completes when process terminates with process exit code sl@0: p.Logon(stat); sl@0: p.Resume(); sl@0: sl@0: User::WaitForRequest(stat); sl@0: result = p.ExitReason(); sl@0: p.Close(); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: TInt LaunchServer(RProcess& aServer) sl@0: { sl@0: TheTest.Printf(_L("Launching BackupServer...\n")); sl@0: sl@0: TInt err = aServer.Create(KServerLauncherProcess, _L("")); sl@0: TheTest(err == KErrNone); sl@0: sl@0: //Start server and wait until it is running sl@0: TRequestStatus serverStat; sl@0: aServer.SetJustInTime(false); sl@0: aServer.Resume(); sl@0: sl@0: aServer.Rendezvous(serverStat); sl@0: User::WaitForRequest(serverStat); sl@0: sl@0: err = serverStat.Int(); sl@0: sl@0: return err; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-UT-4052 sl@0: @SYMTestCaseDesc Tests BackupServer crashes under IPC fuzzing and freezes phone sl@0: @SYMTestPriority High sl@0: @SYMTestActions Calls BackupServer with EBakOpCodeCloseServer with 0-4 args. Verifies that server returns KErrNotSupported. sl@0: @SYMTestExpectedResults Server should not process the CloseServer message and should return KErrNotSupported sl@0: */ sl@0: LOCAL_C void Defect_INC120743L() sl@0: { sl@0: TheTest.Next (_L ("Defect_INC120743L")); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: RProcess server; sl@0: TInt messageToTest = EBakOpCodeCloseServer; sl@0: sl@0: //Clean up any chance of launcher or baksrvs still running sl@0: TInt err = KillProcess(KServerLauncherProcess); sl@0: if((err != KErrNotFound)&&(err != KErrDied)) sl@0: { sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: err = KillProcess(KBURServerName); sl@0: if((err != KErrNotFound)&&(err != KErrDied)) sl@0: { sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: TInt startedFlag = LaunchServer(server); sl@0: sl@0: TheTest.Printf(_L("LaunchServer has returned: %d"), startedFlag); sl@0: sl@0: TheTest(startedFlag == 0 || startedFlag == KErrAlreadyExists); sl@0: sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: err=KErrNoMemory; sl@0: sl@0: if (cleanup) sl@0: { sl@0: //Carry out each test with number of arguments 1 - 4 sl@0: for(TInt argCount = 0; argCount <= 4; argCount++) sl@0: { sl@0: RIpcServerCloseTest closeTest; sl@0: sl@0: TRAP(err,closeTest.RunTestL(KServerName, messageToTest, argCount)); sl@0: sl@0: closeTest.Close(); sl@0: } sl@0: sl@0: delete cleanup; sl@0: } sl@0: sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-1390 sl@0: @SYMTestCaseDesc Tests BaflUtils::PersistScreenCalibration sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Deletes screen calibration file, calls PersistScreenCalibration() sl@0: and checks that file now exists sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void Defect_DEF068052L() sl@0: { sl@0: TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-BAFL-CT-1390 Defect_DEF068052L ")); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: User::LeaveIfError (TheFs.Connect ()); sl@0: ::CleanupClosePushL (TheFs); sl@0: sl@0: const TInt KDriveLength = 2; sl@0: const TInt KScreenPathLength = 26; sl@0: const TInt KScreenPathLengthTemp = 30; sl@0: sl@0: _LIT (KDriveColon, ":"); sl@0: _LIT (KScreen, "\\System\\Data\\Screen.DAT"); sl@0: _LIT (KScreenTemp, "\\System\\Data\\ScreenTemp.DAT"); sl@0: sl@0: // Find the system drive sl@0: TDriveNumber systemDrive = TheFs.GetSystemDrive(); sl@0: sl@0: // Set up a full file path name incorporating the system drive sl@0: // (for example if system drive is EDriveC pathname will be: sl@0: // C:\System\Data\Screen.DAT) sl@0: TBuf screenFilePath; sl@0: screenFilePath.Append(systemDrive + 'A'); sl@0: screenFilePath.Append(KDriveColon); sl@0: screenFilePath.Append(KScreen); sl@0: sl@0: // Set up a full file path name to make a copy of the screen.dat sl@0: // file. sl@0: TBuf screenFilePathTemp; sl@0: screenFilePathTemp.Append(systemDrive + 'A'); sl@0: screenFilePathTemp.Append(KDriveColon); sl@0: screenFilePathTemp.Append(KScreenTemp); sl@0: sl@0: // Make a copy of the screen.dat file (if it exists) sl@0: BaflUtils::CopyFile(TheFs, screenFilePath, screenFilePathTemp); sl@0: sl@0: // Delete the Screen.DAT file (if it exists) sl@0: BaflUtils::DeleteFile(TheFs, screenFilePath); sl@0: sl@0: // Saving Screen settings - call API to write the screen sl@0: // calibration to file sl@0: TDigitizerCalibration calib; sl@0: BaflUtils::PersistScreenCalibration(calib); sl@0: sl@0: // Check if screen.dat file now exists sl@0: TBool exists = BaflUtils::FileExists(TheFs, screenFilePath); sl@0: TheTest(exists); sl@0: sl@0: TheTest.Printf(_L("Screen settings were saved in %S\n"), &screenFilePath); sl@0: sl@0: // Cleaning up, restore files to original state sl@0: User::LeaveIfError(BaflUtils::DeleteFile(TheFs, screenFilePath)); sl@0: BaflUtils::CopyFile(TheFs, screenFilePathTemp, screenFilePath); sl@0: BaflUtils::DeleteFile(TheFs, screenFilePathTemp); sl@0: CleanupStack::PopAndDestroy (&::TheFs); sl@0: sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0487 sl@0: @SYMTestCaseDesc Tests for defect number INC045169L sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for creation of files sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void Defect_INC045169L() sl@0: { sl@0: TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-BAFL-CT-0487 Defect_INC045169L ")); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: // find out the number of open handles sl@0: TInt startProcessHandleCount; sl@0: TInt startThreadHandleCount; sl@0: RThread ().HandleCount (startProcessHandleCount, startThreadHandleCount); sl@0: sl@0: // sl@0: // The Test Setup sl@0: sl@0: User::LeaveIfError (TheFs.Connect ()); sl@0: ::CleanupClosePushL (TheFs); sl@0: sl@0: // sl@0: // The Test Begins... sl@0: sl@0: sl@0: // Our test diectory and files... sl@0: _LIT (KDirectory, "C:\\System\\Data\\"); sl@0: sl@0: // ++++++++++++++ sl@0: sl@0: // When creating test file names be careful to use different sl@0: // combinations of charaters as you may get ambiguity! sl@0: // i.e. '.aaa' will find files '.a' or 'a' if on disk. sl@0: // similarly, 'abc158' will find files 'abc' or 'abc.'. sl@0: // Also, file name ending in a period will have them sl@0: // stripped off by the Fs, so 'abcd.' will give you 'abcd' sl@0: // Finally, don't have like names like 'abc.rsc' and 'abc.r' sl@0: sl@0: // Failure cases sl@0: _LIT (KFilename1, "c:"); // not supported sl@0: _LIT (KFilename2, "x"); // not supported sl@0: _LIT (KFilename3, "C:\\System\\Data\\a"); // not supported sl@0: _LIT (KFilename4, "C:\\System\\Data\\ab"); // not supported sl@0: _LIT (KFilename5, "C:\\System\\Data\\i.j"); // no 'i.01' available sl@0: _LIT (KFilename6, "C:\\System\\Data\\abc.r12345678901234567890"); // suffix too large sl@0: _LIT (KFilename7, "C:\\System\\Data\\"); // not supported sl@0: sl@0: // Successful cases sl@0: _LIT (KFilename10, "C:\\System\\Data\\cde"); sl@0: _LIT (KFilename11, "C:\\System\\Data\\abc158"); sl@0: _LIT (KFilename12, "C:\\System\\Data\\C01abc001"); sl@0: _LIT (KFilename13, "C:\\System\\Data\\0123456789.012"); sl@0: _LIT (KFilename14, "C:\\System\\Data\\0123"); sl@0: _LIT (KFilename15, "C:\\System\\Data\\0123456789012"); sl@0: _LIT (KFilename16, "C:\\System\\Data\\C.01a1"); sl@0: _LIT (KFilename17, "C:\\System\\Data\\C.a0a1"); sl@0: _LIT (KFilename18, "C:\\System\\Data\\.b"); sl@0: _LIT (KFilename19, "C:\\System\\Data\\.ccc"); sl@0: _LIT (KFilename20, "C:\\System\\Data\\rfg.3a"); sl@0: _LIT (KFilename21, "C:\\System\\Data\\abc.r158"); sl@0: _LIT (KFilename22, "C:\\System\\Data\\abc.rsc"); sl@0: _LIT (KFilename23, "C:\\System\\Data\\efg.r"); sl@0: _LIT (KFilename24, "C:\\System\\Data\\klmn."); sl@0: _LIT (KFilename25, "C:\\System\\Data\\jhgdfgd.123456789abc"); sl@0: _LIT (KFilename26, "\\abc.r158"); sl@0: _LIT (KFilename27, "abc.r158"); sl@0: _LIT (KFilename28, "c:abc.r158"); sl@0: sl@0: // ++++++++++++++ sl@0: sl@0: // ELangAmerican sl@0: _LIT (KLocale, "ELOCL.10"); sl@0: _LIT (KNearestLang, "C:\\System\\Data\\abc.r10"); sl@0: sl@0: // Tidy the files if there... sl@0: // KFilename1 can't be created sl@0: BaflUtils::DeleteFile (TheFs, KFilename2); sl@0: BaflUtils::DeleteFile (TheFs, KFilename3); sl@0: BaflUtils::DeleteFile (TheFs, KFilename4); sl@0: BaflUtils::DeleteFile (TheFs, KFilename5); sl@0: BaflUtils::DeleteFile (TheFs, KFilename6); sl@0: sl@0: // Do not delete KFileName7, there may be other sl@0: // files in this directory unrelated to this test sl@0: // which are required by other tests. sl@0: // See defect DEF108808 sl@0: // BaflUtils::DeleteFile (TheFs, KFilename7); sl@0: sl@0: BaflUtils::DeleteFile (TheFs, KFilename10); sl@0: BaflUtils::DeleteFile (TheFs, KFilename11); sl@0: BaflUtils::DeleteFile (TheFs, KFilename12); sl@0: BaflUtils::DeleteFile (TheFs, KFilename13); sl@0: BaflUtils::DeleteFile (TheFs, KFilename14); sl@0: BaflUtils::DeleteFile (TheFs, KFilename15); sl@0: BaflUtils::DeleteFile (TheFs, KFilename16); sl@0: BaflUtils::DeleteFile (TheFs, KFilename17); sl@0: BaflUtils::DeleteFile (TheFs, KFilename18); sl@0: BaflUtils::DeleteFile (TheFs, KFilename19); sl@0: BaflUtils::DeleteFile (TheFs, KFilename20); sl@0: BaflUtils::DeleteFile (TheFs, KFilename21); sl@0: BaflUtils::DeleteFile (TheFs, KFilename22); sl@0: BaflUtils::DeleteFile (TheFs, KFilename23); sl@0: #ifdef __EPOC32__ sl@0: BaflUtils::DeleteFile (TheFs, KFilename24); sl@0: #else sl@0: // Windows strips off trailing periods sl@0: BaflUtils::DeleteFile (TheFs, _L("C:\\System\\Data\\klmn")); sl@0: #endif sl@0: BaflUtils::DeleteFile (TheFs, KFilename25); sl@0: BaflUtils::DeleteFile (TheFs, KFilename26); sl@0: BaflUtils::DeleteFile (TheFs, KFilename27); sl@0: BaflUtils::DeleteFile (TheFs, KFilename28); sl@0: BaflUtils::DeleteFile (TheFs, KNearestLang); sl@0: sl@0: // Confirm the prerequisites for this test... sl@0: if (!BaflUtils::PathExists (TheFs, KDirectory)) sl@0: { sl@0: BaflUtils::EnsurePathExistsL(TheFs, KDirectory); sl@0: } sl@0: sl@0: // KFilename1 can't be created sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename2) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename3) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename4) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename5) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename6) == EFalse); sl@0: // KFilename7 can't be created, not a file sl@0: sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename10) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename11) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename12) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename13) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename14) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename15) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename16) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename17) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename18) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename19) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename20) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename21) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename22) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename23) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename24) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename25) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename26) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename27) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KFilename28) == EFalse); sl@0: TheTest (BaflUtils::FileExists (TheFs, KNearestLang) == EFalse); sl@0: sl@0: // Create the files... sl@0: RFile rFile; sl@0: // KFilename1 can't be created sl@0: rFile.Create (TheFs, KFilename2, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename3, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename4, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename5, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename6, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename7, EFileRead); sl@0: rFile.Close (); sl@0: sl@0: rFile.Create (TheFs, KFilename10, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename11, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename12, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename13, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename14, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename15, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename16, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename17, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename18, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename19, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename20, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename21, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename22, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename23, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename24, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename25, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename26, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename27, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KFilename28, EFileRead); sl@0: rFile.Close (); sl@0: rFile.Create (TheFs, KNearestLang, EFileRead); sl@0: rFile.Close (); sl@0: sl@0: TBuf <256> filename (KFilename1); sl@0: sl@0: // Test the defect... sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename1, &filename); sl@0: TheTest(filename == KFilename1); sl@0: sl@0: filename.Copy (KFilename2); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename2, &filename); sl@0: TheTest(filename == _L("x")); sl@0: sl@0: filename.Copy (KFilename3); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename3, &filename); sl@0: TheTest(filename == KFilename3); sl@0: sl@0: filename.Copy (KFilename4); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename4, &filename); sl@0: TheTest(filename == KFilename4); sl@0: sl@0: filename.Copy (KFilename5); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename5, &filename); sl@0: TheTest(filename == KFilename5); sl@0: sl@0: filename.Copy (KFilename6); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename6, &filename); sl@0: TheTest(filename == KFilename6); sl@0: sl@0: filename.Copy (KFilename7); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename7, &filename); sl@0: TheTest(filename == KFilename7); sl@0: sl@0: sl@0: sl@0: filename.Copy (KFilename10); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename10, &filename); sl@0: TheTest(filename == KFilename10); sl@0: sl@0: filename.Copy (KFilename11); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename11, &filename); sl@0: TheTest(filename == KFilename11); sl@0: sl@0: filename.Copy (KFilename12); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename12, &filename); sl@0: TheTest(filename == KFilename12); sl@0: sl@0: filename.Copy (KFilename13); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename13, &filename); sl@0: TheTest(filename == KFilename13); sl@0: sl@0: filename.Copy (KFilename14); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename14, &filename); sl@0: TheTest(filename == KFilename14); sl@0: sl@0: filename.Copy (KFilename15); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename15, &filename); sl@0: TheTest(filename == KFilename15); sl@0: sl@0: filename.Copy (KFilename16); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename16, &filename); sl@0: TheTest(filename == KFilename16); sl@0: sl@0: filename.Copy (KFilename17); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename17, &filename); sl@0: TheTest(filename == KFilename17); sl@0: sl@0: filename.Copy (KFilename18); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename18, &filename); sl@0: TheTest(filename == KFilename18); sl@0: sl@0: filename.Copy (KFilename19); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename19, &filename); sl@0: TheTest(filename == KFilename19); sl@0: sl@0: filename.Copy (KFilename20); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename20, &filename); sl@0: TheTest(filename == KFilename20); sl@0: sl@0: filename.Copy (KFilename21); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename21, &filename); sl@0: TheTest(filename == KFilename21); sl@0: sl@0: filename.Copy (KFilename22); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename22, &filename); sl@0: TheTest(filename == KFilename22); sl@0: sl@0: filename.Copy (KFilename23); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename23, &filename); sl@0: TheTest(filename == KFilename23); sl@0: sl@0: filename.Copy (KFilename24); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename24, &filename); sl@0: TheTest(filename == KFilename24); sl@0: sl@0: filename.Copy (KFilename25); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename25, &filename); sl@0: TheTest(filename == KFilename25); sl@0: sl@0: filename.Copy (KFilename26); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename26, &filename); sl@0: TheTest(filename == KFilename26); sl@0: sl@0: filename.Copy (KFilename27); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename27, &filename); sl@0: TheTest(filename == KFilename27); sl@0: sl@0: filename.Copy (KFilename28); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename28, &filename); sl@0: TheTest(filename == KFilename28); sl@0: sl@0: sl@0: // Store the original locale settings so they can be restored at the sl@0: // end of the test. sl@0: sl@0: TExtendedLocale originalLocale; sl@0: originalLocale.LoadSystemSettings(); sl@0: sl@0: // Change locale sl@0: TExtendedLocale newLocale; sl@0: TBuf<50> libraryName; sl@0: sl@0: libraryName.Format(KLocale); sl@0: sl@0: TInt err = newLocale.LoadLocale(libraryName); sl@0: User::LeaveIfError (err); sl@0: sl@0: newLocale.SaveSystemSettings(); sl@0: User::After (5000000); sl@0: sl@0: filename.Copy (KFilename1); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename1, &filename); sl@0: TheTest(filename == KFilename1); sl@0: sl@0: filename.Copy (KFilename2); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename2, &filename); sl@0: TheTest(filename == _L("x")); sl@0: sl@0: filename.Copy (KFilename3); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename3, &filename); sl@0: TheTest(filename == KFilename3); sl@0: sl@0: filename.Copy (KFilename4); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename4, &filename); sl@0: TheTest(filename == KFilename4); sl@0: sl@0: filename.Copy (KFilename5); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename5, &filename); sl@0: TheTest(filename == KFilename5); sl@0: sl@0: filename.Copy (KFilename6); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename6, &filename); sl@0: TheTest(filename == KFilename6); sl@0: sl@0: filename.Copy (KFilename7); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename7, &filename); sl@0: TheTest(filename == KFilename7); sl@0: sl@0: sl@0: sl@0: filename.Copy (KFilename10); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename10, &filename); sl@0: TheTest(filename == KFilename10); sl@0: sl@0: filename.Copy (KFilename11); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename11, &filename); sl@0: TheTest(filename == KFilename11); sl@0: sl@0: filename.Copy (KFilename12); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename12, &filename); sl@0: TheTest(filename == KFilename12); sl@0: sl@0: filename.Copy (KFilename13); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename13, &filename); sl@0: TheTest(filename == KFilename13); sl@0: sl@0: filename.Copy (KFilename14); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename14, &filename); sl@0: TheTest(filename == KFilename14); sl@0: sl@0: filename.Copy (KFilename15); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename15, &filename); sl@0: TheTest(filename == KFilename15); sl@0: sl@0: filename.Copy (KFilename16); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename16, &filename); sl@0: TheTest(filename == KFilename16); sl@0: sl@0: filename.Copy (KFilename17); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename17, &filename); sl@0: TheTest(filename == KFilename17); sl@0: sl@0: filename.Copy (KFilename18); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename18, &filename); sl@0: TheTest(filename == KFilename18); sl@0: sl@0: filename.Copy (KFilename19); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename19, &filename); sl@0: TheTest(filename == KFilename19); sl@0: sl@0: filename.Copy (KFilename20); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename20, &filename); sl@0: TheTest(filename == KFilename20); sl@0: sl@0: filename.Copy (KFilename21); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename21, &filename); sl@0: TheTest(filename == KNearestLang); sl@0: sl@0: filename.Copy (KFilename22); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename22, &filename); sl@0: TheTest(filename == KNearestLang); sl@0: sl@0: filename.Copy (KFilename23); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename23, &filename); sl@0: TheTest(filename == KFilename23); sl@0: sl@0: filename.Copy (KFilename24); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename24, &filename); sl@0: TheTest(filename == KFilename24); sl@0: sl@0: filename.Copy (KFilename25); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename25, &filename); sl@0: TheTest(filename == KFilename25); sl@0: sl@0: filename.Copy (KFilename26); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename26, &filename); sl@0: TheTest(filename == KFilename26); sl@0: sl@0: filename.Copy (KFilename27); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename27, &filename); sl@0: TheTest(filename == KFilename27); sl@0: sl@0: filename.Copy (KFilename28); sl@0: BaflUtils::NearestLanguageFile (TheFs, filename); sl@0: TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename28, &filename); sl@0: TheTest(filename == KFilename28); sl@0: sl@0: // Tidy the files... sl@0: // KFilename1 can't be created sl@0: BaflUtils::DeleteFile (TheFs, KFilename2); sl@0: BaflUtils::DeleteFile (TheFs, KFilename3); sl@0: BaflUtils::DeleteFile (TheFs, KFilename4); sl@0: BaflUtils::DeleteFile (TheFs, KFilename5); sl@0: BaflUtils::DeleteFile (TheFs, KFilename6); sl@0: sl@0: // Do not delete KFileName7, there may be other sl@0: // files in this directory unrelated to this test sl@0: // which are required by other tests. sl@0: // See defect DEF108808 sl@0: // BaflUtils::DeleteFile (TheFs, KFilename7); sl@0: sl@0: BaflUtils::DeleteFile (TheFs, KFilename10); sl@0: BaflUtils::DeleteFile (TheFs, KFilename11); sl@0: BaflUtils::DeleteFile (TheFs, KFilename12); sl@0: BaflUtils::DeleteFile (TheFs, KFilename13); sl@0: BaflUtils::DeleteFile (TheFs, KFilename14); sl@0: BaflUtils::DeleteFile (TheFs, KFilename15); sl@0: BaflUtils::DeleteFile (TheFs, KFilename16); sl@0: BaflUtils::DeleteFile (TheFs, KFilename17); sl@0: BaflUtils::DeleteFile (TheFs, KFilename18); sl@0: BaflUtils::DeleteFile (TheFs, KFilename19); sl@0: BaflUtils::DeleteFile (TheFs, KFilename20); sl@0: BaflUtils::DeleteFile (TheFs, KFilename21); sl@0: BaflUtils::DeleteFile (TheFs, KFilename22); sl@0: BaflUtils::DeleteFile (TheFs, KFilename23); sl@0: #ifdef __EPOC32__ sl@0: BaflUtils::DeleteFile (TheFs, KFilename24); sl@0: #else sl@0: // Windows strips off trailing periods sl@0: BaflUtils::DeleteFile (TheFs, _L("C:\\System\\Data\\klmn")); sl@0: #endif sl@0: BaflUtils::DeleteFile (TheFs, KFilename25); sl@0: BaflUtils::DeleteFile (TheFs, KFilename26); sl@0: BaflUtils::DeleteFile (TheFs, KFilename27); sl@0: BaflUtils::DeleteFile (TheFs, KFilename28); sl@0: BaflUtils::DeleteFile (TheFs, KNearestLang); sl@0: sl@0: // Restore the original locale settings. sl@0: originalLocale.SaveSystemSettings(); sl@0: sl@0: CleanupStack::PopAndDestroy (&::TheFs); sl@0: sl@0: // The Test Ends... sl@0: // sl@0: sl@0: // check that no handles have leaked sl@0: TInt endProcessHandleCount; sl@0: TInt endThreadHandleCount; sl@0: RThread ().HandleCount (endProcessHandleCount, endThreadHandleCount); sl@0: sl@0: TheTest (startThreadHandleCount == endThreadHandleCount); sl@0: sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: //=============================================================================== sl@0: sl@0: /** sl@0: Initialise the cleanup stack and active scheduler sl@0: */ sl@0: LOCAL_C void SetupL () sl@0: { sl@0: TheTrapCleanup = CTrapCleanup::New (); sl@0: User::LeaveIfNull (TheTrapCleanup); sl@0: sl@0: // Construct and install the active scheduler sl@0: TheActiveScheduler = new (ELeave) CActiveScheduler; sl@0: CActiveScheduler::Install (TheActiveScheduler); sl@0: } sl@0: sl@0: /** sl@0: Cleanup sl@0: */ sl@0: LOCAL_C void CleanupL () sl@0: { sl@0: delete TheActiveScheduler; sl@0: delete TheTrapCleanup; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Invoke the tests sl@0: */ sl@0: LOCAL_C void DoTestsL () sl@0: { sl@0: Defect_INC045169L (); sl@0: Defect_DEF068052L (); sl@0: sl@0: Defect_INC120743L (); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main () sl@0: { sl@0: __UHEAP_MARK; sl@0: sl@0: TheTest.Printf (_L ("\n")); sl@0: TheTest.Title (); sl@0: TheTest.Start (_L("Defect Tests ")); sl@0: sl@0: TRAPD (err, SetupL ()); sl@0: TheTest (err == KErrNone); sl@0: sl@0: TRAP (err, DoTestsL ()); sl@0: TheTest (err == KErrNone); sl@0: sl@0: CleanupL (); sl@0: sl@0: TheTest.End (); sl@0: TheTest.Close (); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return (KErrNone); sl@0: }