sl@0: #ifndef __T_LANGUTILSIMP_H__ sl@0: #define __T_LANGUTILSIMP_H__ sl@0: sl@0: //#include sl@0: #include sl@0: #include sl@0: #include "LangUtilImpl.h" sl@0: #include "T_LangUtilsTestShareFunc.h" sl@0: sl@0: struct SDowngradeTest sl@0: { sl@0: TLanguage iIn[4]; sl@0: TLanguage iOut[9]; sl@0: }; sl@0: sl@0: class RTestDirectoryScanner : public RDirectoryScanner sl@0: { sl@0: public: sl@0: RTestDirectoryScanner(CDesCArray*& aMember) sl@0: : iOpenError(0), iFilesThatExist(aMember) sl@0: { sl@0: for (TInt i = 0; i != 26; ++i) sl@0: iDriveError[i] = 0; sl@0: } sl@0: virtual TInt Open(RFs&, const TDesC& aMatchPattern) sl@0: { sl@0: iMatch = aMatchPattern; sl@0: iIndex = 0; sl@0: return iOpenError; sl@0: } sl@0: virtual TInt Next(TEntry& aOut) sl@0: { sl@0: if (!iFilesThatExist) sl@0: return KErrEof; sl@0: while (iIndex < iFilesThatExist->Count()) sl@0: { sl@0: TInt i = iIndex++; sl@0: if (0 <= (*iFilesThatExist)[i].MatchF(iMatch)) sl@0: { sl@0: TPtrC fullName=(*iFilesThatExist)[i]; sl@0: TParsePtrC name(fullName); sl@0: aOut.iName=name.NameAndExt(); sl@0: if (1 < fullName.Length() && fullName[1] == ':') sl@0: { sl@0: TInt drive = fullName[0]; sl@0: if ('a' <= drive && drive <= 'z') sl@0: drive -= 'a'; sl@0: else sl@0: { sl@0: ASSERT('A' <= drive && drive <= 'Z'); sl@0: drive -= 'A'; sl@0: } sl@0: return iDriveError[drive]; sl@0: } sl@0: return KErrNone; sl@0: } sl@0: } sl@0: return KErrEof; sl@0: } sl@0: virtual void Close() {} sl@0: TInt iOpenError; sl@0: TInt iDriveError[26]; sl@0: private: sl@0: CDesCArray *&iFilesThatExist; sl@0: TInt iIndex; sl@0: TFileName iMatch; sl@0: }; sl@0: sl@0: sl@0: class TTestNearestLanguageFileFinder : public TNearestLanguageFileFinder sl@0: { sl@0: public: sl@0: TTestNearestLanguageFileFinder(const RFs& aFs) sl@0: : TNearestLanguageFileFinder(aFs), iTestScanner(iFilesThatExist) sl@0: { sl@0: iFilesThatExist = 0; sl@0: iFilesSearchedFor = 0; sl@0: } sl@0: ~TTestNearestLanguageFileFinder() sl@0: { sl@0: delete iFilesThatExist; sl@0: delete iFilesSearchedFor; sl@0: } sl@0: virtual TInt GetCustomResourceDriveNumber() const { return iCustomRscDrive; } sl@0: virtual TBool FileExists(const TDesC& aFileName) const sl@0: { sl@0: ASSERT(aFileName[1] == ':'); sl@0: ASSERT(0 == aFileName.Left(1).CompareF(iDrivesChecked.Left(1))); sl@0: iDrivesChecked.Delete(0, 1); sl@0: ASSERT(0 <= aFileName.MatchF(iFileCheckedFor)); sl@0: if (iFilesSearchedFor) sl@0: { sl@0: ASSERT(0 == aFileName.CompareF((*iFilesSearchedFor)[0])); sl@0: iFilesSearchedFor->Delete(0); sl@0: } sl@0: if (!iFilesThatExist) sl@0: return EFalse; sl@0: TInt i; sl@0: iFilesThatExist->Find(aFileName, i); sl@0: return (0 <= i && i < iFilesThatExist->Count())? ETrue : EFalse; sl@0: } sl@0: virtual RDirectoryScanner& DirectoryScanner() { return iTestScanner; } sl@0: sl@0: TInt iCustomRscDrive; sl@0: CDesCArray* iFilesThatExist; sl@0: // File that is expected to go into FileExists. sl@0: // Can contain wildcards. sl@0: TFileName iFileCheckedFor; sl@0: // Drives expected in calls to FileExists. The first one is checked then sl@0: // discarded each time FileExists is called. sl@0: mutable TBuf<26> iDrivesChecked; sl@0: CDesCArray* iFilesSearchedFor; sl@0: RTestDirectoryScanner iTestScanner; sl@0: }; sl@0: sl@0: sl@0: class CT_LANGUTILSIMP : public CTestStep sl@0: { sl@0: public: sl@0: CT_LANGUTILSIMP(); sl@0: protected: sl@0: TVerdict doTestStepL(); sl@0: private: sl@0: void TestLANGUTILSIMP(); sl@0: void TestPath(const TLanguagePath& aPath, const TLanguage* aExpected, TInt aExpectedCount); sl@0: void TestAddLanguage(); sl@0: void TestDowngrade(SDowngradeTest& aTest); sl@0: void TestMakeLanguageDowngradePath(); sl@0: void SetUpFinderForLanguageAndDriveSearchL(TTestNearestLanguageFileFinder& aFinder); sl@0: void TestNearestLanguageFinder(); sl@0: sl@0: }; sl@0: sl@0: _LIT(KTestStep_T_LANGUTILSIMP, "T_LANGUTILSIMP"); sl@0: sl@0: #endif