Update contrib.
1 #ifndef __T_LANGUTILSIMP_H__
2 #define __T_LANGUTILSIMP_H__
5 #include <test/testexecutestepbase.h>
7 #include "LangUtilImpl.h"
8 #include "T_LangUtilsTestShareFunc.h"
16 class RTestDirectoryScanner : public RDirectoryScanner
19 RTestDirectoryScanner(CDesCArray*& aMember)
20 : iOpenError(0), iFilesThatExist(aMember)
22 for (TInt i = 0; i != 26; ++i)
25 virtual TInt Open(RFs&, const TDesC& aMatchPattern)
27 iMatch = aMatchPattern;
31 virtual TInt Next(TEntry& aOut)
35 while (iIndex < iFilesThatExist->Count())
38 if (0 <= (*iFilesThatExist)[i].MatchF(iMatch))
40 TPtrC fullName=(*iFilesThatExist)[i];
41 TParsePtrC name(fullName);
42 aOut.iName=name.NameAndExt();
43 if (1 < fullName.Length() && fullName[1] == ':')
45 TInt drive = fullName[0];
46 if ('a' <= drive && drive <= 'z')
50 ASSERT('A' <= drive && drive <= 'Z');
53 return iDriveError[drive];
60 virtual void Close() {}
64 CDesCArray *&iFilesThatExist;
70 class TTestNearestLanguageFileFinder : public TNearestLanguageFileFinder
73 TTestNearestLanguageFileFinder(const RFs& aFs)
74 : TNearestLanguageFileFinder(aFs), iTestScanner(iFilesThatExist)
77 iFilesSearchedFor = 0;
79 ~TTestNearestLanguageFileFinder()
81 delete iFilesThatExist;
82 delete iFilesSearchedFor;
84 virtual TInt GetCustomResourceDriveNumber() const { return iCustomRscDrive; }
85 virtual TBool FileExists(const TDesC& aFileName) const
87 ASSERT(aFileName[1] == ':');
88 ASSERT(0 == aFileName.Left(1).CompareF(iDrivesChecked.Left(1)));
89 iDrivesChecked.Delete(0, 1);
90 ASSERT(0 <= aFileName.MatchF(iFileCheckedFor));
91 if (iFilesSearchedFor)
93 ASSERT(0 == aFileName.CompareF((*iFilesSearchedFor)[0]));
94 iFilesSearchedFor->Delete(0);
99 iFilesThatExist->Find(aFileName, i);
100 return (0 <= i && i < iFilesThatExist->Count())? ETrue : EFalse;
102 virtual RDirectoryScanner& DirectoryScanner() { return iTestScanner; }
104 TInt iCustomRscDrive;
105 CDesCArray* iFilesThatExist;
106 // File that is expected to go into FileExists.
107 // Can contain wildcards.
108 TFileName iFileCheckedFor;
109 // Drives expected in calls to FileExists. The first one is checked then
110 // discarded each time FileExists is called.
111 mutable TBuf<26> iDrivesChecked;
112 CDesCArray* iFilesSearchedFor;
113 RTestDirectoryScanner iTestScanner;
117 class CT_LANGUTILSIMP : public CTestStep
122 TVerdict doTestStepL();
124 void TestLANGUTILSIMP();
125 void TestPath(const TLanguagePath& aPath, const TLanguage* aExpected, TInt aExpectedCount);
126 void TestAddLanguage();
127 void TestDowngrade(SDowngradeTest& aTest);
128 void TestMakeLanguageDowngradePath();
129 void SetUpFinderForLanguageAndDriveSearchL(TTestNearestLanguageFileFinder& aFinder);
130 void TestNearestLanguageFinder();
134 _LIT(KTestStep_T_LANGUTILSIMP, "T_LANGUTILSIMP");