os/kernelhwsrv/kerneltest/f32test/outsideBMP/src/t_surrogatepair.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/outsideBMP/src/t_surrogatepair.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,574 @@
     1.4 +// Copyright (c) 2007-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 the License "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 +// f32test\locl\localeutils\T_SURROGATEPAIR.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#define __E32TEST_EXTENSION__
    1.22 +
    1.23 +#include <e32test.h>
    1.24 +#include <HAL.H>
    1.25 +#include <f32fsys.h>
    1.26 +#include <f32dbg.h>
    1.27 +#include "..\server\t_server.h"
    1.28 +
    1.29 +RTest test(_L("T_SURROGATEPAIR"));
    1.30 +
    1.31 +/* 
    1.32 + * Helper function to capture and return any MakeFile error code.
    1.33 + */
    1.34 +TInt SurrogatePair_MakeFile(const TDesC& aFileName)
    1.35 +	{
    1.36 +	RFile file;
    1.37 +	TInt r=file.Replace(TheFs,aFileName,0);
    1.38 +	file.Close();
    1.39 +	return r;
    1.40 +	}
    1.41 +
    1.42 +/*
    1.43 + *  Tests given ShortName against LongName and vice versa for a File Entry.
    1.44 + */
    1.45 +void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName)
    1.46 +	{
    1.47 +	TFileName lgnFullPath;
    1.48 +	TFileName shnFullPath;
    1.49 +	TFileName lgn;
    1.50 +	TFileName shn;
    1.51 +
    1.52 +	TInt r = TheFs.SessionPath(gSessionPath);
    1.53 +	test_KErrNone(r);
    1.54 +	lgnFullPath = gSessionPath;
    1.55 +	lgnFullPath += aLongName;
    1.56 +
    1.57 +	MakeFile(lgnFullPath);
    1.58 +
    1.59 +	// Check short name	
    1.60 +	r = TheFs.GetShortName(lgnFullPath, shn);
    1.61 +	test_KErrNone(r);
    1.62 +	r = shn.Compare(aShortName);
    1.63 +	test(r==0);
    1.64 +
    1.65 +	// Check long name	
    1.66 +	shnFullPath = gSessionPath;
    1.67 +	shnFullPath += aShortName;
    1.68 +
    1.69 +	r = TheFs.GetLongName(shnFullPath, lgn);
    1.70 +	test_KErrNone(r);
    1.71 +	r = lgn.Compare(aLongName);
    1.72 +	test(r==0);
    1.73 +
    1.74 +	test_KErrNone(TheFs.Delete(lgnFullPath));
    1.75 +	}
    1.76 +
    1.77 +/*
    1.78 + *  Tests given ShortName against LongName and vice versa for a Directory Entry.
    1.79 + */
    1.80 +void doDirNameTest(const TDesC& aLongName, const TDesC& aShortName)
    1.81 +	{
    1.82 +	TBuf<KMaxFileName> longDirNamePath;
    1.83 +	TBuf<KMaxFileName> shortDirNamePath;
    1.84 +	TBuf<KMaxFileName> longName;
    1.85 +	TBuf<KMaxFileName> shortName;
    1.86 +	longDirNamePath = gSessionPath;
    1.87 +	longDirNamePath += aLongName;
    1.88 +	longDirNamePath.Append('\\');
    1.89 +
    1.90 +	// Create new directory and check creation
    1.91 +	TInt r = TheFs.MkDir(longDirNamePath);
    1.92 +	test_KErrNone(r);
    1.93 +	TUint dumUint=0;
    1.94 +	CDir* dumDir;
    1.95 +	r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir);
    1.96 +	test_KErrNone(r);
    1.97 +	test_NotNull(dumDir);
    1.98 +	delete dumDir;
    1.99 +
   1.100 +	// Check short name
   1.101 +	r = TheFs.GetShortName(longDirNamePath, shortName);
   1.102 +	test_KErrNone(r);
   1.103 +	r = shortName.Compare(aShortName);
   1.104 +	test(r==0);
   1.105 +	
   1.106 +	// Check long name
   1.107 +	shortDirNamePath = gSessionPath;
   1.108 +	shortDirNamePath += shortName;
   1.109 +	shortDirNamePath.Append('\\');
   1.110 +	r = TheFs.GetLongName(shortDirNamePath, longName);
   1.111 +	test_KErrNone(r);
   1.112 +	r = longName.Compare(aLongName);
   1.113 +	test(r==0);
   1.114 +
   1.115 +	r = TheFs.RmDir(longDirNamePath);
   1.116 +	test_KErrNone(r);
   1.117 +	}
   1.118 +
   1.119 +/*
   1.120 + *  Tests File entry and Dir entry.
   1.121 + */
   1.122 +void TestConversion(const TDesC& aLongName, const TDesC& aShortName)
   1.123 +	{
   1.124 +	doFileNameTest(aLongName, aShortName);
   1.125 +	doDirNameTest(aLongName, aShortName);
   1.126 +	}
   1.127 +
   1.128 +/*
   1.129 + * Tests different characters for its validity and conversion in absence of cp dll.
   1.130 + * Expects ReplacementForUnconvertibleUnicodeCharacters : "_" : UNDERSCORE for all
   1.131 + * Illegal Characters
   1.132 + */
   1.133 +void TestShortNameCharacter()
   1.134 +	{
   1.135 +	test.Next(_L("++TestShortNameCharacter"));
   1.136 +	TInt r;
   1.137 +	
   1.138 +	// one-byte chars
   1.139 +	_LIT16(Uni_1, 									"\x0019.TXT");
   1.140 +	_LIT16(Uni_1_ShortName, 						"_.TXT");
   1.141 +	TestConversion( Uni_1, Uni_1_ShortName);
   1.142 +	
   1.143 +	_LIT16(Uni_2, 									"\x0020.TXT");
   1.144 +	_LIT(Uni_2_ShortName, 							"_.TXT");
   1.145 +	TestConversion( Uni_2, Uni_2_ShortName);
   1.146 +	
   1.147 +	_LIT16(Uni_3, 									"\x0021.TXT");
   1.148 +	_LIT16(Uni_3_ShortName, 						"\x0021.TXT");
   1.149 +	TestConversion( Uni_3, Uni_3_ShortName);
   1.150 +
   1.151 + 	_LIT16(Uni_4, 									"\x0079"); // y lower case 
   1.152 +	_LIT16(Uni_4_ShortName, 						"\x0059");	// Y upper case
   1.153 +	TestConversion( Uni_4, Uni_4_ShortName);
   1.154 +
   1.155 +	_LIT16(Uni_5,									"\x0080");
   1.156 +	_LIT16(Uni_5_ShortName, 						"_");
   1.157 +	TestConversion( Uni_5, Uni_5_ShortName);
   1.158 +
   1.159 +	_LIT16(Uni_6,									"\x0081");
   1.160 +	_LIT16(Uni_6_ShortName, 						"_");
   1.161 +	TestConversion( Uni_6, Uni_6_ShortName);
   1.162 +
   1.163 +	_LIT16(Uni_7, 									"\x00fe");
   1.164 +	_LIT16(Uni_7_ShortName, 						"_");
   1.165 +	TestConversion( Uni_7, Uni_7_ShortName);
   1.166 +
   1.167 +	_LIT16(Uni_8, 									"\x00ff");
   1.168 +	_LIT16(Uni_8_ShortName, 						"_");
   1.169 +	TestConversion( Uni_8, Uni_8_ShortName);
   1.170 +	
   1.171 +	// two-byte chars
   1.172 +	_LIT16(Uni_9, 									"\x0100");
   1.173 +	_LIT16(Uni_9_ShortName, 						"_");
   1.174 +	TestConversion( Uni_9, Uni_9_ShortName);
   1.175 +
   1.176 +	_LIT16(Uni_10, 									"\x0101");
   1.177 +	_LIT16(Uni_10_ShortName, 						"_");
   1.178 +	TestConversion( Uni_10, Uni_10_ShortName);
   1.179 +
   1.180 +	_LIT16(Uni_11, 									"\x0ffe");
   1.181 +	_LIT16(Uni_11_ShortName, 						"_");
   1.182 +	TestConversion( Uni_11, Uni_11_ShortName);
   1.183 +
   1.184 +	_LIT16(Uni_12, 									"\x0fff");
   1.185 +	_LIT16(Uni_12_ShortName,						"_");
   1.186 +	TestConversion( Uni_12, Uni_12_ShortName);
   1.187 +
   1.188 +	_LIT16(Uni_13, 									"\x1000");
   1.189 +	_LIT16(Uni_13_ShortName, 						"_");
   1.190 +	TestConversion( Uni_13, Uni_13_ShortName);
   1.191 +
   1.192 +	_LIT16(Uni_14, 									"\x1001");
   1.193 +	_LIT16(Uni_14_ShortName, 						"_");
   1.194 +	TestConversion( Uni_14, Uni_14_ShortName);
   1.195 +
   1.196 +	_LIT16(Uni_15, 									"\x2999.TXT");
   1.197 +	_LIT16(Uni_15_ShortName, 						"_.TXT");
   1.198 +	TestConversion( Uni_15, Uni_15_ShortName);
   1.199 +
   1.200 +	_LIT16(Uni_16, 									"\x4E02.TXT");	
   1.201 +	_LIT16(Uni_16_ShortName, 						"_.TXT");
   1.202 +	TestConversion( Uni_16, Uni_16_ShortName);
   1.203 +
   1.204 +	_LIT16(Uni_17, 									"\x4E02.TXT");	
   1.205 +	_LIT(Uni_17_ShortName, 							"_.TXT");
   1.206 +	TestConversion( Uni_17, Uni_17_ShortName);
   1.207 +
   1.208 +	_LIT16(Uni_18, 									"\xfffe");
   1.209 +	_LIT16(Uni_18_ShortName, 						"_");
   1.210 +	TestConversion( Uni_18, Uni_18_ShortName);
   1.211 +
   1.212 +	_LIT16(Uni_19, 									"\xffff");
   1.213 +	_LIT16(Uni_19_ShortName, 						"_");
   1.214 +	TestConversion( Uni_19, Uni_19_ShortName);
   1.215 +
   1.216 +	// four-byte surrogate pairs
   1.217 +	_LIT16(Uni_20, 									"\xd840\xdc00");
   1.218 +	_LIT16(Uni_20_ShortName, 						"_");
   1.219 +	TestConversion( Uni_20, Uni_20_ShortName);	
   1.220 +
   1.221 +	_LIT16(Uni_21, 									"\xd840\xdc01");
   1.222 +	_LIT16(Uni_21_ShortName, 						"_");
   1.223 +	TestConversion( Uni_21, Uni_21_ShortName);	
   1.224 +
   1.225 +	_LIT16(Uni_22, 									"\xD87F\xdffe");
   1.226 +	_LIT16(Uni_22_ShortName, 						"_");
   1.227 +	TestConversion( Uni_22, Uni_22_ShortName);	
   1.228 +
   1.229 +	_LIT16(Uni_23, 									"\xD87F\xdfff");
   1.230 +	_LIT16(Uni_23_ShortName, 						"_");
   1.231 +	TestConversion( Uni_23, Uni_23_ShortName);	
   1.232 +
   1.233 +	//	surrogate pair
   1.234 +	_LIT16(Uni_24, 									"\xd840\xddad");
   1.235 +	_LIT16(Uni_24_ShortName, 						"_");
   1.236 +	TestConversion( Uni_24, Uni_24_ShortName);	
   1.237 +	
   1.238 +	_LIT16(Uni_25, 									"\xd801\xdd00");
   1.239 +	_LIT16(Uni_25_ShortName, 						"_");
   1.240 +	TestConversion( Uni_25, Uni_25_ShortName);
   1.241 +
   1.242 +	// corrupt surrogate in file name
   1.243 +	_LIT16(KTest0xD800, 							"\xD800.TXT");
   1.244 +	r = SurrogatePair_MakeFile(KTest0xD800);
   1.245 +	test(r==KErrBadName);
   1.246 +
   1.247 +	// corrupt surrogate in file ext
   1.248 +	_LIT16(KTest0xD800XT, 							"\xD684.\xD800XT");
   1.249 +	r = SurrogatePair_MakeFile(KTest0xD800XT);
   1.250 +	test(r==KErrBadName);
   1.251 +
   1.252 +	// corrupt surrogate in file ext
   1.253 +	_LIT16(KTestTX0xD800, 							"\xD684.TX\xD800");
   1.254 +	r = SurrogatePair_MakeFile(KTestTX0xD800);
   1.255 +	test(r==KErrBadName);
   1.256 +
   1.257 +	// corrupt surrogate in file name
   1.258 +	_LIT16(KTest0xDFFF, 							"\xDFFF.TXT");
   1.259 +	r = SurrogatePair_MakeFile(KTest0xDFFF);
   1.260 +	test(r==KErrBadName);
   1.261 +
   1.262 +	// corrupt surrogate in file ext
   1.263 +	_LIT16(KTest0xDFFFXT, 							"\xD684.\xDFFFXT");
   1.264 +	r = SurrogatePair_MakeFile(KTest0xDFFFXT);
   1.265 +	test(r==KErrBadName);
   1.266 +
   1.267 +	// corrupt surrogate in file ext
   1.268 +	_LIT16(KTestTX0xDFFF, 							"\xD684.TX\xDFFF");
   1.269 +	r = SurrogatePair_MakeFile(KTestTX0xDFFF);
   1.270 +	test(r==KErrBadName);
   1.271 +
   1.272 +	test.Next(_L("--TestShortNameCharacter"));
   1.273 +	}
   1.274 +
   1.275 +void TestVolumeLabel()
   1.276 +	{
   1.277 +	test.Next(_L("++TestVolumeLabel"));
   1.278 +	test.Next(_L("Test unicode volume labels"));
   1.279 +
   1.280 +	TInt r = TheFs.SessionPath(gSessionPath);
   1.281 +	test_KErrNone(r);
   1.282 +	TInt driveNum;
   1.283 +	r = TheFs.CharToDrive(gSessionPath[0], driveNum);
   1.284 +	test_KErrNone(r);
   1.285 +	
   1.286 +	// Retrieves the original volume label
   1.287 +	TVolumeInfo vInfo;
   1.288 +	r = TheFs.Volume(vInfo, driveNum);
   1.289 +	const TInt KVolumeLabelSize = 11;
   1.290 +	TBuf<KVolumeLabelSize> originalVolumeLabel(vInfo.iName);
   1.291 +
   1.292 +	// Tests setting volume label with 1 byte characters
   1.293 +	_LIT(K1ByteVolumeLabel, 				"\x0079\x0079\x0079");
   1.294 +	_LIT(K1ByteVolumeLabel_ShortName, 		"\x0079\x0079\x0079");
   1.295 +	
   1.296 +	r = TheFs.SetVolumeLabel(K1ByteVolumeLabel, driveNum);
   1.297 +	test_KErrNone(r);
   1.298 +	r = TheFs.Volume(vInfo, driveNum);
   1.299 +	test_KErrNone(r);
   1.300 +	r = vInfo.iName.Compare(K1ByteVolumeLabel_ShortName);
   1.301 +	test_Equal(r, 0);
   1.302 +	
   1.303 +	// Tests setting volume label with 2 byte characters
   1.304 +	_LIT(K2ByteVolumeLabel, 				"\x65B0\x65B0\x65B0");
   1.305 +	_LIT(K2ByteVolumeLabel_ShortName, 		"___");
   1.306 +
   1.307 +	r = TheFs.SetVolumeLabel(K2ByteVolumeLabel, driveNum);
   1.308 +	test_KErrNone(r);
   1.309 +	r = TheFs.Volume(vInfo, driveNum);
   1.310 +	test_KErrNone(r);
   1.311 +	r = vInfo.iName.Compare(K2ByteVolumeLabel_ShortName);
   1.312 +	test_Equal(r, 0);
   1.313 +
   1.314 +	// Tests setting volume label with surrogate pair
   1.315 +	_LIT(KTestVolumeLabelSurrogatePair1, 			"\xD846\xDF1D\x0041\x0042");
   1.316 +	_LIT(KTestVolumeLabelSurrogatePair1_ShortName,	"_AB");
   1.317 +
   1.318 +	r = TheFs.SetVolumeLabel(KTestVolumeLabelSurrogatePair1, driveNum);
   1.319 +	test_KErrNone(r);
   1.320 +	r = TheFs.Volume(vInfo, driveNum);
   1.321 +	test_KErrNone(r);
   1.322 +	r = vInfo.iName.Compare(KTestVolumeLabelSurrogatePair1_ShortName);
   1.323 +	test_Equal(r, 0);
   1.324 +
   1.325 +	_LIT(KTestVolumeLabelSurrogatePair2, 			"\x0041\x0042\xD846\xDF1D");
   1.326 +	_LIT(KTestVolumeLabelSurrogatePair2_ShortName,	"AB_");
   1.327 +
   1.328 +	r = TheFs.SetVolumeLabel(KTestVolumeLabelSurrogatePair2, driveNum);
   1.329 +	test_KErrNone(r);
   1.330 +	r = TheFs.Volume(vInfo, driveNum);
   1.331 +	test_KErrNone(r);
   1.332 +	r = vInfo.iName.Compare(KTestVolumeLabelSurrogatePair2_ShortName);
   1.333 +	test_Equal(r, 0);
   1.334 +
   1.335 +	// Sets back the original volume label
   1.336 +	r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum);
   1.337 +	test_KErrNone(r);
   1.338 +	
   1.339 +	test.Next(_L("--TestVolumeLabel"));
   1.340 +	}
   1.341 +
   1.342 +void TestConsistentShortNameGeneration()
   1.343 +	{
   1.344 +	test.Next(_L("++TestConsistentShortNameGeneration"));
   1.345 +	test.Next(_L("Test consistent short name generation"));
   1.346 +
   1.347 +	//unicode characters.
   1.348 +	_LIT(KTestFileName1,		 				"a\x65B0(bcd)");
   1.349 +	_LIT(KTestFileName1_ShortName,	 			"A_(BCD)");
   1.350 +	_LIT(KTestFileName2, 						"ab\x65B0(cdef)");
   1.351 +	_LIT(KTestFileName2_ShortName,				"AB_(CD~1");
   1.352 +	_LIT(KTestFileName3, 						"abc\x65B0(def)");
   1.353 +	_LIT(KTestFileName3_ShortName,				"ABC_(D~1");
   1.354 +	_LIT(KTestFileName4, 						"abcd\x65B0(ef)");
   1.355 +	_LIT(KTestFileName4_ShortName,				"ABCD_(~1");
   1.356 +	_LIT(KTestFileName5, 						"abcde\x65B0(f)");
   1.357 +	_LIT(KTestFileName5_ShortName,				"ABCDE_~1");
   1.358 +	_LIT(KTestFileNameSurrogatePair1, 			"\x0041\x0308\x006F\xD846\xDF1D\x0042");
   1.359 +	_LIT(KTestFileNameSurrogatePair1_ShortName,	"A_O_B");
   1.360 +	_LIT(KTestFileNameSurrogatePair2, 			"\xD846\xDF1D\x0041\x0042");
   1.361 +	_LIT(KTestFileNameSurrogatePair2_ShortName,	"_AB");
   1.362 +	_LIT(KTestFileNameSurrogatePair3, 			"\x0041\x0042\xD846\xDF1D");
   1.363 +	_LIT(KTestFileNameSurrogatePair3_ShortName,	"AB_");
   1.364 +
   1.365 +	// Test file creation and long/short name generation
   1.366 +	TestConversion(KTestFileName1,				KTestFileName1_ShortName);
   1.367 +	TestConversion(KTestFileName2, 				KTestFileName2_ShortName);
   1.368 +	TestConversion(KTestFileName3, 				KTestFileName3_ShortName);
   1.369 +	TestConversion(KTestFileName4, 				KTestFileName4_ShortName);
   1.370 +	TestConversion(KTestFileName5, 				KTestFileName5_ShortName);
   1.371 +	TestConversion(KTestFileNameSurrogatePair1,	KTestFileNameSurrogatePair1_ShortName);
   1.372 +	TestConversion(KTestFileNameSurrogatePair2,	KTestFileNameSurrogatePair2_ShortName);
   1.373 +	TestConversion(KTestFileNameSurrogatePair3,	KTestFileNameSurrogatePair3_ShortName);
   1.374 +
   1.375 +	test.Next(_L("--TestConsistentShortNameGeneration"));
   1.376 +	}
   1.377 +
   1.378 +void TestConsistentShortNameExtGeneration()
   1.379 +	{
   1.380 +	test.Next(_L("++TestConsistentShortNameExtGeneration"));
   1.381 +	test.Next(_L("Test consistent short name extensions are generated"));
   1.382 +	
   1.383 +	// File names will be used for testing boundaries
   1.384 +	_LIT(KTestFileNameExt1, 						"abcdefg.\xFFFF");
   1.385 +	_LIT(KTestFileNameExt1_ShortName,				"ABCDEFG._");
   1.386 +	_LIT(KTestFileNameExt2, 						"abcdefg.t_");
   1.387 +	_LIT(KTestFileNameExt2_ShortName, 				"ABCDEFG.T_");
   1.388 +	_LIT(KTestFileNameExt3, 						"abcdefg.\xFFFFt");
   1.389 +	_LIT(KTestFileNameExt3_ShortName,				"ABCDEFG._T");
   1.390 +	_LIT(KTestFileNameExt4, 						"abcdefg.\xFFFF\xFFFF");
   1.391 +	_LIT(KTestFileNameExt4_ShortName,				"ABCDEFG.__");
   1.392 +	_LIT(KTestFileNameExtSurrogatePair1, 			"ABCDEFG.\xD846\xDF1D\x0041");
   1.393 +	_LIT(KTestFileNameExtSurrogatePair1_ShortName,	"ABCDEFG._A");
   1.394 +	_LIT(KTestFileNameExtSurrogatePair2, 			"ABCDEFG.\x0041\xD846\xDF1D");
   1.395 +	_LIT(KTestFileNameExtSurrogatePair2_ShortName,	"ABCDEFG.A_");
   1.396 +
   1.397 +	// Test file creation and long/short name generation
   1.398 +	TestConversion(KTestFileNameExt1, 				KTestFileNameExt1_ShortName);
   1.399 +	TestConversion(KTestFileNameExt2, 				KTestFileNameExt2_ShortName);
   1.400 +	TestConversion(KTestFileNameExt3, 				KTestFileNameExt3_ShortName);
   1.401 +	TestConversion(KTestFileNameExt4, 				KTestFileNameExt4_ShortName);
   1.402 +	TestConversion(KTestFileNameExtSurrogatePair1, 	KTestFileNameExtSurrogatePair1_ShortName);
   1.403 +	TestConversion(KTestFileNameExtSurrogatePair2, 	KTestFileNameExtSurrogatePair2_ShortName);
   1.404 +
   1.405 +	test.Next(_L("--TestConsistentShortNameExtGeneration"));
   1.406 +	}
   1.407 +
   1.408 +void TestDuplicateLongFileNames()
   1.409 +	{
   1.410 +	test.Next(_L("++TestDuplicateLongFileNames"));
   1.411 +	test.Next(_L("Testing tilde and numbers (\"~n\") are applied correctly for multiple long-named files"));
   1.412 +
   1.413 +	// These are to test "~1", "~2" behaviours when the first 8 bytes of new files
   1.414 +	// are identical with existing files
   1.415 +	_LIT(KTestFileName1, 							"ABCD\xFFFE(A).TXT");
   1.416 +	_LIT(KTestFileName1_ShortName, 					"ABCD_(A).TXT");
   1.417 +	_LIT(KTestFileName2, 							"ABCD\xFFFE(AB).TXT");
   1.418 +	_LIT(KTestFileName2_ShortName, 					"ABCD_(~1.TXT");
   1.419 +	_LIT(KTestFileName3, 							"ABCD\xFFFE(ABC).TXT");
   1.420 +	_LIT(KTestFileName3_ShortName, 					"ABCD_(~2.TXT");
   1.421 +	_LIT(KTestFileNameSurrogatePair1, 				"ABCD\xD846\xDF1D(ABC).TXT");
   1.422 +	_LIT(KTestFileNameSurrogatePair1_ShortName,		"ABCD_(~3.TXT");
   1.423 +	_LIT(KTestFileNameSurrogatePair2, 				"ABCD\xD846\xDF1D(DEF).TXT");
   1.424 +	_LIT(KTestFileNameSurrogatePair2_ShortName,		"ABCD_(~4.TXT");
   1.425 +
   1.426 +	TFileName sn;
   1.427 +	MakeFile(KTestFileName1);
   1.428 +	TInt r = TheFs.GetShortName(KTestFileName1, sn);
   1.429 +	test_KErrNone(r);
   1.430 +	r = sn.Compare(KTestFileName1_ShortName);
   1.431 +	test_Equal(r, 0);
   1.432 +
   1.433 +	MakeFile(KTestFileName2);
   1.434 +	r = TheFs.GetShortName(KTestFileName2, sn);
   1.435 +	test_KErrNone(r);
   1.436 +	r = sn.Compare(KTestFileName2_ShortName);
   1.437 +	test_Equal(r, 0);
   1.438 +
   1.439 +	MakeFile(KTestFileName3);
   1.440 +	r = TheFs.GetShortName(KTestFileName3, sn);
   1.441 +	test_KErrNone(r);
   1.442 +	r = sn.Compare(KTestFileName3_ShortName);
   1.443 +	test_Equal(r, 0);
   1.444 +
   1.445 +	MakeFile(KTestFileNameSurrogatePair1);
   1.446 +	r = TheFs.GetShortName(KTestFileNameSurrogatePair1, sn);
   1.447 +	test_KErrNone(r);
   1.448 +	r = sn.Compare(KTestFileNameSurrogatePair1_ShortName);
   1.449 +	test_Equal(r, 0);
   1.450 +
   1.451 +	MakeFile(KTestFileNameSurrogatePair2);
   1.452 +	r = TheFs.GetShortName(KTestFileNameSurrogatePair2, sn);
   1.453 +	test_KErrNone(r);
   1.454 +	r = sn.Compare(KTestFileNameSurrogatePair2_ShortName);
   1.455 +	test_Equal(r, 0);
   1.456 +
   1.457 +	test_KErrNone(TheFs.Delete(KTestFileName1));
   1.458 +	test_KErrNone(TheFs.Delete(KTestFileName2));
   1.459 +	test_KErrNone(TheFs.Delete(KTestFileName3));
   1.460 +	test_KErrNone(TheFs.Delete(KTestFileNameSurrogatePair1));
   1.461 +	test_KErrNone(TheFs.Delete(KTestFileNameSurrogatePair2));
   1.462 +
   1.463 +	test.Next(_L("--TestDuplicateLongFileNames"));
   1.464 +	}
   1.465 +
   1.466 +void TestDuplicateLongDirNames()
   1.467 +	{
   1.468 +	test.Next(_L("++TestDuplicateLongDirNames"));
   1.469 +	test.Next(_L("Testing tilde and number appended correctly for duplicate long name dirs"));
   1.470 +
   1.471 +	TheFs.SessionPath(gSessionPath);
   1.472 +
   1.473 +	// These are to test "~1", "~2" behaviours when the first 8 bytes of new directories
   1.474 +	// are identical with existing directories
   1.475 +	_LIT(KTestDirName1, 							"\\F32-TST\\T_SURROGATEPAIR\\ABCD\xFFFE(A)\\");
   1.476 +	_LIT(KTestDirName1_ShortName, 					"ABCD_(A)");
   1.477 +	_LIT(KTestDirName2, 							"\\F32-TST\\T_SURROGATEPAIR\\ABCD\xFFFE(AB)\\");
   1.478 +	_LIT(KTestDirName2_ShortName, 					"ABCD_(~1");
   1.479 +	_LIT(KTestDirName3, 							"\\F32-TST\\T_SURROGATEPAIR\\ABCD\xFFFE(ABC)\\");
   1.480 +	_LIT(KTestDirName3_ShortName,				 	"ABCD_(~2");
   1.481 +	_LIT(KTestDirNameSurrogatePair1, 				"\\F32-TST\\T_SURROGATEPAIR\\ABCD\xD846\xDF1D(ABCD)\\");
   1.482 +	_LIT(KTestDirNameSurrogatePair1_ShortName,		"ABCD_(~3");
   1.483 +	_LIT(KTestDirNameSurrogatePair2, 				"\\F32-TST\\T_SURROGATEPAIR\\ABCD\xD846\xDF1D(ABCDE)\\");
   1.484 +	_LIT(KTestDirNameSurrogatePair2_ShortName,		"ABCD_(~4");
   1.485 +
   1.486 +	TFileName sn;
   1.487 +	MakeDir(KTestDirName1);
   1.488 +	TInt r = TheFs.GetShortName(KTestDirName1, sn);
   1.489 +	test_KErrNone(r);
   1.490 +	r = sn.Compare(KTestDirName1_ShortName);
   1.491 +	test_Equal(r, 0);
   1.492 +
   1.493 +	MakeDir(KTestDirName2);
   1.494 +	r = TheFs.GetShortName(KTestDirName2, sn);
   1.495 +	test_KErrNone(r);
   1.496 +	r = sn.Compare(KTestDirName2_ShortName);
   1.497 +	test_Equal(r, 0);
   1.498 +
   1.499 +	MakeDir(KTestDirName3);
   1.500 +	r = TheFs.GetShortName(KTestDirName3, sn);
   1.501 +	test_KErrNone(r);
   1.502 +	r = sn.Compare(KTestDirName3_ShortName);
   1.503 +	test_Equal(r, 0);
   1.504 +
   1.505 +	MakeDir(KTestDirNameSurrogatePair1);
   1.506 +	r = TheFs.GetShortName(KTestDirNameSurrogatePair1, sn);
   1.507 +	test_KErrNone(r);
   1.508 +	r = sn.Compare(KTestDirNameSurrogatePair1_ShortName);
   1.509 +	test_Equal(r, 0);
   1.510 +
   1.511 +	MakeDir(KTestDirNameSurrogatePair2);
   1.512 +	r = TheFs.GetShortName(KTestDirNameSurrogatePair2, sn);
   1.513 +	test_KErrNone(r);
   1.514 +	r = sn.Compare(KTestDirNameSurrogatePair2_ShortName);
   1.515 +	test_Equal(r, 0);
   1.516 +
   1.517 +	test_KErrNone(TheFs.RmDir(KTestDirName1));
   1.518 +	test_KErrNone(TheFs.RmDir(KTestDirName2));
   1.519 +	test_KErrNone(TheFs.RmDir(KTestDirName3));
   1.520 +	test_KErrNone(TheFs.RmDir(KTestDirNameSurrogatePair1));
   1.521 +	test_KErrNone(TheFs.RmDir(KTestDirNameSurrogatePair2));
   1.522 +
   1.523 +	test.Next(_L("--TestDuplicateLongDirNames"));
   1.524 +	}
   1.525 +
   1.526 +void CallTestsL(void)
   1.527 +	{
   1.528 +
   1.529 +	test.Title();
   1.530 +	test.Start(_L("Starting T_SURROGATEPAIR tests"));
   1.531 +
   1.532 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   1.533 +
   1.534 +	// Test only runs on Fat file systems
   1.535 +	TheFs.SessionPath(gSessionPath);
   1.536 +	TInt driveNum = CurrentDrive();
   1.537 +	TFSName name;
   1.538 +	TInt r = TheFs.FileSystemName(name, driveNum);
   1.539 +	if (KErrNone == r)
   1.540 +		{
   1.541 +		if (name.Compare(_L("Fat")) != 0)
   1.542 +			{
   1.543 +			test.Printf(_L("Test only runs on 'Fat' drives"));
   1.544 +			}
   1.545 +		else
   1.546 +			{
   1.547 +			// Check for the default implementation
   1.548 +			// Disables codepage dll implementation of LocaleUtils functions
   1.549 +			r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions);
   1.550 +			test_KErrNone(r);
   1.551 +
   1.552 +			CreateTestDirectory(_L("\\F32-TST\\T_SURROGATEPAIR\\"));
   1.553 +
   1.554 +			TestVolumeLabel();
   1.555 +			TestShortNameCharacter();
   1.556 +			TestConsistentShortNameGeneration();
   1.557 +			TestConsistentShortNameExtGeneration();
   1.558 +			TestDuplicateLongFileNames();
   1.559 +			TestDuplicateLongDirNames();
   1.560 +
   1.561 +			DeleteTestDirectory();
   1.562 +
   1.563 +			// Disables codepage dll implementation of LocaleUtils functions for other base tests
   1.564 +			r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions);
   1.565 +			test_KErrNone(r);
   1.566 +			}
   1.567 +		}
   1.568 +	else
   1.569 +		{
   1.570 +		test.Printf(_L("Drive %C: is not ready!"), 'A'+driveNum);
   1.571 +		test(EFalse);
   1.572 +		}
   1.573 +#else
   1.574 +	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   1.575 +#endif  // _DEBUG) || _DEBUG_RELEASE
   1.576 +	test.End();
   1.577 +	}