os/kernelhwsrv/kerneltest/f32test/outsideBMP/src/t_surrogatepair.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// f32test\locl\localeutils\T_SURROGATEPAIR.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#define __E32TEST_EXTENSION__
sl@0
    19
sl@0
    20
#include <e32test.h>
sl@0
    21
#include <HAL.H>
sl@0
    22
#include <f32fsys.h>
sl@0
    23
#include <f32dbg.h>
sl@0
    24
#include "..\server\t_server.h"
sl@0
    25
sl@0
    26
RTest test(_L("T_SURROGATEPAIR"));
sl@0
    27
sl@0
    28
/* 
sl@0
    29
 * Helper function to capture and return any MakeFile error code.
sl@0
    30
 */
sl@0
    31
TInt SurrogatePair_MakeFile(const TDesC& aFileName)
sl@0
    32
	{
sl@0
    33
	RFile file;
sl@0
    34
	TInt r=file.Replace(TheFs,aFileName,0);
sl@0
    35
	file.Close();
sl@0
    36
	return r;
sl@0
    37
	}
sl@0
    38
sl@0
    39
/*
sl@0
    40
 *  Tests given ShortName against LongName and vice versa for a File Entry.
sl@0
    41
 */
sl@0
    42
void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName)
sl@0
    43
	{
sl@0
    44
	TFileName lgnFullPath;
sl@0
    45
	TFileName shnFullPath;
sl@0
    46
	TFileName lgn;
sl@0
    47
	TFileName shn;
sl@0
    48
sl@0
    49
	TInt r = TheFs.SessionPath(gSessionPath);
sl@0
    50
	test_KErrNone(r);
sl@0
    51
	lgnFullPath = gSessionPath;
sl@0
    52
	lgnFullPath += aLongName;
sl@0
    53
sl@0
    54
	MakeFile(lgnFullPath);
sl@0
    55
sl@0
    56
	// Check short name	
sl@0
    57
	r = TheFs.GetShortName(lgnFullPath, shn);
sl@0
    58
	test_KErrNone(r);
sl@0
    59
	r = shn.Compare(aShortName);
sl@0
    60
	test(r==0);
sl@0
    61
sl@0
    62
	// Check long name	
sl@0
    63
	shnFullPath = gSessionPath;
sl@0
    64
	shnFullPath += aShortName;
sl@0
    65
sl@0
    66
	r = TheFs.GetLongName(shnFullPath, lgn);
sl@0
    67
	test_KErrNone(r);
sl@0
    68
	r = lgn.Compare(aLongName);
sl@0
    69
	test(r==0);
sl@0
    70
sl@0
    71
	test_KErrNone(TheFs.Delete(lgnFullPath));
sl@0
    72
	}
sl@0
    73
sl@0
    74
/*
sl@0
    75
 *  Tests given ShortName against LongName and vice versa for a Directory Entry.
sl@0
    76
 */
sl@0
    77
void doDirNameTest(const TDesC& aLongName, const TDesC& aShortName)
sl@0
    78
	{
sl@0
    79
	TBuf<KMaxFileName> longDirNamePath;
sl@0
    80
	TBuf<KMaxFileName> shortDirNamePath;
sl@0
    81
	TBuf<KMaxFileName> longName;
sl@0
    82
	TBuf<KMaxFileName> shortName;
sl@0
    83
	longDirNamePath = gSessionPath;
sl@0
    84
	longDirNamePath += aLongName;
sl@0
    85
	longDirNamePath.Append('\\');
sl@0
    86
sl@0
    87
	// Create new directory and check creation
sl@0
    88
	TInt r = TheFs.MkDir(longDirNamePath);
sl@0
    89
	test_KErrNone(r);
sl@0
    90
	TUint dumUint=0;
sl@0
    91
	CDir* dumDir;
sl@0
    92
	r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir);
sl@0
    93
	test_KErrNone(r);
sl@0
    94
	test_NotNull(dumDir);
sl@0
    95
	delete dumDir;
sl@0
    96
sl@0
    97
	// Check short name
sl@0
    98
	r = TheFs.GetShortName(longDirNamePath, shortName);
sl@0
    99
	test_KErrNone(r);
sl@0
   100
	r = shortName.Compare(aShortName);
sl@0
   101
	test(r==0);
sl@0
   102
	
sl@0
   103
	// Check long name
sl@0
   104
	shortDirNamePath = gSessionPath;
sl@0
   105
	shortDirNamePath += shortName;
sl@0
   106
	shortDirNamePath.Append('\\');
sl@0
   107
	r = TheFs.GetLongName(shortDirNamePath, longName);
sl@0
   108
	test_KErrNone(r);
sl@0
   109
	r = longName.Compare(aLongName);
sl@0
   110
	test(r==0);
sl@0
   111
sl@0
   112
	r = TheFs.RmDir(longDirNamePath);
sl@0
   113
	test_KErrNone(r);
sl@0
   114
	}
sl@0
   115
sl@0
   116
/*
sl@0
   117
 *  Tests File entry and Dir entry.
sl@0
   118
 */
sl@0
   119
void TestConversion(const TDesC& aLongName, const TDesC& aShortName)
sl@0
   120
	{
sl@0
   121
	doFileNameTest(aLongName, aShortName);
sl@0
   122
	doDirNameTest(aLongName, aShortName);
sl@0
   123
	}
sl@0
   124
sl@0
   125
/*
sl@0
   126
 * Tests different characters for its validity and conversion in absence of cp dll.
sl@0
   127
 * Expects ReplacementForUnconvertibleUnicodeCharacters : "_" : UNDERSCORE for all
sl@0
   128
 * Illegal Characters
sl@0
   129
 */
sl@0
   130
void TestShortNameCharacter()
sl@0
   131
	{
sl@0
   132
	test.Next(_L("++TestShortNameCharacter"));
sl@0
   133
	TInt r;
sl@0
   134
	
sl@0
   135
	// one-byte chars
sl@0
   136
	_LIT16(Uni_1, 									"\x0019.TXT");
sl@0
   137
	_LIT16(Uni_1_ShortName, 						"_.TXT");
sl@0
   138
	TestConversion( Uni_1, Uni_1_ShortName);
sl@0
   139
	
sl@0
   140
	_LIT16(Uni_2, 									"\x0020.TXT");
sl@0
   141
	_LIT(Uni_2_ShortName, 							"_.TXT");
sl@0
   142
	TestConversion( Uni_2, Uni_2_ShortName);
sl@0
   143
	
sl@0
   144
	_LIT16(Uni_3, 									"\x0021.TXT");
sl@0
   145
	_LIT16(Uni_3_ShortName, 						"\x0021.TXT");
sl@0
   146
	TestConversion( Uni_3, Uni_3_ShortName);
sl@0
   147
sl@0
   148
 	_LIT16(Uni_4, 									"\x0079"); // y lower case 
sl@0
   149
	_LIT16(Uni_4_ShortName, 						"\x0059");	// Y upper case
sl@0
   150
	TestConversion( Uni_4, Uni_4_ShortName);
sl@0
   151
sl@0
   152
	_LIT16(Uni_5,									"\x0080");
sl@0
   153
	_LIT16(Uni_5_ShortName, 						"_");
sl@0
   154
	TestConversion( Uni_5, Uni_5_ShortName);
sl@0
   155
sl@0
   156
	_LIT16(Uni_6,									"\x0081");
sl@0
   157
	_LIT16(Uni_6_ShortName, 						"_");
sl@0
   158
	TestConversion( Uni_6, Uni_6_ShortName);
sl@0
   159
sl@0
   160
	_LIT16(Uni_7, 									"\x00fe");
sl@0
   161
	_LIT16(Uni_7_ShortName, 						"_");
sl@0
   162
	TestConversion( Uni_7, Uni_7_ShortName);
sl@0
   163
sl@0
   164
	_LIT16(Uni_8, 									"\x00ff");
sl@0
   165
	_LIT16(Uni_8_ShortName, 						"_");
sl@0
   166
	TestConversion( Uni_8, Uni_8_ShortName);
sl@0
   167
	
sl@0
   168
	// two-byte chars
sl@0
   169
	_LIT16(Uni_9, 									"\x0100");
sl@0
   170
	_LIT16(Uni_9_ShortName, 						"_");
sl@0
   171
	TestConversion( Uni_9, Uni_9_ShortName);
sl@0
   172
sl@0
   173
	_LIT16(Uni_10, 									"\x0101");
sl@0
   174
	_LIT16(Uni_10_ShortName, 						"_");
sl@0
   175
	TestConversion( Uni_10, Uni_10_ShortName);
sl@0
   176
sl@0
   177
	_LIT16(Uni_11, 									"\x0ffe");
sl@0
   178
	_LIT16(Uni_11_ShortName, 						"_");
sl@0
   179
	TestConversion( Uni_11, Uni_11_ShortName);
sl@0
   180
sl@0
   181
	_LIT16(Uni_12, 									"\x0fff");
sl@0
   182
	_LIT16(Uni_12_ShortName,						"_");
sl@0
   183
	TestConversion( Uni_12, Uni_12_ShortName);
sl@0
   184
sl@0
   185
	_LIT16(Uni_13, 									"\x1000");
sl@0
   186
	_LIT16(Uni_13_ShortName, 						"_");
sl@0
   187
	TestConversion( Uni_13, Uni_13_ShortName);
sl@0
   188
sl@0
   189
	_LIT16(Uni_14, 									"\x1001");
sl@0
   190
	_LIT16(Uni_14_ShortName, 						"_");
sl@0
   191
	TestConversion( Uni_14, Uni_14_ShortName);
sl@0
   192
sl@0
   193
	_LIT16(Uni_15, 									"\x2999.TXT");
sl@0
   194
	_LIT16(Uni_15_ShortName, 						"_.TXT");
sl@0
   195
	TestConversion( Uni_15, Uni_15_ShortName);
sl@0
   196
sl@0
   197
	_LIT16(Uni_16, 									"\x4E02.TXT");	
sl@0
   198
	_LIT16(Uni_16_ShortName, 						"_.TXT");
sl@0
   199
	TestConversion( Uni_16, Uni_16_ShortName);
sl@0
   200
sl@0
   201
	_LIT16(Uni_17, 									"\x4E02.TXT");	
sl@0
   202
	_LIT(Uni_17_ShortName, 							"_.TXT");
sl@0
   203
	TestConversion( Uni_17, Uni_17_ShortName);
sl@0
   204
sl@0
   205
	_LIT16(Uni_18, 									"\xfffe");
sl@0
   206
	_LIT16(Uni_18_ShortName, 						"_");
sl@0
   207
	TestConversion( Uni_18, Uni_18_ShortName);
sl@0
   208
sl@0
   209
	_LIT16(Uni_19, 									"\xffff");
sl@0
   210
	_LIT16(Uni_19_ShortName, 						"_");
sl@0
   211
	TestConversion( Uni_19, Uni_19_ShortName);
sl@0
   212
sl@0
   213
	// four-byte surrogate pairs
sl@0
   214
	_LIT16(Uni_20, 									"\xd840\xdc00");
sl@0
   215
	_LIT16(Uni_20_ShortName, 						"_");
sl@0
   216
	TestConversion( Uni_20, Uni_20_ShortName);	
sl@0
   217
sl@0
   218
	_LIT16(Uni_21, 									"\xd840\xdc01");
sl@0
   219
	_LIT16(Uni_21_ShortName, 						"_");
sl@0
   220
	TestConversion( Uni_21, Uni_21_ShortName);	
sl@0
   221
sl@0
   222
	_LIT16(Uni_22, 									"\xD87F\xdffe");
sl@0
   223
	_LIT16(Uni_22_ShortName, 						"_");
sl@0
   224
	TestConversion( Uni_22, Uni_22_ShortName);	
sl@0
   225
sl@0
   226
	_LIT16(Uni_23, 									"\xD87F\xdfff");
sl@0
   227
	_LIT16(Uni_23_ShortName, 						"_");
sl@0
   228
	TestConversion( Uni_23, Uni_23_ShortName);	
sl@0
   229
sl@0
   230
	//	surrogate pair
sl@0
   231
	_LIT16(Uni_24, 									"\xd840\xddad");
sl@0
   232
	_LIT16(Uni_24_ShortName, 						"_");
sl@0
   233
	TestConversion( Uni_24, Uni_24_ShortName);	
sl@0
   234
	
sl@0
   235
	_LIT16(Uni_25, 									"\xd801\xdd00");
sl@0
   236
	_LIT16(Uni_25_ShortName, 						"_");
sl@0
   237
	TestConversion( Uni_25, Uni_25_ShortName);
sl@0
   238
sl@0
   239
	// corrupt surrogate in file name
sl@0
   240
	_LIT16(KTest0xD800, 							"\xD800.TXT");
sl@0
   241
	r = SurrogatePair_MakeFile(KTest0xD800);
sl@0
   242
	test(r==KErrBadName);
sl@0
   243
sl@0
   244
	// corrupt surrogate in file ext
sl@0
   245
	_LIT16(KTest0xD800XT, 							"\xD684.\xD800XT");
sl@0
   246
	r = SurrogatePair_MakeFile(KTest0xD800XT);
sl@0
   247
	test(r==KErrBadName);
sl@0
   248
sl@0
   249
	// corrupt surrogate in file ext
sl@0
   250
	_LIT16(KTestTX0xD800, 							"\xD684.TX\xD800");
sl@0
   251
	r = SurrogatePair_MakeFile(KTestTX0xD800);
sl@0
   252
	test(r==KErrBadName);
sl@0
   253
sl@0
   254
	// corrupt surrogate in file name
sl@0
   255
	_LIT16(KTest0xDFFF, 							"\xDFFF.TXT");
sl@0
   256
	r = SurrogatePair_MakeFile(KTest0xDFFF);
sl@0
   257
	test(r==KErrBadName);
sl@0
   258
sl@0
   259
	// corrupt surrogate in file ext
sl@0
   260
	_LIT16(KTest0xDFFFXT, 							"\xD684.\xDFFFXT");
sl@0
   261
	r = SurrogatePair_MakeFile(KTest0xDFFFXT);
sl@0
   262
	test(r==KErrBadName);
sl@0
   263
sl@0
   264
	// corrupt surrogate in file ext
sl@0
   265
	_LIT16(KTestTX0xDFFF, 							"\xD684.TX\xDFFF");
sl@0
   266
	r = SurrogatePair_MakeFile(KTestTX0xDFFF);
sl@0
   267
	test(r==KErrBadName);
sl@0
   268
sl@0
   269
	test.Next(_L("--TestShortNameCharacter"));
sl@0
   270
	}
sl@0
   271
sl@0
   272
void TestVolumeLabel()
sl@0
   273
	{
sl@0
   274
	test.Next(_L("++TestVolumeLabel"));
sl@0
   275
	test.Next(_L("Test unicode volume labels"));
sl@0
   276
sl@0
   277
	TInt r = TheFs.SessionPath(gSessionPath);
sl@0
   278
	test_KErrNone(r);
sl@0
   279
	TInt driveNum;
sl@0
   280
	r = TheFs.CharToDrive(gSessionPath[0], driveNum);
sl@0
   281
	test_KErrNone(r);
sl@0
   282
	
sl@0
   283
	// Retrieves the original volume label
sl@0
   284
	TVolumeInfo vInfo;
sl@0
   285
	r = TheFs.Volume(vInfo, driveNum);
sl@0
   286
	const TInt KVolumeLabelSize = 11;
sl@0
   287
	TBuf<KVolumeLabelSize> originalVolumeLabel(vInfo.iName);
sl@0
   288
sl@0
   289
	// Tests setting volume label with 1 byte characters
sl@0
   290
	_LIT(K1ByteVolumeLabel, 				"\x0079\x0079\x0079");
sl@0
   291
	_LIT(K1ByteVolumeLabel_ShortName, 		"\x0079\x0079\x0079");
sl@0
   292
	
sl@0
   293
	r = TheFs.SetVolumeLabel(K1ByteVolumeLabel, driveNum);
sl@0
   294
	test_KErrNone(r);
sl@0
   295
	r = TheFs.Volume(vInfo, driveNum);
sl@0
   296
	test_KErrNone(r);
sl@0
   297
	r = vInfo.iName.Compare(K1ByteVolumeLabel_ShortName);
sl@0
   298
	test_Equal(r, 0);
sl@0
   299
	
sl@0
   300
	// Tests setting volume label with 2 byte characters
sl@0
   301
	_LIT(K2ByteVolumeLabel, 				"\x65B0\x65B0\x65B0");
sl@0
   302
	_LIT(K2ByteVolumeLabel_ShortName, 		"___");
sl@0
   303
sl@0
   304
	r = TheFs.SetVolumeLabel(K2ByteVolumeLabel, driveNum);
sl@0
   305
	test_KErrNone(r);
sl@0
   306
	r = TheFs.Volume(vInfo, driveNum);
sl@0
   307
	test_KErrNone(r);
sl@0
   308
	r = vInfo.iName.Compare(K2ByteVolumeLabel_ShortName);
sl@0
   309
	test_Equal(r, 0);
sl@0
   310
sl@0
   311
	// Tests setting volume label with surrogate pair
sl@0
   312
	_LIT(KTestVolumeLabelSurrogatePair1, 			"\xD846\xDF1D\x0041\x0042");
sl@0
   313
	_LIT(KTestVolumeLabelSurrogatePair1_ShortName,	"_AB");
sl@0
   314
sl@0
   315
	r = TheFs.SetVolumeLabel(KTestVolumeLabelSurrogatePair1, driveNum);
sl@0
   316
	test_KErrNone(r);
sl@0
   317
	r = TheFs.Volume(vInfo, driveNum);
sl@0
   318
	test_KErrNone(r);
sl@0
   319
	r = vInfo.iName.Compare(KTestVolumeLabelSurrogatePair1_ShortName);
sl@0
   320
	test_Equal(r, 0);
sl@0
   321
sl@0
   322
	_LIT(KTestVolumeLabelSurrogatePair2, 			"\x0041\x0042\xD846\xDF1D");
sl@0
   323
	_LIT(KTestVolumeLabelSurrogatePair2_ShortName,	"AB_");
sl@0
   324
sl@0
   325
	r = TheFs.SetVolumeLabel(KTestVolumeLabelSurrogatePair2, driveNum);
sl@0
   326
	test_KErrNone(r);
sl@0
   327
	r = TheFs.Volume(vInfo, driveNum);
sl@0
   328
	test_KErrNone(r);
sl@0
   329
	r = vInfo.iName.Compare(KTestVolumeLabelSurrogatePair2_ShortName);
sl@0
   330
	test_Equal(r, 0);
sl@0
   331
sl@0
   332
	// Sets back the original volume label
sl@0
   333
	r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum);
sl@0
   334
	test_KErrNone(r);
sl@0
   335
	
sl@0
   336
	test.Next(_L("--TestVolumeLabel"));
sl@0
   337
	}
sl@0
   338
sl@0
   339
void TestConsistentShortNameGeneration()
sl@0
   340
	{
sl@0
   341
	test.Next(_L("++TestConsistentShortNameGeneration"));
sl@0
   342
	test.Next(_L("Test consistent short name generation"));
sl@0
   343
sl@0
   344
	//unicode characters.
sl@0
   345
	_LIT(KTestFileName1,		 				"a\x65B0(bcd)");
sl@0
   346
	_LIT(KTestFileName1_ShortName,	 			"A_(BCD)");
sl@0
   347
	_LIT(KTestFileName2, 						"ab\x65B0(cdef)");
sl@0
   348
	_LIT(KTestFileName2_ShortName,				"AB_(CD~1");
sl@0
   349
	_LIT(KTestFileName3, 						"abc\x65B0(def)");
sl@0
   350
	_LIT(KTestFileName3_ShortName,				"ABC_(D~1");
sl@0
   351
	_LIT(KTestFileName4, 						"abcd\x65B0(ef)");
sl@0
   352
	_LIT(KTestFileName4_ShortName,				"ABCD_(~1");
sl@0
   353
	_LIT(KTestFileName5, 						"abcde\x65B0(f)");
sl@0
   354
	_LIT(KTestFileName5_ShortName,				"ABCDE_~1");
sl@0
   355
	_LIT(KTestFileNameSurrogatePair1, 			"\x0041\x0308\x006F\xD846\xDF1D\x0042");
sl@0
   356
	_LIT(KTestFileNameSurrogatePair1_ShortName,	"A_O_B");
sl@0
   357
	_LIT(KTestFileNameSurrogatePair2, 			"\xD846\xDF1D\x0041\x0042");
sl@0
   358
	_LIT(KTestFileNameSurrogatePair2_ShortName,	"_AB");
sl@0
   359
	_LIT(KTestFileNameSurrogatePair3, 			"\x0041\x0042\xD846\xDF1D");
sl@0
   360
	_LIT(KTestFileNameSurrogatePair3_ShortName,	"AB_");
sl@0
   361
sl@0
   362
	// Test file creation and long/short name generation
sl@0
   363
	TestConversion(KTestFileName1,				KTestFileName1_ShortName);
sl@0
   364
	TestConversion(KTestFileName2, 				KTestFileName2_ShortName);
sl@0
   365
	TestConversion(KTestFileName3, 				KTestFileName3_ShortName);
sl@0
   366
	TestConversion(KTestFileName4, 				KTestFileName4_ShortName);
sl@0
   367
	TestConversion(KTestFileName5, 				KTestFileName5_ShortName);
sl@0
   368
	TestConversion(KTestFileNameSurrogatePair1,	KTestFileNameSurrogatePair1_ShortName);
sl@0
   369
	TestConversion(KTestFileNameSurrogatePair2,	KTestFileNameSurrogatePair2_ShortName);
sl@0
   370
	TestConversion(KTestFileNameSurrogatePair3,	KTestFileNameSurrogatePair3_ShortName);
sl@0
   371
sl@0
   372
	test.Next(_L("--TestConsistentShortNameGeneration"));
sl@0
   373
	}
sl@0
   374
sl@0
   375
void TestConsistentShortNameExtGeneration()
sl@0
   376
	{
sl@0
   377
	test.Next(_L("++TestConsistentShortNameExtGeneration"));
sl@0
   378
	test.Next(_L("Test consistent short name extensions are generated"));
sl@0
   379
	
sl@0
   380
	// File names will be used for testing boundaries
sl@0
   381
	_LIT(KTestFileNameExt1, 						"abcdefg.\xFFFF");
sl@0
   382
	_LIT(KTestFileNameExt1_ShortName,				"ABCDEFG._");
sl@0
   383
	_LIT(KTestFileNameExt2, 						"abcdefg.t_");
sl@0
   384
	_LIT(KTestFileNameExt2_ShortName, 				"ABCDEFG.T_");
sl@0
   385
	_LIT(KTestFileNameExt3, 						"abcdefg.\xFFFFt");
sl@0
   386
	_LIT(KTestFileNameExt3_ShortName,				"ABCDEFG._T");
sl@0
   387
	_LIT(KTestFileNameExt4, 						"abcdefg.\xFFFF\xFFFF");
sl@0
   388
	_LIT(KTestFileNameExt4_ShortName,				"ABCDEFG.__");
sl@0
   389
	_LIT(KTestFileNameExtSurrogatePair1, 			"ABCDEFG.\xD846\xDF1D\x0041");
sl@0
   390
	_LIT(KTestFileNameExtSurrogatePair1_ShortName,	"ABCDEFG._A");
sl@0
   391
	_LIT(KTestFileNameExtSurrogatePair2, 			"ABCDEFG.\x0041\xD846\xDF1D");
sl@0
   392
	_LIT(KTestFileNameExtSurrogatePair2_ShortName,	"ABCDEFG.A_");
sl@0
   393
sl@0
   394
	// Test file creation and long/short name generation
sl@0
   395
	TestConversion(KTestFileNameExt1, 				KTestFileNameExt1_ShortName);
sl@0
   396
	TestConversion(KTestFileNameExt2, 				KTestFileNameExt2_ShortName);
sl@0
   397
	TestConversion(KTestFileNameExt3, 				KTestFileNameExt3_ShortName);
sl@0
   398
	TestConversion(KTestFileNameExt4, 				KTestFileNameExt4_ShortName);
sl@0
   399
	TestConversion(KTestFileNameExtSurrogatePair1, 	KTestFileNameExtSurrogatePair1_ShortName);
sl@0
   400
	TestConversion(KTestFileNameExtSurrogatePair2, 	KTestFileNameExtSurrogatePair2_ShortName);
sl@0
   401
sl@0
   402
	test.Next(_L("--TestConsistentShortNameExtGeneration"));
sl@0
   403
	}
sl@0
   404
sl@0
   405
void TestDuplicateLongFileNames()
sl@0
   406
	{
sl@0
   407
	test.Next(_L("++TestDuplicateLongFileNames"));
sl@0
   408
	test.Next(_L("Testing tilde and numbers (\"~n\") are applied correctly for multiple long-named files"));
sl@0
   409
sl@0
   410
	// These are to test "~1", "~2" behaviours when the first 8 bytes of new files
sl@0
   411
	// are identical with existing files
sl@0
   412
	_LIT(KTestFileName1, 							"ABCD\xFFFE(A).TXT");
sl@0
   413
	_LIT(KTestFileName1_ShortName, 					"ABCD_(A).TXT");
sl@0
   414
	_LIT(KTestFileName2, 							"ABCD\xFFFE(AB).TXT");
sl@0
   415
	_LIT(KTestFileName2_ShortName, 					"ABCD_(~1.TXT");
sl@0
   416
	_LIT(KTestFileName3, 							"ABCD\xFFFE(ABC).TXT");
sl@0
   417
	_LIT(KTestFileName3_ShortName, 					"ABCD_(~2.TXT");
sl@0
   418
	_LIT(KTestFileNameSurrogatePair1, 				"ABCD\xD846\xDF1D(ABC).TXT");
sl@0
   419
	_LIT(KTestFileNameSurrogatePair1_ShortName,		"ABCD_(~3.TXT");
sl@0
   420
	_LIT(KTestFileNameSurrogatePair2, 				"ABCD\xD846\xDF1D(DEF).TXT");
sl@0
   421
	_LIT(KTestFileNameSurrogatePair2_ShortName,		"ABCD_(~4.TXT");
sl@0
   422
sl@0
   423
	TFileName sn;
sl@0
   424
	MakeFile(KTestFileName1);
sl@0
   425
	TInt r = TheFs.GetShortName(KTestFileName1, sn);
sl@0
   426
	test_KErrNone(r);
sl@0
   427
	r = sn.Compare(KTestFileName1_ShortName);
sl@0
   428
	test_Equal(r, 0);
sl@0
   429
sl@0
   430
	MakeFile(KTestFileName2);
sl@0
   431
	r = TheFs.GetShortName(KTestFileName2, sn);
sl@0
   432
	test_KErrNone(r);
sl@0
   433
	r = sn.Compare(KTestFileName2_ShortName);
sl@0
   434
	test_Equal(r, 0);
sl@0
   435
sl@0
   436
	MakeFile(KTestFileName3);
sl@0
   437
	r = TheFs.GetShortName(KTestFileName3, sn);
sl@0
   438
	test_KErrNone(r);
sl@0
   439
	r = sn.Compare(KTestFileName3_ShortName);
sl@0
   440
	test_Equal(r, 0);
sl@0
   441
sl@0
   442
	MakeFile(KTestFileNameSurrogatePair1);
sl@0
   443
	r = TheFs.GetShortName(KTestFileNameSurrogatePair1, sn);
sl@0
   444
	test_KErrNone(r);
sl@0
   445
	r = sn.Compare(KTestFileNameSurrogatePair1_ShortName);
sl@0
   446
	test_Equal(r, 0);
sl@0
   447
sl@0
   448
	MakeFile(KTestFileNameSurrogatePair2);
sl@0
   449
	r = TheFs.GetShortName(KTestFileNameSurrogatePair2, sn);
sl@0
   450
	test_KErrNone(r);
sl@0
   451
	r = sn.Compare(KTestFileNameSurrogatePair2_ShortName);
sl@0
   452
	test_Equal(r, 0);
sl@0
   453
sl@0
   454
	test_KErrNone(TheFs.Delete(KTestFileName1));
sl@0
   455
	test_KErrNone(TheFs.Delete(KTestFileName2));
sl@0
   456
	test_KErrNone(TheFs.Delete(KTestFileName3));
sl@0
   457
	test_KErrNone(TheFs.Delete(KTestFileNameSurrogatePair1));
sl@0
   458
	test_KErrNone(TheFs.Delete(KTestFileNameSurrogatePair2));
sl@0
   459
sl@0
   460
	test.Next(_L("--TestDuplicateLongFileNames"));
sl@0
   461
	}
sl@0
   462
sl@0
   463
void TestDuplicateLongDirNames()
sl@0
   464
	{
sl@0
   465
	test.Next(_L("++TestDuplicateLongDirNames"));
sl@0
   466
	test.Next(_L("Testing tilde and number appended correctly for duplicate long name dirs"));
sl@0
   467
sl@0
   468
	TheFs.SessionPath(gSessionPath);
sl@0
   469
sl@0
   470
	// These are to test "~1", "~2" behaviours when the first 8 bytes of new directories
sl@0
   471
	// are identical with existing directories
sl@0
   472
	_LIT(KTestDirName1, 							"\\F32-TST\\T_SURROGATEPAIR\\ABCD\xFFFE(A)\\");
sl@0
   473
	_LIT(KTestDirName1_ShortName, 					"ABCD_(A)");
sl@0
   474
	_LIT(KTestDirName2, 							"\\F32-TST\\T_SURROGATEPAIR\\ABCD\xFFFE(AB)\\");
sl@0
   475
	_LIT(KTestDirName2_ShortName, 					"ABCD_(~1");
sl@0
   476
	_LIT(KTestDirName3, 							"\\F32-TST\\T_SURROGATEPAIR\\ABCD\xFFFE(ABC)\\");
sl@0
   477
	_LIT(KTestDirName3_ShortName,				 	"ABCD_(~2");
sl@0
   478
	_LIT(KTestDirNameSurrogatePair1, 				"\\F32-TST\\T_SURROGATEPAIR\\ABCD\xD846\xDF1D(ABCD)\\");
sl@0
   479
	_LIT(KTestDirNameSurrogatePair1_ShortName,		"ABCD_(~3");
sl@0
   480
	_LIT(KTestDirNameSurrogatePair2, 				"\\F32-TST\\T_SURROGATEPAIR\\ABCD\xD846\xDF1D(ABCDE)\\");
sl@0
   481
	_LIT(KTestDirNameSurrogatePair2_ShortName,		"ABCD_(~4");
sl@0
   482
sl@0
   483
	TFileName sn;
sl@0
   484
	MakeDir(KTestDirName1);
sl@0
   485
	TInt r = TheFs.GetShortName(KTestDirName1, sn);
sl@0
   486
	test_KErrNone(r);
sl@0
   487
	r = sn.Compare(KTestDirName1_ShortName);
sl@0
   488
	test_Equal(r, 0);
sl@0
   489
sl@0
   490
	MakeDir(KTestDirName2);
sl@0
   491
	r = TheFs.GetShortName(KTestDirName2, sn);
sl@0
   492
	test_KErrNone(r);
sl@0
   493
	r = sn.Compare(KTestDirName2_ShortName);
sl@0
   494
	test_Equal(r, 0);
sl@0
   495
sl@0
   496
	MakeDir(KTestDirName3);
sl@0
   497
	r = TheFs.GetShortName(KTestDirName3, sn);
sl@0
   498
	test_KErrNone(r);
sl@0
   499
	r = sn.Compare(KTestDirName3_ShortName);
sl@0
   500
	test_Equal(r, 0);
sl@0
   501
sl@0
   502
	MakeDir(KTestDirNameSurrogatePair1);
sl@0
   503
	r = TheFs.GetShortName(KTestDirNameSurrogatePair1, sn);
sl@0
   504
	test_KErrNone(r);
sl@0
   505
	r = sn.Compare(KTestDirNameSurrogatePair1_ShortName);
sl@0
   506
	test_Equal(r, 0);
sl@0
   507
sl@0
   508
	MakeDir(KTestDirNameSurrogatePair2);
sl@0
   509
	r = TheFs.GetShortName(KTestDirNameSurrogatePair2, sn);
sl@0
   510
	test_KErrNone(r);
sl@0
   511
	r = sn.Compare(KTestDirNameSurrogatePair2_ShortName);
sl@0
   512
	test_Equal(r, 0);
sl@0
   513
sl@0
   514
	test_KErrNone(TheFs.RmDir(KTestDirName1));
sl@0
   515
	test_KErrNone(TheFs.RmDir(KTestDirName2));
sl@0
   516
	test_KErrNone(TheFs.RmDir(KTestDirName3));
sl@0
   517
	test_KErrNone(TheFs.RmDir(KTestDirNameSurrogatePair1));
sl@0
   518
	test_KErrNone(TheFs.RmDir(KTestDirNameSurrogatePair2));
sl@0
   519
sl@0
   520
	test.Next(_L("--TestDuplicateLongDirNames"));
sl@0
   521
	}
sl@0
   522
sl@0
   523
void CallTestsL(void)
sl@0
   524
	{
sl@0
   525
sl@0
   526
	test.Title();
sl@0
   527
	test.Start(_L("Starting T_SURROGATEPAIR tests"));
sl@0
   528
sl@0
   529
#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
sl@0
   530
sl@0
   531
	// Test only runs on Fat file systems
sl@0
   532
	TheFs.SessionPath(gSessionPath);
sl@0
   533
	TInt driveNum = CurrentDrive();
sl@0
   534
	TFSName name;
sl@0
   535
	TInt r = TheFs.FileSystemName(name, driveNum);
sl@0
   536
	if (KErrNone == r)
sl@0
   537
		{
sl@0
   538
		if (name.Compare(_L("Fat")) != 0)
sl@0
   539
			{
sl@0
   540
			test.Printf(_L("Test only runs on 'Fat' drives"));
sl@0
   541
			}
sl@0
   542
		else
sl@0
   543
			{
sl@0
   544
			// Check for the default implementation
sl@0
   545
			// Disables codepage dll implementation of LocaleUtils functions
sl@0
   546
			r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions);
sl@0
   547
			test_KErrNone(r);
sl@0
   548
sl@0
   549
			CreateTestDirectory(_L("\\F32-TST\\T_SURROGATEPAIR\\"));
sl@0
   550
sl@0
   551
			TestVolumeLabel();
sl@0
   552
			TestShortNameCharacter();
sl@0
   553
			TestConsistentShortNameGeneration();
sl@0
   554
			TestConsistentShortNameExtGeneration();
sl@0
   555
			TestDuplicateLongFileNames();
sl@0
   556
			TestDuplicateLongDirNames();
sl@0
   557
sl@0
   558
			DeleteTestDirectory();
sl@0
   559
sl@0
   560
			// Disables codepage dll implementation of LocaleUtils functions for other base tests
sl@0
   561
			r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions);
sl@0
   562
			test_KErrNone(r);
sl@0
   563
			}
sl@0
   564
		}
sl@0
   565
	else
sl@0
   566
		{
sl@0
   567
		test.Printf(_L("Drive %C: is not ready!"), 'A'+driveNum);
sl@0
   568
		test(EFalse);
sl@0
   569
		}
sl@0
   570
#else
sl@0
   571
	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
sl@0
   572
#endif  // _DEBUG) || _DEBUG_RELEASE
sl@0
   573
	test.End();
sl@0
   574
	}