sl@0
|
1 |
#ifndef __T_LANGUTILSIMP_H__
|
sl@0
|
2 |
#define __T_LANGUTILSIMP_H__
|
sl@0
|
3 |
|
sl@0
|
4 |
//#include <w32std.h>
|
sl@0
|
5 |
#include <test/testexecutestepbase.h>
|
sl@0
|
6 |
#include <langutil.h>
|
sl@0
|
7 |
#include "LangUtilImpl.h"
|
sl@0
|
8 |
#include "T_LangUtilsTestShareFunc.h"
|
sl@0
|
9 |
|
sl@0
|
10 |
struct SDowngradeTest
|
sl@0
|
11 |
{
|
sl@0
|
12 |
TLanguage iIn[4];
|
sl@0
|
13 |
TLanguage iOut[9];
|
sl@0
|
14 |
};
|
sl@0
|
15 |
|
sl@0
|
16 |
class RTestDirectoryScanner : public RDirectoryScanner
|
sl@0
|
17 |
{
|
sl@0
|
18 |
public:
|
sl@0
|
19 |
RTestDirectoryScanner(CDesCArray*& aMember)
|
sl@0
|
20 |
: iOpenError(0), iFilesThatExist(aMember)
|
sl@0
|
21 |
{
|
sl@0
|
22 |
for (TInt i = 0; i != 26; ++i)
|
sl@0
|
23 |
iDriveError[i] = 0;
|
sl@0
|
24 |
}
|
sl@0
|
25 |
virtual TInt Open(RFs&, const TDesC& aMatchPattern)
|
sl@0
|
26 |
{
|
sl@0
|
27 |
iMatch = aMatchPattern;
|
sl@0
|
28 |
iIndex = 0;
|
sl@0
|
29 |
return iOpenError;
|
sl@0
|
30 |
}
|
sl@0
|
31 |
virtual TInt Next(TEntry& aOut)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
if (!iFilesThatExist)
|
sl@0
|
34 |
return KErrEof;
|
sl@0
|
35 |
while (iIndex < iFilesThatExist->Count())
|
sl@0
|
36 |
{
|
sl@0
|
37 |
TInt i = iIndex++;
|
sl@0
|
38 |
if (0 <= (*iFilesThatExist)[i].MatchF(iMatch))
|
sl@0
|
39 |
{
|
sl@0
|
40 |
TPtrC fullName=(*iFilesThatExist)[i];
|
sl@0
|
41 |
TParsePtrC name(fullName);
|
sl@0
|
42 |
aOut.iName=name.NameAndExt();
|
sl@0
|
43 |
if (1 < fullName.Length() && fullName[1] == ':')
|
sl@0
|
44 |
{
|
sl@0
|
45 |
TInt drive = fullName[0];
|
sl@0
|
46 |
if ('a' <= drive && drive <= 'z')
|
sl@0
|
47 |
drive -= 'a';
|
sl@0
|
48 |
else
|
sl@0
|
49 |
{
|
sl@0
|
50 |
ASSERT('A' <= drive && drive <= 'Z');
|
sl@0
|
51 |
drive -= 'A';
|
sl@0
|
52 |
}
|
sl@0
|
53 |
return iDriveError[drive];
|
sl@0
|
54 |
}
|
sl@0
|
55 |
return KErrNone;
|
sl@0
|
56 |
}
|
sl@0
|
57 |
}
|
sl@0
|
58 |
return KErrEof;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
virtual void Close() {}
|
sl@0
|
61 |
TInt iOpenError;
|
sl@0
|
62 |
TInt iDriveError[26];
|
sl@0
|
63 |
private:
|
sl@0
|
64 |
CDesCArray *&iFilesThatExist;
|
sl@0
|
65 |
TInt iIndex;
|
sl@0
|
66 |
TFileName iMatch;
|
sl@0
|
67 |
};
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
class TTestNearestLanguageFileFinder : public TNearestLanguageFileFinder
|
sl@0
|
71 |
{
|
sl@0
|
72 |
public:
|
sl@0
|
73 |
TTestNearestLanguageFileFinder(const RFs& aFs)
|
sl@0
|
74 |
: TNearestLanguageFileFinder(aFs), iTestScanner(iFilesThatExist)
|
sl@0
|
75 |
{
|
sl@0
|
76 |
iFilesThatExist = 0;
|
sl@0
|
77 |
iFilesSearchedFor = 0;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
~TTestNearestLanguageFileFinder()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
delete iFilesThatExist;
|
sl@0
|
82 |
delete iFilesSearchedFor;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
virtual TInt GetCustomResourceDriveNumber() const { return iCustomRscDrive; }
|
sl@0
|
85 |
virtual TBool FileExists(const TDesC& aFileName) const
|
sl@0
|
86 |
{
|
sl@0
|
87 |
ASSERT(aFileName[1] == ':');
|
sl@0
|
88 |
ASSERT(0 == aFileName.Left(1).CompareF(iDrivesChecked.Left(1)));
|
sl@0
|
89 |
iDrivesChecked.Delete(0, 1);
|
sl@0
|
90 |
ASSERT(0 <= aFileName.MatchF(iFileCheckedFor));
|
sl@0
|
91 |
if (iFilesSearchedFor)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
ASSERT(0 == aFileName.CompareF((*iFilesSearchedFor)[0]));
|
sl@0
|
94 |
iFilesSearchedFor->Delete(0);
|
sl@0
|
95 |
}
|
sl@0
|
96 |
if (!iFilesThatExist)
|
sl@0
|
97 |
return EFalse;
|
sl@0
|
98 |
TInt i;
|
sl@0
|
99 |
iFilesThatExist->Find(aFileName, i);
|
sl@0
|
100 |
return (0 <= i && i < iFilesThatExist->Count())? ETrue : EFalse;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
virtual RDirectoryScanner& DirectoryScanner() { return iTestScanner; }
|
sl@0
|
103 |
|
sl@0
|
104 |
TInt iCustomRscDrive;
|
sl@0
|
105 |
CDesCArray* iFilesThatExist;
|
sl@0
|
106 |
// File that is expected to go into FileExists.
|
sl@0
|
107 |
// Can contain wildcards.
|
sl@0
|
108 |
TFileName iFileCheckedFor;
|
sl@0
|
109 |
// Drives expected in calls to FileExists. The first one is checked then
|
sl@0
|
110 |
// discarded each time FileExists is called.
|
sl@0
|
111 |
mutable TBuf<26> iDrivesChecked;
|
sl@0
|
112 |
CDesCArray* iFilesSearchedFor;
|
sl@0
|
113 |
RTestDirectoryScanner iTestScanner;
|
sl@0
|
114 |
};
|
sl@0
|
115 |
|
sl@0
|
116 |
|
sl@0
|
117 |
class CT_LANGUTILSIMP : public CTestStep
|
sl@0
|
118 |
{
|
sl@0
|
119 |
public:
|
sl@0
|
120 |
CT_LANGUTILSIMP();
|
sl@0
|
121 |
protected:
|
sl@0
|
122 |
TVerdict doTestStepL();
|
sl@0
|
123 |
private:
|
sl@0
|
124 |
void TestLANGUTILSIMP();
|
sl@0
|
125 |
void TestPath(const TLanguagePath& aPath, const TLanguage* aExpected, TInt aExpectedCount);
|
sl@0
|
126 |
void TestAddLanguage();
|
sl@0
|
127 |
void TestDowngrade(SDowngradeTest& aTest);
|
sl@0
|
128 |
void TestMakeLanguageDowngradePath();
|
sl@0
|
129 |
void SetUpFinderForLanguageAndDriveSearchL(TTestNearestLanguageFileFinder& aFinder);
|
sl@0
|
130 |
void TestNearestLanguageFinder();
|
sl@0
|
131 |
|
sl@0
|
132 |
};
|
sl@0
|
133 |
|
sl@0
|
134 |
_LIT(KTestStep_T_LANGUTILSIMP, "T_LANGUTILSIMP");
|
sl@0
|
135 |
|
sl@0
|
136 |
#endif
|