os/ossrv/lowlevellibsandfws/apputils/tsrc/T_BaflUtilsImp.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/apputils/tsrc/T_BaflUtilsImp.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1029 @@
     1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Tests some code internal to BaflUtils
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "BaUtilsImp.h"
    1.22 +#include <bautils.h>
    1.23 +#include <e32test.h>
    1.24 +#include <baflpan.h>
    1.25 +
    1.26 +#define UNUSED_VAR(a) a = a
    1.27 +
    1.28 +const TPtrC KValFolderName=_L("ValidFolderName");
    1.29 +const TPtrC KCurrentPath=_L("C:\\System\\Data\\");
    1.30 +const TPtrC KNoFolderName = _L("");
    1.31 +const TPtrC KInValidFolderName=_L("C:\\System\\Data\\InValid3+FollderName");
    1.32 +
    1.33 +namespace
    1.34 +{
    1.35 +CTrapCleanup* TrapCleanup;
    1.36 +RTest test(_L("T_BaflUtilsImp - Internal Bafl function tests"));
    1.37 +}
    1.38 +
    1.39 +class RTestDirectoryScanner : public RDirectoryScanner
    1.40 +	{
    1.41 +public:
    1.42 +	RTestDirectoryScanner(CDesCArray*& aMember)
    1.43 +		: iOpenError(0), iFilesThatExist(aMember)
    1.44 +		{
    1.45 +		for (TInt i = 0; i != 26; ++i)
    1.46 +			iDriveError[i] = 0;
    1.47 +		}
    1.48 +	virtual TInt Open(RFs&, const TDesC& aMatchPattern)
    1.49 +		{
    1.50 +		iMatch = aMatchPattern;
    1.51 +		iIndex = 0;
    1.52 +		return iOpenError;
    1.53 +		}
    1.54 +	virtual TInt Next(TEntry& aOut)
    1.55 +		{
    1.56 +		if (!iFilesThatExist)
    1.57 +			return KErrEof;
    1.58 +		while (iIndex < iFilesThatExist->Count())
    1.59 +			{
    1.60 +			TInt i = iIndex++;
    1.61 +			if (0 <= (*iFilesThatExist)[i].MatchF(iMatch))
    1.62 +				{
    1.63 +				TPtrC fullName=(*iFilesThatExist)[i];
    1.64 +				TParsePtrC name(fullName);
    1.65 +				aOut.iName=name.NameAndExt();
    1.66 +				if (1 < fullName.Length() && fullName[1] == ':')
    1.67 +					{
    1.68 +					TInt drive = fullName[0];
    1.69 +					if ('a' <= drive && drive <= 'z')
    1.70 +						drive -= 'a';
    1.71 +					else
    1.72 +						{
    1.73 +						ASSERT('A' <= drive && drive <= 'Z');
    1.74 +						drive -= 'A';
    1.75 +						}
    1.76 +					return iDriveError[drive];
    1.77 +					}
    1.78 +				return KErrNone;
    1.79 +				}
    1.80 +			}
    1.81 +		return KErrEof;
    1.82 +		}
    1.83 +	virtual void Close() {}
    1.84 +	TInt iOpenError;
    1.85 +	TInt iDriveError[26];
    1.86 +private:
    1.87 +	CDesCArray *&iFilesThatExist;
    1.88 +	TInt iIndex;
    1.89 +	TFileName iMatch;
    1.90 +	};
    1.91 +
    1.92 +class TTestNearestLanguageFileFinder : public TNearestLanguageFileFinder
    1.93 +	{
    1.94 +public:
    1.95 +	TTestNearestLanguageFileFinder(const RFs& aFs)
    1.96 +		: TNearestLanguageFileFinder(aFs), iTestScanner(iFilesThatExist)
    1.97 +		{
    1.98 +		iFilesThatExist = 0;
    1.99 +		iFilesSearchedFor = 0;
   1.100 +		}
   1.101 +	~TTestNearestLanguageFileFinder()
   1.102 +		{
   1.103 +		delete iFilesThatExist;
   1.104 +		delete iFilesSearchedFor;
   1.105 +		}
   1.106 +	virtual TInt GetCustomResourceDriveNumber() const { return iCustomRscDrive; }
   1.107 +	virtual TBool FileExists(const TDesC& aFileName) const
   1.108 +		{
   1.109 +		test(aFileName[1] == ':');
   1.110 +		test(0 == aFileName.Left(1).CompareF(iDrivesChecked.Left(1)));
   1.111 +		iDrivesChecked.Delete(0, 1);
   1.112 +		test(0 <= aFileName.MatchF(iFileCheckedFor));
   1.113 +		if (iFilesSearchedFor)
   1.114 +			{
   1.115 +			test(0 == aFileName.CompareF((*iFilesSearchedFor)[0]));
   1.116 +			iFilesSearchedFor->Delete(0);
   1.117 +			}
   1.118 +		if (!iFilesThatExist)
   1.119 +			return EFalse;
   1.120 +		TInt i;
   1.121 +		iFilesThatExist->Find(aFileName, i);
   1.122 +		return (0 <= i && i < iFilesThatExist->Count())? ETrue : EFalse;
   1.123 +		}
   1.124 +	virtual RDirectoryScanner& DirectoryScanner() { return iTestScanner; }
   1.125 +
   1.126 +	TInt iCustomRscDrive;
   1.127 +	CDesCArray* iFilesThatExist;
   1.128 +	// File that is expected to go into FileExists.
   1.129 +	// Can contain wildcards.
   1.130 +	TFileName iFileCheckedFor;
   1.131 +	// Drives expected in calls to FileExists. The first one is checked then
   1.132 +	// discarded each time FileExists is called.
   1.133 +	mutable TBuf<26> iDrivesChecked;
   1.134 +	CDesCArray* iFilesSearchedFor;
   1.135 +	RTestDirectoryScanner iTestScanner;
   1.136 +	};
   1.137 +
   1.138 +void TestPath(const TLanguagePath& aPath, const TLanguage* aExpected, TInt aExpectedCount)
   1.139 +	{
   1.140 +	for (int i = 0; i != aExpectedCount; ++i)
   1.141 +		test(aPath[i] == *aExpected++);
   1.142 +	test(aPath[aExpectedCount] == ELangNone);
   1.143 +	}
   1.144 +
   1.145 +const TLanguage ExpectedPath[] = { ELangFrench, ELangJapanese, ELangGerman, ELangGreek,
   1.146 +	ELangArabic, ELangEnglish, ELangItalian, ELangHebrew };
   1.147 +
   1.148 +/**
   1.149 +@SYMTestCaseID          SYSLIB-BAFL-CT-0443
   1.150 +@SYMTestCaseDesc        Tests TLanguagePath class
   1.151 +@SYMTestPriority        High
   1.152 +@SYMTestActions         Test for adding different language paths
   1.153 +@SYMTestExpectedResults Test must not fail
   1.154 +@SYMREQ                 REQ0000
   1.155 +*/
   1.156 +void TestAddLanguage()
   1.157 +	{
   1.158 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0443 "));
   1.159 +	TLanguagePath path;
   1.160 +	path[0] = ELangNone;
   1.161 +	AddLanguage(path, ELangNone);
   1.162 +	TestPath(path, ExpectedPath, 0);
   1.163 +	AddLanguage(path, ELangFrench);
   1.164 +	TestPath(path, ExpectedPath, 1);
   1.165 +	AddLanguage(path, ELangFrench);
   1.166 +	TestPath(path, ExpectedPath, 1);
   1.167 +	AddLanguage(path, ELangNone);
   1.168 +	TestPath(path, ExpectedPath, 1);
   1.169 +	AddLanguage(path, ELangFrench);
   1.170 +	TestPath(path, ExpectedPath, 1);
   1.171 +	AddLanguage(path, ELangJapanese);
   1.172 +	TestPath(path, ExpectedPath, 2);
   1.173 +	AddLanguage(path, ELangFrench);
   1.174 +	TestPath(path, ExpectedPath, 2);
   1.175 +	AddLanguage(path, ELangNone);
   1.176 +	TestPath(path, ExpectedPath, 2);
   1.177 +	AddLanguage(path, ELangGerman);
   1.178 +	TestPath(path, ExpectedPath, 3);
   1.179 +	AddLanguage(path, ELangGreek);
   1.180 +	TestPath(path, ExpectedPath, 4);
   1.181 +	AddLanguage(path, ELangArabic);
   1.182 +	TestPath(path, ExpectedPath, 5);
   1.183 +	AddLanguage(path, ELangNone);
   1.184 +	TestPath(path, ExpectedPath, 5);
   1.185 +	AddLanguage(path, ELangEnglish);
   1.186 +	TestPath(path, ExpectedPath, 6);
   1.187 +	AddLanguage(path, ELangItalian);
   1.188 +	TestPath(path, ExpectedPath, 7);
   1.189 +	AddLanguage(path, ELangNone);
   1.190 +	TestPath(path, ExpectedPath, 7);
   1.191 +	AddLanguage(path, ELangHebrew);
   1.192 +	TestPath(path, ExpectedPath, 8);
   1.193 +	AddLanguage(path, ELangHebrew);
   1.194 +	TestPath(path, ExpectedPath, 8);
   1.195 +	AddLanguage(path, ELangEnglish);
   1.196 +	TestPath(path, ExpectedPath, 8);
   1.197 +	AddLanguage(path, ELangItalian);
   1.198 +	TestPath(path, ExpectedPath, 8);
   1.199 +	AddLanguage(path, ELangNone);
   1.200 +	TestPath(path, ExpectedPath, 8);
   1.201 +	AddLanguage(path, ELangFrench);
   1.202 +	TestPath(path, ExpectedPath, 8);
   1.203 +	AddLanguage(path, ELangNone);
   1.204 +	TestPath(path, ExpectedPath, 8);
   1.205 +	AddLanguage(path, ELangGerman);
   1.206 +	TestPath(path, ExpectedPath, 8);
   1.207 +	}
   1.208 +
   1.209 +struct SDowngradeTest
   1.210 +	{
   1.211 +	TLanguage iIn[4];
   1.212 +	TLanguage iOut[9];
   1.213 +	};
   1.214 +
   1.215 +/**
   1.216 +@SYMTestCaseID          SYSLIB-BAFL-CT-0444
   1.217 +@SYMTestCaseDesc        Tests for the functionality of TLocale class
   1.218 +@SYMTestPriority        High
   1.219 +@SYMTestActions         Test for language downgrades
   1.220 +@SYMTestExpectedResults Test must not fail
   1.221 +@SYMREQ                 REQ0000
   1.222 +*/
   1.223 +void TestDowngrade(SDowngradeTest& aTest)
   1.224 +	{
   1.225 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0444 "));
   1.226 +	TLocale loc;
   1.227 +	loc.SetLanguageDowngrade(0, aTest.iIn[1]);
   1.228 +	loc.SetLanguageDowngrade(1, aTest.iIn[2]);
   1.229 +	loc.SetLanguageDowngrade(2, aTest.iIn[3]);
   1.230 +	TLanguagePath path;
   1.231 +	MakeLanguageDowngradePath(path, aTest.iIn[0], ELangNone, loc);
   1.232 +	for (int i = 0; ; ++i)
   1.233 +		{
   1.234 +		test(i < 9);
   1.235 +		test(aTest.iOut[i] == path[i]);
   1.236 +		if (path[i] == ELangNone)
   1.237 +			return;
   1.238 +		}
   1.239 +	}
   1.240 +
   1.241 +
   1.242 +// Test Dialect enumeration.
   1.243 +// Each value represents a dialect (variant) of a TLanguage language.
   1.244 +// E.g. AmericanSprint is represented by ELangAmerican | EDialectSprint
   1.245 +
   1.246 +// The dialect location -- top six bits
   1.247 +const TUint KDialectFactor=0x0400;
   1.248 +enum TDialect
   1.249 +	{
   1.250 +	// The following are example dialects for testing only
   1.251 +	EDialectSprint = (1*KDialectFactor),
   1.252 +	EDialectOrange = (2*KDialectFactor),
   1.253 +	EDialectMaximum = EDialectOrange // This must always be equal to the last TDialect enum.
   1.254 +	// Up to 63 dialects.
   1.255 +	};
   1.256 +
   1.257 +const TLanguage ELangEnglishOrange = static_cast<TLanguage>(ELangEnglish|EDialectOrange);
   1.258 +const TLanguage ELangAmericanSprint = static_cast<TLanguage>(ELangAmerican|EDialectSprint);
   1.259 +
   1.260 +SDowngradeTest DowngradeData[] =
   1.261 +	{
   1.262 +		// 0 = test language
   1.263 +		// 1-3 = language downgrade for locale
   1.264 +		// 4- = calculated language downgrade path, terminated with ELangNone.
   1.265 +		{{ELangEnglishOrange, ELangNone, ELangNone, ELangNone},
   1.266 +			{ELangEnglishOrange, ELangEnglish, ELangNone}},
   1.267 +		{{ELangAmericanSprint, ELangNone, ELangNone, ELangNone},
   1.268 +			{ELangAmericanSprint, ELangAmerican, ELangEnglish, ELangNone}},
   1.269 +		{{ELangFrench, ELangNone, ELangNone, ELangNone},
   1.270 +			{ELangFrench, ELangNone}},
   1.271 +		{{ELangSwissFrench, ELangNone, ELangNone, ELangNone},
   1.272 +			{ELangSwissFrench, ELangFrench, ELangNone}},
   1.273 +		{{ELangCanadianEnglish, ELangNone, ELangNone, ELangNone},
   1.274 +			{ELangCanadianEnglish, ELangAmerican, ELangEnglish, ELangNone}},
   1.275 +		{{ELangSwissFrench, ELangNone, ELangFrench, ELangNone},
   1.276 +			{ELangSwissFrench, ELangFrench, ELangNone}},
   1.277 +		{{ELangCanadianEnglish, ELangEnglish, ELangNone, ELangAmerican},
   1.278 +			{ELangCanadianEnglish, ELangEnglish, ELangAmerican, ELangNone}},
   1.279 +		{{ELangCanadianEnglish, ELangNone, ELangNone, ELangSwissFrench},
   1.280 +			{ELangCanadianEnglish, ELangSwissFrench, ELangAmerican, ELangEnglish, ELangNone}},
   1.281 +		{{ELangCanadianEnglish, ELangFrench, ELangAmerican, ELangSwissFrench},
   1.282 +			{ELangCanadianEnglish, ELangFrench, ELangAmerican, ELangSwissFrench, ELangEnglish, ELangNone}},
   1.283 +		{{ELangCanadianEnglish, ELangNone, ELangGerman, ELangSwissFrench},
   1.284 +			{ELangCanadianEnglish, ELangGerman, ELangSwissFrench, ELangAmerican, ELangEnglish, ELangNone}},
   1.285 +		{{ELangCanadianEnglish, ELangFinlandSwedish, ELangGerman, ELangSwissFrench},
   1.286 +			{ELangCanadianEnglish, ELangFinlandSwedish, ELangGerman, ELangSwissFrench, ELangAmerican, ELangEnglish, ELangNone}},
   1.287 +		{{ELangFinlandSwedish, ELangFinlandSwedish, ELangFinlandSwedish, ELangFinlandSwedish},
   1.288 +			{ELangFinlandSwedish, ELangSwedish, ELangNone}},
   1.289 +	};
   1.290 +
   1.291 +/**
   1.292 +@SYMTestCaseID          SYSLIB-BAFL-CT-0445
   1.293 +@SYMTestCaseDesc        Tests for language downgrades
   1.294 +@SYMTestPriority        High
   1.295 +@SYMTestActions         Call up downgrade path test function
   1.296 +@SYMTestExpectedResults Test must not fail
   1.297 +@SYMREQ                 REQ0000
   1.298 +*/
   1.299 +void TestMakeLanguageDowngradePath()
   1.300 +	{
   1.301 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0445 "));
   1.302 +	for (int i = 0; i != sizeof(DowngradeData)/sizeof(DowngradeData[0]); ++i)
   1.303 +		TestDowngrade(DowngradeData[i]);
   1.304 +	}
   1.305 +
   1.306 +void SetUpFinderForLanguageAndDriveSearchL(
   1.307 +	TTestNearestLanguageFileFinder& aFinder)
   1.308 +	{
   1.309 +	aFinder.iDrives = _L("ZAG");
   1.310 +	aFinder.iFilesSearchedFor = new(ELeave) CDesCArraySeg(10);
   1.311 +	aFinder.iFilesSearchedFor->AppendL(_L("z:\\dir\\name.e02"));
   1.312 +	aFinder.iFilesSearchedFor->AppendL(_L("a:\\dir\\name.e02"));
   1.313 +	aFinder.iFilesSearchedFor->AppendL(_L("g:\\dir\\name.e02"));
   1.314 +	aFinder.iFilesSearchedFor->AppendL(_L("z:\\dir\\name.e15702")); //Extended lang
   1.315 +	aFinder.iFilesSearchedFor->AppendL(_L("a:\\dir\\name.e15702"));
   1.316 +	aFinder.iFilesSearchedFor->AppendL(_L("g:\\dir\\name.e15702"));
   1.317 +	aFinder.iFilesSearchedFor->AppendL(_L("z:\\dir\\name.e01"));
   1.318 +	aFinder.iFilesSearchedFor->AppendL(_L("a:\\dir\\name.e01"));
   1.319 +	aFinder.iFilesSearchedFor->AppendL(_L("g:\\dir\\name.e01"));
   1.320 +	aFinder.iFilesSearchedFor->AppendL(_L("z:\\dir\\name.ext"));
   1.321 +	aFinder.iFilesSearchedFor->AppendL(_L("a:\\dir\\name.ext"));
   1.322 +	aFinder.iFilesSearchedFor->AppendL(_L("g:\\dir\\name.ext"));
   1.323 +	aFinder.iDrivesChecked = _L("zagzagzagzagzag");
   1.324 +	}
   1.325 +
   1.326 +_LIT(KTestFileName1, "z:\\dir\\name.ext");
   1.327 +//_LIT(KTestFileName2, "z:\\dir\\náme.ext");
   1.328 +_LIT(KTestFileName2, "z:\\dir\\n\u00c1me.ext");
   1.329 +_LIT(KTestFileName3, "a:\\dir\\name.ext");
   1.330 +_LIT(KTestFileName4, "c:\\dir\\name.ext");
   1.331 +_LIT(KTestFileName5, "d:\\dir\\name.ext");
   1.332 +_LIT(KTestFileName6, "y:\\dir\\name.ext");
   1.333 +_LIT(KTestFileName7, "A:\\dir\\name.ext");
   1.334 +_LIT(KTestFileName8, "C:\\dir\\name.ext");
   1.335 +_LIT(KTestFileName9, "Y:\\dir\\name.ext");
   1.336 +_LIT(KTestFileName11, "\\abc\\defg.hijkl");
   1.337 +_LIT(KTestFileName256Chars, "\
   1.338 +\\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\
   1.339 +\\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\
   1.340 +\\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\
   1.341 +\\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz0.ext");
   1.342 +
   1.343 +_LIT(KExpectedFileName256Chars, "?:\
   1.344 +\\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\
   1.345 +\\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\
   1.346 +\\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\
   1.347 +\\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz0.e");
   1.348 +_LIT(KExpectedFileName1, "?:\\dir\\name.e");
   1.349 +_LIT(KExpectedSuffix1, "xt");
   1.350 +_LIT(KExpectedFileName2, "?:\\abc\\defg.hij");
   1.351 +_LIT(KExpectedSuffix2, "kl");
   1.352 +_LIT(KTestFileName1French, "z:\\dir\\name.e02");
   1.353 +_LIT(KTestFileName1Japanese, "z:\\dir\\name.e32");
   1.354 +_LIT(KTestFileName1Mongolian, "z:\\dir\\name.e54321");
   1.355 +_LIT(KTestFileName1AmericanSprint, "z:\\dir\\name.e1034"); //American=0x0A, Sprint=0x0400. 0x040A=1034.
   1.356 +_LIT(KCheckedForFrench, "?:\\dir\\name.e02");
   1.357 +
   1.358 +/**
   1.359 +@SYMTestCaseID          SYSLIB-BAFL-CT-0446
   1.360 +@SYMTestCaseDesc        Nearest language finder test
   1.361 +@SYMTestPriority        High
   1.362 +@SYMTestActions         Test drive sequence construction
   1.363 +						Test addition of language number
   1.364 +						Test searching each drive for the specified file
   1.365 +						Test searching language and drive down the language path
   1.366 +						Test filename matching
   1.367 +						Test searching for any language file within a drive
   1.368 +						Test searching all drives for any language
   1.369 +@SYMTestExpectedResults Test must not fail
   1.370 +@SYMREQ                 REQ0000
   1.371 +*/
   1.372 +void TestNearestLanguageFinder()
   1.373 +	{
   1.374 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0446 "));
   1.375 +	RFs dummy;
   1.376 +	TTestNearestLanguageFileFinder finder(dummy);
   1.377 +
   1.378 +	// Test file name setting and disecting
   1.379 +	// SetFileName
   1.380 +	// RepairFileName
   1.381 +	TFileName fileName(KTestFileName1);
   1.382 +	finder.SetFileName(fileName);
   1.383 +	test(0 <= finder.iFileName->MatchF(KExpectedFileName1));
   1.384 +	test(0 == finder.iSuffix.Compare(KExpectedSuffix1));
   1.385 +	test('z' == finder.iInitialDriveLetter);
   1.386 +	finder.RepairFileName();
   1.387 +	test(0 == finder.iFileName->Compare(KTestFileName1));
   1.388 +	fileName = KTestFileName11;
   1.389 +	finder.SetFileName(fileName);
   1.390 +	test(0 <= finder.iFileName->MatchF(KExpectedFileName2));
   1.391 +	test(0 == finder.iSuffix.Compare(KExpectedSuffix2));
   1.392 +	test(-1 == finder.iInitialDriveLetter);
   1.393 +	finder.RepairFileName();
   1.394 +	test(0 == finder.iFileName->Compare(KTestFileName11));
   1.395 +	fileName = KTestFileName256Chars;
   1.396 +	finder.SetFileName(fileName);
   1.397 +	test(0 <= finder.iFileName->MatchF(KExpectedFileName256Chars));
   1.398 +	test(0 == finder.iSuffix.Compare(KExpectedSuffix1));
   1.399 +	test(-1 == finder.iInitialDriveLetter);
   1.400 +	finder.RepairFileName();
   1.401 +	test(0 == finder.iFileName->Compare(KTestFileName256Chars));
   1.402 +
   1.403 +	// Test drive sequence construction
   1.404 +	// AddCustomResourceDrive
   1.405 +	finder.iCustomRscDrive = static_cast<TInt>(EDriveC);	// drive c:
   1.406 +	fileName = KTestFileName1;
   1.407 +	finder.SetFileName(fileName);
   1.408 +	test(finder.AddCustomResourceDrive() == KErrNone);
   1.409 +	test(0 == finder.iDrives.CompareF(_L("CZ")));
   1.410 +	fileName = KTestFileName3;
   1.411 +	finder.SetFileName(fileName);
   1.412 +	test(finder.AddCustomResourceDrive() == KErrNone);
   1.413 +	test(0 == finder.iDrives.CompareF(_L("CA")));
   1.414 +	fileName = KTestFileName4;
   1.415 +	finder.SetFileName(fileName);
   1.416 +	test(finder.AddCustomResourceDrive() == KErrAlreadyExists);
   1.417 +	test(0 == finder.iDrives.CompareF(_L("C")));
   1.418 +	fileName = KTestFileName5;
   1.419 +	finder.SetFileName(fileName);
   1.420 +	test(finder.AddCustomResourceDrive() == KErrNone);
   1.421 +	test(0 == finder.iDrives.CompareF(_L("CD")));
   1.422 +	fileName = KTestFileName6;
   1.423 +	finder.SetFileName(fileName);
   1.424 +	test(finder.AddCustomResourceDrive() == KErrNone);
   1.425 +	test(0 == finder.iDrives.CompareF(_L("CY")));
   1.426 +	fileName = KTestFileName7;
   1.427 +	finder.SetFileName(fileName);
   1.428 +	test(finder.AddCustomResourceDrive() == KErrNone);
   1.429 +	test(0 == finder.iDrives.CompareF(_L("CA")));
   1.430 +	fileName = KTestFileName8;
   1.431 +	finder.SetFileName(fileName);
   1.432 +	test(finder.AddCustomResourceDrive() == KErrAlreadyExists);
   1.433 +	test(0 == finder.iDrives.CompareF(_L("C")));
   1.434 +	fileName = KTestFileName9;
   1.435 +	finder.SetFileName(fileName);
   1.436 +	test(finder.AddCustomResourceDrive() == KErrNone);
   1.437 +	test(0 == finder.iDrives.CompareF(_L("CY")));
   1.438 +	// AddAllDrives
   1.439 +	fileName = KTestFileName1;
   1.440 +	finder.SetFileName(fileName);
   1.441 +	finder.AddAllDrives();
   1.442 +	test(0 == finder.iDrives.CompareF(_L("ZYXWVUTSRQPONMLKJIHGFEDCBA")));
   1.443 +	fileName = KTestFileName3;
   1.444 +	finder.SetFileName(fileName);
   1.445 +	finder.AddAllDrives();
   1.446 +	test(0 == finder.iDrives.CompareF(_L("AYXWVUTSRQPONMLKJIHGFEDCBZ")));
   1.447 +	fileName = KTestFileName4;
   1.448 +	finder.SetFileName(fileName);
   1.449 +	finder.AddAllDrives();
   1.450 +	test(0 == finder.iDrives.CompareF(_L("CYXWVUTSRQPONMLKJIHGFEDBAZ")));
   1.451 +	fileName = KTestFileName5;
   1.452 +	finder.SetFileName(fileName);
   1.453 +	finder.AddAllDrives();
   1.454 +	test(0 == finder.iDrives.CompareF(_L("DYXWVUTSRQPONMLKJIHGFECBAZ")));
   1.455 +	fileName = KTestFileName6;
   1.456 +	finder.SetFileName(fileName);
   1.457 +	finder.AddAllDrives();
   1.458 +	test(0 == finder.iDrives.CompareF(_L("YXWVUTSRQPONMLKJIHGFEDCBAZ")));
   1.459 +	fileName = KTestFileName7;
   1.460 +	finder.SetFileName(fileName);
   1.461 +	finder.AddAllDrives();
   1.462 +	test(0 == finder.iDrives.CompareF(_L("AYXWVUTSRQPONMLKJIHGFEDCBZ")));
   1.463 +	fileName = KTestFileName8;
   1.464 +	finder.SetFileName(fileName);
   1.465 +	finder.AddAllDrives();
   1.466 +	test(0 == finder.iDrives.CompareF(_L("CYXWVUTSRQPONMLKJIHGFEDBAZ")));
   1.467 +	fileName = KTestFileName9;
   1.468 +	finder.SetFileName(fileName);
   1.469 +	finder.AddAllDrives();
   1.470 +	test(0 == finder.iDrives.CompareF(_L("YXWVUTSRQPONMLKJIHGFEDCBAZ")));
   1.471 +
   1.472 +	// Test addition of language number
   1.473 +	// AppendLanguageCode
   1.474 +	fileName = KTestFileName1;
   1.475 +	finder.SetFileName(fileName);
   1.476 +	finder.AppendLanguageCode(ELangFrench);
   1.477 +	test(0 == finder.iFileName->CompareF(KTestFileName1French));
   1.478 +	finder.SetFileName(fileName);
   1.479 +	finder.AppendLanguageCode(ELangJapanese);
   1.480 +	test(0 == finder.iFileName->CompareF(KTestFileName1Japanese));
   1.481 +	finder.SetFileName(fileName);
   1.482 +	finder.AppendLanguageCode(ELangAmericanSprint);
   1.483 +	test(0 == finder.iFileName->CompareF(KTestFileName1AmericanSprint));
   1.484 +
   1.485 +	fileName = KTestFileName1;
   1.486 +	finder.SetFileName(fileName);
   1.487 +	finder.AppendLanguageCode(static_cast<TLanguage>(54321));
   1.488 +	test(0 == finder.iFileName->CompareF(KTestFileName1Mongolian));
   1.489 +	fileName = KTestFileName256Chars;
   1.490 +	finder.SetFileName(fileName);
   1.491 +	test(!finder.AppendLanguageCode(ELangFrench));
   1.492 +
   1.493 +	// Test searching each drive for the specified file
   1.494 +	// FindDrive
   1.495 +	finder.iFileCheckedFor = KCheckedForFrench;
   1.496 +	finder.iDrivesChecked = _L("D");
   1.497 +	fileName = KTestFileName5;
   1.498 +	finder.SetFileName(fileName);
   1.499 +	finder.AppendLanguageCode(ELangFrench);
   1.500 +	finder.FindDrive();
   1.501 +	test(finder.iDrivesChecked.Length() == 0);
   1.502 +	finder.SetFileName(fileName);
   1.503 +	finder.AddAllDrives();
   1.504 +	finder.iDrivesChecked = _L("dyxwvutsrqponmlkjihgfecbaz");
   1.505 +	finder.AppendLanguageCode(ELangFrench);
   1.506 +	finder.FindDrive();
   1.507 +	test(finder.iDrivesChecked.Length() == 0);
   1.508 +	fileName = KTestFileName5;
   1.509 +	finder.SetFileName(fileName);
   1.510 +	finder.AddAllDrives();
   1.511 +	finder.iDrivesChecked = _L("dyxwvutsrqponmlkjihgfecbaz");
   1.512 +	finder.AppendLanguageCode(ELangFrench);
   1.513 +	finder.iFilesThatExist = new (ELeave) CDesCArraySeg(10);
   1.514 +	finder.iFilesThatExist->AppendL(_L("o:\\dIR\\NAmE.E02"));
   1.515 +	test(finder.FindDrive());
   1.516 +	test(0 == finder.iFileName->CompareF(_L("O:\\dir\\name.e02")));
   1.517 +	fileName = KTestFileName2;
   1.518 +	finder.SetFileName(fileName);
   1.519 +	finder.AppendLanguageCode(ELangFrench);
   1.520 +	finder.AddAllDrives();
   1.521 +	finder.iDrivesChecked = _L("zyxwvutsrqponmlkjihgfedcba");
   1.522 +	finder.iFilesThatExist->AppendL(_L("v:\\dIR\\NA\x301mE.E02"));
   1.523 +	//finder.iFileCheckedFor = _L("?:\\dir\\nÁme.e02");
   1.524 +	finder.iFileCheckedFor = _L("?:\\dir\\n\u00c1me.e02");
   1.525 +	test(finder.FindDrive());
   1.526 +	//test(0 == finder.iFileName->CompareF(_L("v:\\dir\\nÁme.e02")));
   1.527 +	test(0 == finder.iFileName->CompareF(_L("v:\\dir\\n\u00c1me.e02")));
   1.528 +	delete finder.iFilesThatExist;
   1.529 +	finder.iFilesThatExist = 0;
   1.530 +
   1.531 +	// Test searching language and drive down the language path
   1.532 +	// FindLanguageAndDrive
   1.533 +	finder.iPath[0] = static_cast<TLanguage>(2);
   1.534 +	finder.iPath[1] = static_cast<TLanguage>(15702);
   1.535 +	finder.iPath[2] = static_cast<TLanguage>(1);
   1.536 +	finder.iPath[3] = ELangNone;
   1.537 +	fileName = KTestFileName1;
   1.538 +	finder.SetFileName(fileName);
   1.539 +	SetUpFinderForLanguageAndDriveSearchL(finder);
   1.540 +	finder.iFileCheckedFor = _L("?:\\dir\\name.e*");
   1.541 +	test(!finder.FindLanguageAndDrive());
   1.542 +	// check that iFileName is undamaged
   1.543 +	finder.RepairFileName();
   1.544 +	test(0 == finder.iFileName->CompareF(KTestFileName1));
   1.545 +	delete finder.iFilesSearchedFor;
   1.546 +	finder.iFilesThatExist = new (ELeave) CDesCArraySeg(10);
   1.547 +	finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e15702"));
   1.548 +	fileName = KTestFileName1;
   1.549 +	finder.SetFileName(fileName);
   1.550 +	SetUpFinderForLanguageAndDriveSearchL(finder);
   1.551 +	test(finder.FindLanguageAndDrive());
   1.552 +	test(0 == finder.iFileName->CompareF(_L("a:\\dir\\name.e15702")));
   1.553 +	delete finder.iFilesSearchedFor;
   1.554 +	finder.iFilesSearchedFor = 0;
   1.555 +
   1.556 +	finder.iPath[0] = static_cast<TLanguage>(7);
   1.557 +	finder.iPath[1] = ELangNone;
   1.558 +	finder.iFilesThatExist->AppendL(_L("g:\\dir\\name.ext"));
   1.559 +	fileName = KTestFileName1;
   1.560 +	finder.SetFileName(fileName);
   1.561 +	finder.iDrives = _L("ZAG");
   1.562 +	finder.iDrivesChecked = _L("ZAGZAG");
   1.563 +	test(finder.FindLanguageAndDrive());
   1.564 +	test(0 == finder.iFileName->CompareF(_L("g:\\dir\\name.ext")));
   1.565 +	delete finder.iFilesThatExist;
   1.566 +	finder.iFilesThatExist = 0;
   1.567 +
   1.568 +	// Test filename matching
   1.569 +	// LanguageNumberFromFile
   1.570 +	test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb04"), _L("AVB")));
   1.571 +	//test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("ávb04"), _L("A\x301VB")));
   1.572 +	//test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("a\x301vb04"), _L("ÁVB")));
   1.573 +	test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("\u00e1vb04"), _L("A\x301VB")));
   1.574 +	test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("a\x301vb04"), _L("\u00c1VB")));
   1.575 +	test(5254 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb5254"), _L("aVb")));
   1.576 +	test(KErrNotFound == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb04"), _L("avb04")));
   1.577 +	test(KErrNotFound == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb04"), _L("av")));
   1.578 +	test(KErrNotFound == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb04"), _L("")));
   1.579 +	test(0 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb0000000"), _L("AVB00000")));
   1.580 +	test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb000000004"), _L("AVB0000000")));
   1.581 +	test(100004 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb000100004"), _L("AVB000")));
   1.582 +	test(111114 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb0111114"), _L("AVB0")));
   1.583 +
   1.584 +	// Test searching for any language file within a drive
   1.585 +	// FindFirstLanguageFile
   1.586 +	fileName = KTestFileName3;
   1.587 +	finder.SetFileName(fileName);
   1.588 +	finder.iFilesThatExist = new (ELeave) CDesCArraySeg(10);
   1.589 +	finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e107"));
   1.590 +	finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e07"));
   1.591 +	finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e02"));
   1.592 +	finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.ee01"));
   1.593 +	finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.01"));
   1.594 +	finder.iFilesThatExist->AppendL(_L("a:\\dir\\name01"));
   1.595 +	finder.iFilesThatExist->AppendL(_L("a:\\dir\\name01.e01"));
   1.596 +	finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e15108"));
   1.597 +	finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e03"));
   1.598 +	finder.iTestScanner.iDriveError[0] = KErrNoMemory;
   1.599 +	fileName = KTestFileName3;
   1.600 +	finder.SetFileName(fileName);
   1.601 +	test(KErrNotFound == finder.FindFirstLanguageFile(dummy));
   1.602 +	finder.iTestScanner.iDriveError[0] = KErrAbort;
   1.603 +	fileName = KTestFileName3;
   1.604 +	finder.SetFileName(fileName);
   1.605 +	test(KErrNotFound == finder.FindFirstLanguageFile(dummy));
   1.606 +	finder.iTestScanner.iDriveError[0] = KErrNone;
   1.607 +	fileName = KTestFileName3;
   1.608 +	finder.SetFileName(fileName);
   1.609 +	test(0 <= finder.FindFirstLanguageFile(dummy));
   1.610 +	test(0 == finder.iFileName->CompareF(_L("a:\\dir\\name.e02")));
   1.611 +
   1.612 +	finder.iFilesThatExist->AppendL(_L("a:\\abaffafg.100"));
   1.613 +	finder.iFilesThatExist->AppendL(_L("a:\\abcdefg.9539"));
   1.614 +	finder.iFilesThatExist->AppendL(_L("a:\\abcdefg.19539"));
   1.615 +	finder.iFilesThatExist->AppendL(_L("a:\\abcdefg.1000"));
   1.616 +	finder.iFilesThatExist->AppendL(_L("a:\\abaffafg.102"));
   1.617 +	fileName = _L("a:\\abcdefg.xx");
   1.618 +	finder.SetFileName(fileName);
   1.619 +	test(0 <= finder.FindFirstLanguageFile(dummy));
   1.620 +	test(0 == finder.iFileName->CompareF(_L("a:\\abcdefg.1000")));
   1.621 +	finder.iFilesThatExist->AppendL(_L("a:\\abaffafg.aaa100"));
   1.622 +	finder.iFilesThatExist->AppendL(_L("a:\\abcdefg.0523"));	// not well-formed. Will not count.
   1.623 +	finder.iFilesThatExist->AppendL(_L("a:\\abcdefg.1001"));
   1.624 +	fileName = _L("a:\\abcdefg.xx");
   1.625 +	finder.SetFileName(fileName);
   1.626 +	test(0 <= finder.FindFirstLanguageFile(dummy));
   1.627 +	test(0 == finder.iFileName->CompareF(_L("a:\\abcdefg.1000")));
   1.628 +	fileName = _L("a:\\abaffafg.xx");
   1.629 +	finder.SetFileName(fileName);
   1.630 +	test(0 <= finder.FindFirstLanguageFile(dummy));
   1.631 +	test(0 == finder.iFileName->CompareF(_L("a:\\abaffafg.100")));
   1.632 +	finder.iFilesThatExist->AppendL(_L("a:\\abaffafg.09"));
   1.633 +	fileName = _L("a:\\abaffafg.xx");
   1.634 +	finder.SetFileName(fileName);
   1.635 +	test(0 <= finder.FindFirstLanguageFile(dummy));
   1.636 +	test(0 == finder.iFileName->CompareF(_L("a:\\abaffafg.09")));
   1.637 +
   1.638 +	// Test searching all drives for any language
   1.639 +	// FindFirstLanguageFileAndDrive
   1.640 +	finder.iFilesThatExist->AppendL(_L("z:\\abcdefg.05"));
   1.641 +	fileName = _L("c:\\abcdefg.xx");
   1.642 +	finder.SetFileName(fileName);
   1.643 +	finder.iDrives = _L("az");
   1.644 +	test(0 <= finder.FindFirstLanguageFileAndDrive());
   1.645 +	test(0 == finder.iFileName->CompareF(_L("a:\\abcdefg.1000")));
   1.646 +	fileName = _L("c:\\abaffafg.xx");
   1.647 +	finder.SetFileName(fileName);
   1.648 +	finder.iDrives = _L("az");
   1.649 +	test(0 <= finder.FindFirstLanguageFileAndDrive());
   1.650 +	test(0 == finder.iFileName->CompareF(_L("a:\\abaffafg.09")));
   1.651 +	fileName = _L("c:\\abcdefg.xx");
   1.652 +	finder.SetFileName(fileName);
   1.653 +	finder.iDrives = _L("za");
   1.654 +	test(0 <= finder.FindFirstLanguageFileAndDrive());
   1.655 +	test(0 == finder.iFileName->CompareF(_L("z:\\abcdefg.05")));
   1.656 +	fileName = _L("c:\\xxx.xx");
   1.657 +	finder.SetFileName(fileName);
   1.658 +	finder.iDrives = _L("za");
   1.659 +	test(KErrNotFound == finder.FindFirstLanguageFileAndDrive());
   1.660 +	finder.iTestScanner.iDriveError[25] = KErrAbort;
   1.661 +	fileName = _L("c:\\abcdefg.xx");
   1.662 +	finder.SetFileName(fileName);
   1.663 +	finder.iDrives = _L("za");
   1.664 +	test(0 <= finder.FindFirstLanguageFileAndDrive());
   1.665 +	test(0 == finder.iFileName->CompareF(_L("a:\\abcdefg.1000")));
   1.666 +	fileName = _L("c:\\abcdefg.xx");
   1.667 +	finder.SetFileName(fileName);
   1.668 +	finder.iDrives = _L("za");
   1.669 +	finder.iTestScanner.iDriveError[0] = KErrNoMemory;
   1.670 +	test(KErrNotFound == finder.FindFirstLanguageFileAndDrive());
   1.671 +	fileName = _L("c:\\abcdefg.xx");
   1.672 +	finder.SetFileName(fileName);
   1.673 +	finder.iDrives = _L("za");
   1.674 +	finder.iTestScanner.iDriveError[0] = KErrAbort;
   1.675 +	test(KErrNotFound == finder.FindFirstLanguageFileAndDrive());
   1.676 +
   1.677 +	}
   1.678 +
   1.679 +/**
   1.680 +@SYMTestCaseID          SYSLIB-BAFL-CT-0447
   1.681 +@SYMTestCaseDesc        Tests for defect number DEF039977
   1.682 +@SYMTestPriority        High
   1.683 +@SYMTestActions         Test for Panic in BaflUtils::DiskIsReadOnly()
   1.684 +						when unexpected parameter supplied
   1.685 +@SYMTestExpectedResults Test must not fail
   1.686 +@SYMREQ                 REQ0000
   1.687 +*/
   1.688 +void TestforDEF039977()
   1.689 +	{
   1.690 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0447 "));
   1.691 +	TFileName filename;
   1.692 +	TBool readOnly;
   1.693 +	TInt theRes;
   1.694 +	RFs fileserver;
   1.695 +	TInt err=fileserver.Connect();
   1.696 +	test(err==KErrNone);
   1.697 +
   1.698 +	filename=_L("c");
   1.699 +	theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly);
   1.700 +	test(theRes==KErrBadName);
   1.701 +
   1.702 +	filename=_L(" z:");
   1.703 +	theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly);
   1.704 +	test(theRes==KErrBadName);
   1.705 +
   1.706 +	filename=_L("z\\");
   1.707 +	theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly);
   1.708 +	test(theRes==KErrBadName);
   1.709 +
   1.710 +	filename=_L("b:");
   1.711 +	theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly);
   1.712 +	test(theRes==KErrNotReady);
   1.713 +
   1.714 +	filename=_L("c:");
   1.715 +	theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly);
   1.716 +	test(theRes==KErrNone);
   1.717 +	test(!readOnly);
   1.718 +
   1.719 +	filename=_L("z:");
   1.720 +	theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly);
   1.721 +	test(theRes==KErrNone);
   1.722 +	test(readOnly);
   1.723 +
   1.724 +	filename=_L("z:\\");
   1.725 +	theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly);
   1.726 +	test(theRes==KErrNone);
   1.727 +
   1.728 +	filename=_L("z:\\system\\data\\");
   1.729 +	theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly);
   1.730 +	test(theRes==KErrNone);
   1.731 +
   1.732 +	fileserver.Close();
   1.733 +	}
   1.734 +
   1.735 +/*
   1.736 +@SYMTestCaseID          SYSLIB-BAFL-CT-1284
   1.737 +@SYMTestCaseDesc        Tests for invalid character
   1.738 +@SYMTestPriority        High
   1.739 +@SYMTestActions         Test for panic when an invalid character when
   1.740 +                        supplied to BaflUtils::RootFolderPath's parameter as drive letter
   1.741 +@SYMTestExpectedResults Test must not fail
   1.742 +@SYMREQ                 REQ0000
   1.743 +*/
   1.744 +TInt TestforInvalidCharacter(TAny* /*aData*/)
   1.745 +/**
   1.746 + This is a root thread function which runs as part of the TestforDEF040198().
   1.747 + It tests a panic is produced when an invalid non alphabet character is supplied
   1.748 + in the aDriveLetter argument in BaflUtils::RootFolderPath(const TBuf<1> aDriveLetter)
   1.749 +*/
   1.750 +	{
   1.751 +	TBuf<1> buf1=_L("?");
   1.752 +	TFileName retValue;
   1.753 +	retValue=BaflUtils::RootFolderPath(buf1);
   1.754 +
   1.755 +	// Line above panics if working OK, so should never get here.
   1.756 +	test(0);
   1.757 +	return 0;
   1.758 +	}
   1.759 +
   1.760 +/**
   1.761 +This method is a test case to demonstrate the fix for DEF040198 by supplying an invalid
   1.762 +input aDriveLetter argument (e.g "?") to BaflUtils::RootFolderPath(aDriveLetter).
   1.763 +
   1.764 +@SYMTestCaseID          SYSLIB-BAFL-CT-0448
   1.765 +@SYMTestCaseDesc        Tests for defect number DEF040198
   1.766 +@SYMTestPriority        High
   1.767 +@SYMTestActions         Check by giving an invalid aDriveLetter argument
   1.768 +@SYMTestExpectedResults Test must not fail
   1.769 +@SYMREQ                 REQ0000
   1.770 +*/
   1.771 +void TestforDEF040198()
   1.772 +	{
   1.773 +        test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0448 "));
   1.774 +//Check invalid aDriveLetter argument panics with panic code EBaflPanicBadOpenArg
   1.775 +#if defined(_DEBUG)
   1.776 +		TRequestStatus threadStatus;
   1.777 +		RThread thread;
   1.778 +		_LIT(KThreadName,"ThreadTest");
   1.779 +		TInt rc;
   1.780 +		TBool jit;
   1.781 +		jit=User::JustInTime();
   1.782 +		User::SetJustInTime(EFalse);
   1.783 +
   1.784 +		test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1284 "));
   1.785 +		rc=thread.Create(KThreadName,TestforInvalidCharacter,KDefaultStackSize,KMinHeapSize,KMinHeapSize*4,NULL);
   1.786 +		test(rc==KErrNone);
   1.787 +		thread.Logon(threadStatus);
   1.788 +		thread.Resume();
   1.789 +		User::WaitForRequest(threadStatus);
   1.790 +		test (thread.ExitType()==EExitPanic);
   1.791 +		test (thread.ExitReason()==EBafPanicBadOpenArg);
   1.792 +		thread.Close();
   1.793 +		User::SetJustInTime(jit);
   1.794 +#endif
   1.795 +	}
   1.796 +
   1.797 +/*
   1.798 +@SYMTestCaseID          SYSLIB-BAFL-CT-1285
   1.799 +@SYMTestCaseDesc        Tests for invalid path name
   1.800 +@SYMTestPriority        High
   1.801 +@SYMTestActions         Test for panic when an invalid character supplied to BaflUtils::RootFolderPath's parameter as drive letter
   1.802 +@SYMTestExpectedResults Test must not fail
   1.803 +@SYMREQ                 REQ0000
   1.804 +*/
   1.805 +TInt TestforInvalidPathName(TAny* /*aData*/)
   1.806 +/**
   1.807 + This is a root thread function which runs as part of the TestforDEF040299().
   1.808 + It tests a panic is produced when an invalid name is supplied
   1.809 + in the aFullName argument in BaflUtils::FolderNameFromFullName(const TDesC& aFullName)
   1.810 +*/
   1.811 +	{	
   1.812 +	TBuf<1> buf1=_L("?");
   1.813 +	TFileName retValue;
   1.814 +	retValue=BaflUtils::FolderNameFromFullName(buf1);
   1.815 +
   1.816 +	// Line above panics if working OK, so should never get here.
   1.817 +	test(0);
   1.818 +	return 0;
   1.819 +	}
   1.820 +
   1.821 +/**
   1.822 +@SYMTestCaseID          SYSLIB-BAFL-CT-0449
   1.823 +@SYMTestCaseDesc        Tests for defect number DEF047305
   1.824 +@SYMTestPriority        High
   1.825 +@SYMTestActions         Test for correct syntax
   1.826 +@SYMTestExpectedResults Test must not fail
   1.827 +@SYMREQ                 REQ0000
   1.828 +*/
   1.829 +void TestForDEF047305()
   1.830 +	{
   1.831 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0449 "));
   1.832 +	RFs aFs;
   1.833 +	CleanupClosePushL(aFs);
   1.834 +	User::LeaveIfError(aFs.Connect());
   1.835 +
   1.836 +	TFileName newFolderFullName = KCurrentPath;
   1.837 +
   1.838 +	test(User::LeaveIfError(BaflUtils::ValidateFolderNameTypedByUserL(aFs, KValFolderName, KCurrentPath, newFolderFullName)==KErrNone));
   1.839 + 	test(User::LeaveIfError(BaflUtils::ValidateFolderNameTypedByUserL(aFs, KNoFolderName, KCurrentPath, newFolderFullName)==KErrArgument));
   1.840 + 	test(User::LeaveIfError(BaflUtils::ValidateFolderNameTypedByUserL(aFs, KInValidFolderName, KCurrentPath, newFolderFullName)==KErrBadName));
   1.841 +
   1.842 +	CleanupStack::PopAndDestroy(&aFs);
   1.843 +	}
   1.844 +
   1.845 +/**
   1.846 +@SYMTestCaseID          SYSLIB-BAFL-CT-0450
   1.847 +@SYMTestCaseDesc        Tests for defect number DEF040299
   1.848 +@SYMTestPriority        High
   1.849 +@SYMTestActions         Test by supplying an invalid input aFullName argument to BaflUtils::FolderNameFromFullName(aFullName)
   1.850 +@SYMTestExpectedResults Test must not fail
   1.851 +@SYMREQ                 REQ0000
   1.852 +*/
   1.853 +void TestforDEF040299()
   1.854 +	{
   1.855 +    test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0450 "));
   1.856 +	TBuf<30> buf;
   1.857 +	TFileName fileName;
   1.858 +
   1.859 +	//Path name="c:"
   1.860 +	buf=_L("c:");
   1.861 +	fileName=BaflUtils::FolderNameFromFullName(buf);
   1.862 +	test(buf==fileName);
   1.863 +
   1.864 +	//Path name="c:\\"
   1.865 +	buf=_L("c:\\");
   1.866 +	fileName=BaflUtils::FolderNameFromFullName(buf);
   1.867 +	test(fileName==buf);
   1.868 +
   1.869 +	//Path name="c:\\file.txt"
   1.870 +	buf=_L("c:\\file.txt");
   1.871 +	fileName=BaflUtils::FolderNameFromFullName(buf);
   1.872 +	test(fileName==_L("c:\\"));
   1.873 +
   1.874 +	//Path name="c:\\system\\file.txt"
   1.875 +	buf=_L("c:\\system\\file.txt");
   1.876 +	fileName=BaflUtils::FolderNameFromFullName(buf);
   1.877 +	test(fileName==_L("system"));
   1.878 +
   1.879 +	/**
   1.880 +	This method is a test case to demonstrate the fix for DEF040299 by supplying an invalid
   1.881 +	input aFullName argument (e.g "?") to BaflUtils::FolderNameFromFullName(aFullName).
   1.882 +	*/
   1.883 +	//Check invalid aFullName argument panics with panic code EBaflPanicBadOpenArg
   1.884 +#if defined(_DEBUG)
   1.885 +		TRequestStatus threadStatus;
   1.886 +		RThread thread;
   1.887 +		//Tread name is changed due to test failing on slow machine
   1.888 +		//Using "TreadTest" here are causing KErrAlreadyExist at tread creating stage.
   1.889 +		//This is because the previous tread maybe still being closed when this thread is created.
   1.890 +		_LIT(KThreadName,"ThreadTest1");
   1.891 +		TInt rc;
   1.892 +		TBool jit;
   1.893 +		jit=User::JustInTime();
   1.894 +		User::SetJustInTime(EFalse);
   1.895 +		test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1285 "));
   1.896 +rc=thread.Create(KThreadName,TestforInvalidPathName,KDefaultStackSize,KMinHeapSize,KMinHeapSize*4,NULL);
   1.897 +		test(rc==KErrNone);
   1.898 +		thread.Logon(threadStatus);
   1.899 +		thread.Resume();
   1.900 +		User::WaitForRequest(threadStatus);
   1.901 +		test (thread.ExitType()==EExitPanic);
   1.902 +		test (thread.ExitReason()==EBafPanicBadOpenArg);
   1.903 +		thread.Close();
   1.904 +		User::SetJustInTime(jit);
   1.905 +#endif
   1.906 +
   1.907 +	}
   1.908 +
   1.909 +/**
   1.910 +@SYMTestCaseID          SYSLIB-BAFL-CT-3416
   1.911 +@SYMTestCaseDesc        Tests for defect number DEF101927
   1.912 +@SYMTestPriority        High
   1.913 +@SYMTestActions         Test the simulated Tls functionalities Dll::Tls, Dll::SetTls and Dll::FreeTls
   1.914 +						which is needed for BAUtils.cpp to be complied as part of an .exe.
   1.915 +						Dll::Tls - Recalls the value currently referred to by the Tls pointer
   1.916 +						Dll::SetTls - Sets the the values referred to by the Tls pointer
   1.917 +						Dll::FreeTls - Sets the Tls pointer to NULL
   1.918 +@SYMTestExpectedResults Pass if the TLanguage values is returned as expected after calls to IdealLanguage,
   1.919 +						SetIdealLanguage and ReleaseIdealLanguage.
   1.920 +@SYMDEF                 DEF101927
   1.921 +*/
   1.922 +void TestForDEF101927()
   1.923 +	{
   1.924 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-3416 "));
   1.925 +	TLanguage test_language(ELangAmerican);
   1.926 +
   1.927 +	test(BaflUtils::IdealLanguage()==ELangNone);
   1.928 +
   1.929 +	BaflUtils::SetIdealLanguage(ELangAmerican);
   1.930 +	test(test_language == ELangAmerican);
   1.931 +
   1.932 +	test_language = ELangNone;
   1.933 +	test_language = BaflUtils::IdealLanguage();
   1.934 +	test(test_language == ELangAmerican);
   1.935 +
   1.936 +	BaflUtils::ReleaseIdealLanguage();
   1.937 +	test_language = BaflUtils::IdealLanguage();
   1.938 +	test(test_language == ELangNone);
   1.939 +	}
   1.940 +
   1.941 +/**
   1.942 +@SYMTestCaseID			SYSLIB-BAFL-UT-3667
   1.943 +@SYMTestCaseDesc		Tests for defect number DEF109928
   1.944 +@SYMTestPriority		Normal
   1.945 +@SYMTestActions         Test for the extended NextLanguage(). Check if the MakeLanguageDowngradePath()
   1.946 +						can now return the correct default fallback for the languages which are newly
   1.947 +						added into the NextLanguage().
   1.948 +@SYMTestExpectedResults Test must not fail
   1.949 +@SYMDEF					DEF109928
   1.950 +*/
   1.951 +void TestForDEF109928()
   1.952 +	{
   1.953 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-UT-3667 "));
   1.954 +	TLanguage testDeviceLangs[8] = {ELangEnglish_Japan, ELangSwissFrench, ELangSwissGerman,
   1.955 +									ELangLatinAmericanSpanish, ELangSwissItalian, ELangFinlandSwedish,
   1.956 +									ELangMalay_Apac, ELangBrazilianPortuguese};
   1.957 +	TLanguagePath testOutputPath[8] = {{ELangEnglish_Japan, ELangEnglish}, {ELangSwissFrench, ELangFrench},
   1.958 +				{ELangSwissGerman, ELangGerman}, {ELangLatinAmericanSpanish, ELangSpanish},
   1.959 +				{ELangSwissItalian, ELangItalian}, {ELangFinlandSwedish, ELangSwedish},
   1.960 +				{ELangMalay_Apac, ELangMalay}, {ELangBrazilianPortuguese, ELangPortuguese}};
   1.961 +	TLocale loc;
   1.962 +	loc.SetLanguageDowngrade(0, ELangNone);
   1.963 +	loc.SetLanguageDowngrade(1, ELangNone);
   1.964 +	loc.SetLanguageDowngrade(2, ELangNone);
   1.965 +	TLanguagePath path;
   1.966 +	TLanguage testlang;
   1.967 +
   1.968 +	for(TInt i = 0; i < 8 ; i++)
   1.969 +		{
   1.970 +		testlang = testDeviceLangs[i];
   1.971 +		MakeLanguageDowngradePath(path, testlang, ELangNone, loc);
   1.972 +		test(path[0] == testOutputPath[i][0]);
   1.973 +		test(path[1] == testOutputPath[i][1]);
   1.974 +		test(path[2] == ELangNone);
   1.975 +		}
   1.976 +	}
   1.977 +
   1.978 +/* The following 3 function is defined so that the functions IdealLanguage,
   1.979 +SetIdealLanguage, ReleaseIdealLanguage will compile as part as an .exe
   1.980 +These functions use a global TAny* to store the data that would have been
   1.981 +stored in the TLS under normal compilation (ie If the BaUtils was compilled
   1.982 +as part of a DLL).
   1.983 +*/
   1.984 +
   1.985 +TAny* ptr(NULL);
   1.986 +
   1.987 +TAny* Dll::Tls()
   1.988 +	{
   1.989 +	return ptr;
   1.990 +	}
   1.991 +
   1.992 +TInt Dll::SetTls(TAny* aPtr)
   1.993 +	{
   1.994 +	ptr = aPtr;
   1.995 +	return KErrNone;
   1.996 +	}
   1.997 +
   1.998 +void Dll::FreeTls()
   1.999 +	{
  1.1000 +	ptr = NULL;
  1.1001 +	}
  1.1002 +
  1.1003 +void RunTestsL()
  1.1004 +	{
  1.1005 +	__UHEAP_MARK;
  1.1006 +
  1.1007 +	test.Title();
  1.1008 +	test.Start(_L("BaflUtils Internal Tests: "));
  1.1009 +
  1.1010 +	TestAddLanguage();
  1.1011 +	TestMakeLanguageDowngradePath();
  1.1012 +	TestNearestLanguageFinder();
  1.1013 +	TestforDEF039977();
  1.1014 +	TestforDEF040198();
  1.1015 +	TestforDEF040299();
  1.1016 +	TestForDEF047305();
  1.1017 +	TestForDEF101927();
  1.1018 +	TestForDEF109928();
  1.1019 +	test.End();
  1.1020 +	test.Close();
  1.1021 +
  1.1022 +	__UHEAP_MARKENDC(0);
  1.1023 +	}
  1.1024 +
  1.1025 +TInt E32Main()
  1.1026 +	{
  1.1027 +	TrapCleanup = CTrapCleanup::New();
  1.1028 +	TRAPD(err, RunTestsL());
  1.1029 +    test(err == KErrNone);
  1.1030 +	delete TrapCleanup;
  1.1031 +	return 0;
  1.1032 +	}