sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32test\locl\localeutils\T_SURROGATEPAIR.cpp sl@0: // sl@0: // sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "..\server\t_server.h" sl@0: sl@0: RTest test(_L("T_SURROGATEPAIR")); sl@0: sl@0: /* sl@0: * Helper function to capture and return any MakeFile error code. sl@0: */ sl@0: TInt SurrogatePair_MakeFile(const TDesC& aFileName) sl@0: { sl@0: RFile file; sl@0: TInt r=file.Replace(TheFs,aFileName,0); sl@0: file.Close(); sl@0: return r; sl@0: } sl@0: sl@0: /* sl@0: * Tests given ShortName against LongName and vice versa for a File Entry. sl@0: */ sl@0: void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName) sl@0: { sl@0: TFileName lgnFullPath; sl@0: TFileName shnFullPath; sl@0: TFileName lgn; sl@0: TFileName shn; sl@0: sl@0: TInt r = TheFs.SessionPath(gSessionPath); sl@0: test_KErrNone(r); sl@0: lgnFullPath = gSessionPath; sl@0: lgnFullPath += aLongName; sl@0: sl@0: MakeFile(lgnFullPath); sl@0: sl@0: // Check short name sl@0: r = TheFs.GetShortName(lgnFullPath, shn); sl@0: test_KErrNone(r); sl@0: r = shn.Compare(aShortName); sl@0: test(r==0); sl@0: sl@0: // Check long name sl@0: shnFullPath = gSessionPath; sl@0: shnFullPath += aShortName; sl@0: sl@0: r = TheFs.GetLongName(shnFullPath, lgn); sl@0: test_KErrNone(r); sl@0: r = lgn.Compare(aLongName); sl@0: test(r==0); sl@0: sl@0: test_KErrNone(TheFs.Delete(lgnFullPath)); sl@0: } sl@0: sl@0: /* sl@0: * Tests given ShortName against LongName and vice versa for a Directory Entry. sl@0: */ sl@0: void doDirNameTest(const TDesC& aLongName, const TDesC& aShortName) sl@0: { sl@0: TBuf longDirNamePath; sl@0: TBuf shortDirNamePath; sl@0: TBuf longName; sl@0: TBuf shortName; sl@0: longDirNamePath = gSessionPath; sl@0: longDirNamePath += aLongName; sl@0: longDirNamePath.Append('\\'); sl@0: sl@0: // Create new directory and check creation sl@0: TInt r = TheFs.MkDir(longDirNamePath); sl@0: test_KErrNone(r); sl@0: TUint dumUint=0; sl@0: CDir* dumDir; sl@0: r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir); sl@0: test_KErrNone(r); sl@0: test_NotNull(dumDir); sl@0: delete dumDir; sl@0: sl@0: // Check short name sl@0: r = TheFs.GetShortName(longDirNamePath, shortName); sl@0: test_KErrNone(r); sl@0: r = shortName.Compare(aShortName); sl@0: test(r==0); sl@0: sl@0: // Check long name sl@0: shortDirNamePath = gSessionPath; sl@0: shortDirNamePath += shortName; sl@0: shortDirNamePath.Append('\\'); sl@0: r = TheFs.GetLongName(shortDirNamePath, longName); sl@0: test_KErrNone(r); sl@0: r = longName.Compare(aLongName); sl@0: test(r==0); sl@0: sl@0: r = TheFs.RmDir(longDirNamePath); sl@0: test_KErrNone(r); sl@0: } sl@0: sl@0: /* sl@0: * Tests File entry and Dir entry. sl@0: */ sl@0: void TestConversion(const TDesC& aLongName, const TDesC& aShortName) sl@0: { sl@0: doFileNameTest(aLongName, aShortName); sl@0: doDirNameTest(aLongName, aShortName); sl@0: } sl@0: sl@0: /* sl@0: * Tests different characters for its validity and conversion in absence of cp dll. sl@0: * Expects ReplacementForUnconvertibleUnicodeCharacters : "_" : UNDERSCORE for all sl@0: * Illegal Characters sl@0: */ sl@0: void TestShortNameCharacter() sl@0: { sl@0: test.Next(_L("++TestShortNameCharacter")); sl@0: TInt r; sl@0: sl@0: // one-byte chars sl@0: _LIT16(Uni_1, "\x0019.TXT"); sl@0: _LIT16(Uni_1_ShortName, "_.TXT"); sl@0: TestConversion( Uni_1, Uni_1_ShortName); sl@0: sl@0: _LIT16(Uni_2, "\x0020.TXT"); sl@0: _LIT(Uni_2_ShortName, "_.TXT"); sl@0: TestConversion( Uni_2, Uni_2_ShortName); sl@0: sl@0: _LIT16(Uni_3, "\x0021.TXT"); sl@0: _LIT16(Uni_3_ShortName, "\x0021.TXT"); sl@0: TestConversion( Uni_3, Uni_3_ShortName); sl@0: sl@0: _LIT16(Uni_4, "\x0079"); // y lower case sl@0: _LIT16(Uni_4_ShortName, "\x0059"); // Y upper case sl@0: TestConversion( Uni_4, Uni_4_ShortName); sl@0: sl@0: _LIT16(Uni_5, "\x0080"); sl@0: _LIT16(Uni_5_ShortName, "_"); sl@0: TestConversion( Uni_5, Uni_5_ShortName); sl@0: sl@0: _LIT16(Uni_6, "\x0081"); sl@0: _LIT16(Uni_6_ShortName, "_"); sl@0: TestConversion( Uni_6, Uni_6_ShortName); sl@0: sl@0: _LIT16(Uni_7, "\x00fe"); sl@0: _LIT16(Uni_7_ShortName, "_"); sl@0: TestConversion( Uni_7, Uni_7_ShortName); sl@0: sl@0: _LIT16(Uni_8, "\x00ff"); sl@0: _LIT16(Uni_8_ShortName, "_"); sl@0: TestConversion( Uni_8, Uni_8_ShortName); sl@0: sl@0: // two-byte chars sl@0: _LIT16(Uni_9, "\x0100"); sl@0: _LIT16(Uni_9_ShortName, "_"); sl@0: TestConversion( Uni_9, Uni_9_ShortName); sl@0: sl@0: _LIT16(Uni_10, "\x0101"); sl@0: _LIT16(Uni_10_ShortName, "_"); sl@0: TestConversion( Uni_10, Uni_10_ShortName); sl@0: sl@0: _LIT16(Uni_11, "\x0ffe"); sl@0: _LIT16(Uni_11_ShortName, "_"); sl@0: TestConversion( Uni_11, Uni_11_ShortName); sl@0: sl@0: _LIT16(Uni_12, "\x0fff"); sl@0: _LIT16(Uni_12_ShortName, "_"); sl@0: TestConversion( Uni_12, Uni_12_ShortName); sl@0: sl@0: _LIT16(Uni_13, "\x1000"); sl@0: _LIT16(Uni_13_ShortName, "_"); sl@0: TestConversion( Uni_13, Uni_13_ShortName); sl@0: sl@0: _LIT16(Uni_14, "\x1001"); sl@0: _LIT16(Uni_14_ShortName, "_"); sl@0: TestConversion( Uni_14, Uni_14_ShortName); sl@0: sl@0: _LIT16(Uni_15, "\x2999.TXT"); sl@0: _LIT16(Uni_15_ShortName, "_.TXT"); sl@0: TestConversion( Uni_15, Uni_15_ShortName); sl@0: sl@0: _LIT16(Uni_16, "\x4E02.TXT"); sl@0: _LIT16(Uni_16_ShortName, "_.TXT"); sl@0: TestConversion( Uni_16, Uni_16_ShortName); sl@0: sl@0: _LIT16(Uni_17, "\x4E02.TXT"); sl@0: _LIT(Uni_17_ShortName, "_.TXT"); sl@0: TestConversion( Uni_17, Uni_17_ShortName); sl@0: sl@0: _LIT16(Uni_18, "\xfffe"); sl@0: _LIT16(Uni_18_ShortName, "_"); sl@0: TestConversion( Uni_18, Uni_18_ShortName); sl@0: sl@0: _LIT16(Uni_19, "\xffff"); sl@0: _LIT16(Uni_19_ShortName, "_"); sl@0: TestConversion( Uni_19, Uni_19_ShortName); sl@0: sl@0: // four-byte surrogate pairs sl@0: _LIT16(Uni_20, "\xd840\xdc00"); sl@0: _LIT16(Uni_20_ShortName, "_"); sl@0: TestConversion( Uni_20, Uni_20_ShortName); sl@0: sl@0: _LIT16(Uni_21, "\xd840\xdc01"); sl@0: _LIT16(Uni_21_ShortName, "_"); sl@0: TestConversion( Uni_21, Uni_21_ShortName); sl@0: sl@0: _LIT16(Uni_22, "\xD87F\xdffe"); sl@0: _LIT16(Uni_22_ShortName, "_"); sl@0: TestConversion( Uni_22, Uni_22_ShortName); sl@0: sl@0: _LIT16(Uni_23, "\xD87F\xdfff"); sl@0: _LIT16(Uni_23_ShortName, "_"); sl@0: TestConversion( Uni_23, Uni_23_ShortName); sl@0: sl@0: // surrogate pair sl@0: _LIT16(Uni_24, "\xd840\xddad"); sl@0: _LIT16(Uni_24_ShortName, "_"); sl@0: TestConversion( Uni_24, Uni_24_ShortName); sl@0: sl@0: _LIT16(Uni_25, "\xd801\xdd00"); sl@0: _LIT16(Uni_25_ShortName, "_"); sl@0: TestConversion( Uni_25, Uni_25_ShortName); sl@0: sl@0: // corrupt surrogate in file name sl@0: _LIT16(KTest0xD800, "\xD800.TXT"); sl@0: r = SurrogatePair_MakeFile(KTest0xD800); sl@0: test(r==KErrBadName); sl@0: sl@0: // corrupt surrogate in file ext sl@0: _LIT16(KTest0xD800XT, "\xD684.\xD800XT"); sl@0: r = SurrogatePair_MakeFile(KTest0xD800XT); sl@0: test(r==KErrBadName); sl@0: sl@0: // corrupt surrogate in file ext sl@0: _LIT16(KTestTX0xD800, "\xD684.TX\xD800"); sl@0: r = SurrogatePair_MakeFile(KTestTX0xD800); sl@0: test(r==KErrBadName); sl@0: sl@0: // corrupt surrogate in file name sl@0: _LIT16(KTest0xDFFF, "\xDFFF.TXT"); sl@0: r = SurrogatePair_MakeFile(KTest0xDFFF); sl@0: test(r==KErrBadName); sl@0: sl@0: // corrupt surrogate in file ext sl@0: _LIT16(KTest0xDFFFXT, "\xD684.\xDFFFXT"); sl@0: r = SurrogatePair_MakeFile(KTest0xDFFFXT); sl@0: test(r==KErrBadName); sl@0: sl@0: // corrupt surrogate in file ext sl@0: _LIT16(KTestTX0xDFFF, "\xD684.TX\xDFFF"); sl@0: r = SurrogatePair_MakeFile(KTestTX0xDFFF); sl@0: test(r==KErrBadName); sl@0: sl@0: test.Next(_L("--TestShortNameCharacter")); sl@0: } sl@0: sl@0: void TestVolumeLabel() sl@0: { sl@0: test.Next(_L("++TestVolumeLabel")); sl@0: test.Next(_L("Test unicode volume labels")); sl@0: sl@0: TInt r = TheFs.SessionPath(gSessionPath); sl@0: test_KErrNone(r); sl@0: TInt driveNum; sl@0: r = TheFs.CharToDrive(gSessionPath[0], driveNum); sl@0: test_KErrNone(r); sl@0: sl@0: // Retrieves the original volume label sl@0: TVolumeInfo vInfo; sl@0: r = TheFs.Volume(vInfo, driveNum); sl@0: const TInt KVolumeLabelSize = 11; sl@0: TBuf originalVolumeLabel(vInfo.iName); sl@0: sl@0: // Tests setting volume label with 1 byte characters sl@0: _LIT(K1ByteVolumeLabel, "\x0079\x0079\x0079"); sl@0: _LIT(K1ByteVolumeLabel_ShortName, "\x0079\x0079\x0079"); sl@0: sl@0: r = TheFs.SetVolumeLabel(K1ByteVolumeLabel, driveNum); sl@0: test_KErrNone(r); sl@0: r = TheFs.Volume(vInfo, driveNum); sl@0: test_KErrNone(r); sl@0: r = vInfo.iName.Compare(K1ByteVolumeLabel_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: // Tests setting volume label with 2 byte characters sl@0: _LIT(K2ByteVolumeLabel, "\x65B0\x65B0\x65B0"); sl@0: _LIT(K2ByteVolumeLabel_ShortName, "___"); sl@0: sl@0: r = TheFs.SetVolumeLabel(K2ByteVolumeLabel, driveNum); sl@0: test_KErrNone(r); sl@0: r = TheFs.Volume(vInfo, driveNum); sl@0: test_KErrNone(r); sl@0: r = vInfo.iName.Compare(K2ByteVolumeLabel_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: // Tests setting volume label with surrogate pair sl@0: _LIT(KTestVolumeLabelSurrogatePair1, "\xD846\xDF1D\x0041\x0042"); sl@0: _LIT(KTestVolumeLabelSurrogatePair1_ShortName, "_AB"); sl@0: sl@0: r = TheFs.SetVolumeLabel(KTestVolumeLabelSurrogatePair1, driveNum); sl@0: test_KErrNone(r); sl@0: r = TheFs.Volume(vInfo, driveNum); sl@0: test_KErrNone(r); sl@0: r = vInfo.iName.Compare(KTestVolumeLabelSurrogatePair1_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: _LIT(KTestVolumeLabelSurrogatePair2, "\x0041\x0042\xD846\xDF1D"); sl@0: _LIT(KTestVolumeLabelSurrogatePair2_ShortName, "AB_"); sl@0: sl@0: r = TheFs.SetVolumeLabel(KTestVolumeLabelSurrogatePair2, driveNum); sl@0: test_KErrNone(r); sl@0: r = TheFs.Volume(vInfo, driveNum); sl@0: test_KErrNone(r); sl@0: r = vInfo.iName.Compare(KTestVolumeLabelSurrogatePair2_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: // Sets back the original volume label sl@0: r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("--TestVolumeLabel")); sl@0: } sl@0: sl@0: void TestConsistentShortNameGeneration() sl@0: { sl@0: test.Next(_L("++TestConsistentShortNameGeneration")); sl@0: test.Next(_L("Test consistent short name generation")); sl@0: sl@0: //unicode characters. sl@0: _LIT(KTestFileName1, "a\x65B0(bcd)"); sl@0: _LIT(KTestFileName1_ShortName, "A_(BCD)"); sl@0: _LIT(KTestFileName2, "ab\x65B0(cdef)"); sl@0: _LIT(KTestFileName2_ShortName, "AB_(CD~1"); sl@0: _LIT(KTestFileName3, "abc\x65B0(def)"); sl@0: _LIT(KTestFileName3_ShortName, "ABC_(D~1"); sl@0: _LIT(KTestFileName4, "abcd\x65B0(ef)"); sl@0: _LIT(KTestFileName4_ShortName, "ABCD_(~1"); sl@0: _LIT(KTestFileName5, "abcde\x65B0(f)"); sl@0: _LIT(KTestFileName5_ShortName, "ABCDE_~1"); sl@0: _LIT(KTestFileNameSurrogatePair1, "\x0041\x0308\x006F\xD846\xDF1D\x0042"); sl@0: _LIT(KTestFileNameSurrogatePair1_ShortName, "A_O_B"); sl@0: _LIT(KTestFileNameSurrogatePair2, "\xD846\xDF1D\x0041\x0042"); sl@0: _LIT(KTestFileNameSurrogatePair2_ShortName, "_AB"); sl@0: _LIT(KTestFileNameSurrogatePair3, "\x0041\x0042\xD846\xDF1D"); sl@0: _LIT(KTestFileNameSurrogatePair3_ShortName, "AB_"); sl@0: sl@0: // Test file creation and long/short name generation sl@0: TestConversion(KTestFileName1, KTestFileName1_ShortName); sl@0: TestConversion(KTestFileName2, KTestFileName2_ShortName); sl@0: TestConversion(KTestFileName3, KTestFileName3_ShortName); sl@0: TestConversion(KTestFileName4, KTestFileName4_ShortName); sl@0: TestConversion(KTestFileName5, KTestFileName5_ShortName); sl@0: TestConversion(KTestFileNameSurrogatePair1, KTestFileNameSurrogatePair1_ShortName); sl@0: TestConversion(KTestFileNameSurrogatePair2, KTestFileNameSurrogatePair2_ShortName); sl@0: TestConversion(KTestFileNameSurrogatePair3, KTestFileNameSurrogatePair3_ShortName); sl@0: sl@0: test.Next(_L("--TestConsistentShortNameGeneration")); sl@0: } sl@0: sl@0: void TestConsistentShortNameExtGeneration() sl@0: { sl@0: test.Next(_L("++TestConsistentShortNameExtGeneration")); sl@0: test.Next(_L("Test consistent short name extensions are generated")); sl@0: sl@0: // File names will be used for testing boundaries sl@0: _LIT(KTestFileNameExt1, "abcdefg.\xFFFF"); sl@0: _LIT(KTestFileNameExt1_ShortName, "ABCDEFG._"); sl@0: _LIT(KTestFileNameExt2, "abcdefg.t_"); sl@0: _LIT(KTestFileNameExt2_ShortName, "ABCDEFG.T_"); sl@0: _LIT(KTestFileNameExt3, "abcdefg.\xFFFFt"); sl@0: _LIT(KTestFileNameExt3_ShortName, "ABCDEFG._T"); sl@0: _LIT(KTestFileNameExt4, "abcdefg.\xFFFF\xFFFF"); sl@0: _LIT(KTestFileNameExt4_ShortName, "ABCDEFG.__"); sl@0: _LIT(KTestFileNameExtSurrogatePair1, "ABCDEFG.\xD846\xDF1D\x0041"); sl@0: _LIT(KTestFileNameExtSurrogatePair1_ShortName, "ABCDEFG._A"); sl@0: _LIT(KTestFileNameExtSurrogatePair2, "ABCDEFG.\x0041\xD846\xDF1D"); sl@0: _LIT(KTestFileNameExtSurrogatePair2_ShortName, "ABCDEFG.A_"); sl@0: sl@0: // Test file creation and long/short name generation sl@0: TestConversion(KTestFileNameExt1, KTestFileNameExt1_ShortName); sl@0: TestConversion(KTestFileNameExt2, KTestFileNameExt2_ShortName); sl@0: TestConversion(KTestFileNameExt3, KTestFileNameExt3_ShortName); sl@0: TestConversion(KTestFileNameExt4, KTestFileNameExt4_ShortName); sl@0: TestConversion(KTestFileNameExtSurrogatePair1, KTestFileNameExtSurrogatePair1_ShortName); sl@0: TestConversion(KTestFileNameExtSurrogatePair2, KTestFileNameExtSurrogatePair2_ShortName); sl@0: sl@0: test.Next(_L("--TestConsistentShortNameExtGeneration")); sl@0: } sl@0: sl@0: void TestDuplicateLongFileNames() sl@0: { sl@0: test.Next(_L("++TestDuplicateLongFileNames")); sl@0: test.Next(_L("Testing tilde and numbers (\"~n\") are applied correctly for multiple long-named files")); sl@0: sl@0: // These are to test "~1", "~2" behaviours when the first 8 bytes of new files sl@0: // are identical with existing files sl@0: _LIT(KTestFileName1, "ABCD\xFFFE(A).TXT"); sl@0: _LIT(KTestFileName1_ShortName, "ABCD_(A).TXT"); sl@0: _LIT(KTestFileName2, "ABCD\xFFFE(AB).TXT"); sl@0: _LIT(KTestFileName2_ShortName, "ABCD_(~1.TXT"); sl@0: _LIT(KTestFileName3, "ABCD\xFFFE(ABC).TXT"); sl@0: _LIT(KTestFileName3_ShortName, "ABCD_(~2.TXT"); sl@0: _LIT(KTestFileNameSurrogatePair1, "ABCD\xD846\xDF1D(ABC).TXT"); sl@0: _LIT(KTestFileNameSurrogatePair1_ShortName, "ABCD_(~3.TXT"); sl@0: _LIT(KTestFileNameSurrogatePair2, "ABCD\xD846\xDF1D(DEF).TXT"); sl@0: _LIT(KTestFileNameSurrogatePair2_ShortName, "ABCD_(~4.TXT"); sl@0: sl@0: TFileName sn; sl@0: MakeFile(KTestFileName1); sl@0: TInt r = TheFs.GetShortName(KTestFileName1, sn); sl@0: test_KErrNone(r); sl@0: r = sn.Compare(KTestFileName1_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: MakeFile(KTestFileName2); sl@0: r = TheFs.GetShortName(KTestFileName2, sn); sl@0: test_KErrNone(r); sl@0: r = sn.Compare(KTestFileName2_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: MakeFile(KTestFileName3); sl@0: r = TheFs.GetShortName(KTestFileName3, sn); sl@0: test_KErrNone(r); sl@0: r = sn.Compare(KTestFileName3_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: MakeFile(KTestFileNameSurrogatePair1); sl@0: r = TheFs.GetShortName(KTestFileNameSurrogatePair1, sn); sl@0: test_KErrNone(r); sl@0: r = sn.Compare(KTestFileNameSurrogatePair1_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: MakeFile(KTestFileNameSurrogatePair2); sl@0: r = TheFs.GetShortName(KTestFileNameSurrogatePair2, sn); sl@0: test_KErrNone(r); sl@0: r = sn.Compare(KTestFileNameSurrogatePair2_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: test_KErrNone(TheFs.Delete(KTestFileName1)); sl@0: test_KErrNone(TheFs.Delete(KTestFileName2)); sl@0: test_KErrNone(TheFs.Delete(KTestFileName3)); sl@0: test_KErrNone(TheFs.Delete(KTestFileNameSurrogatePair1)); sl@0: test_KErrNone(TheFs.Delete(KTestFileNameSurrogatePair2)); sl@0: sl@0: test.Next(_L("--TestDuplicateLongFileNames")); sl@0: } sl@0: sl@0: void TestDuplicateLongDirNames() sl@0: { sl@0: test.Next(_L("++TestDuplicateLongDirNames")); sl@0: test.Next(_L("Testing tilde and number appended correctly for duplicate long name dirs")); sl@0: sl@0: TheFs.SessionPath(gSessionPath); sl@0: sl@0: // These are to test "~1", "~2" behaviours when the first 8 bytes of new directories sl@0: // are identical with existing directories sl@0: _LIT(KTestDirName1, "\\F32-TST\\T_SURROGATEPAIR\\ABCD\xFFFE(A)\\"); sl@0: _LIT(KTestDirName1_ShortName, "ABCD_(A)"); sl@0: _LIT(KTestDirName2, "\\F32-TST\\T_SURROGATEPAIR\\ABCD\xFFFE(AB)\\"); sl@0: _LIT(KTestDirName2_ShortName, "ABCD_(~1"); sl@0: _LIT(KTestDirName3, "\\F32-TST\\T_SURROGATEPAIR\\ABCD\xFFFE(ABC)\\"); sl@0: _LIT(KTestDirName3_ShortName, "ABCD_(~2"); sl@0: _LIT(KTestDirNameSurrogatePair1, "\\F32-TST\\T_SURROGATEPAIR\\ABCD\xD846\xDF1D(ABCD)\\"); sl@0: _LIT(KTestDirNameSurrogatePair1_ShortName, "ABCD_(~3"); sl@0: _LIT(KTestDirNameSurrogatePair2, "\\F32-TST\\T_SURROGATEPAIR\\ABCD\xD846\xDF1D(ABCDE)\\"); sl@0: _LIT(KTestDirNameSurrogatePair2_ShortName, "ABCD_(~4"); sl@0: sl@0: TFileName sn; sl@0: MakeDir(KTestDirName1); sl@0: TInt r = TheFs.GetShortName(KTestDirName1, sn); sl@0: test_KErrNone(r); sl@0: r = sn.Compare(KTestDirName1_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: MakeDir(KTestDirName2); sl@0: r = TheFs.GetShortName(KTestDirName2, sn); sl@0: test_KErrNone(r); sl@0: r = sn.Compare(KTestDirName2_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: MakeDir(KTestDirName3); sl@0: r = TheFs.GetShortName(KTestDirName3, sn); sl@0: test_KErrNone(r); sl@0: r = sn.Compare(KTestDirName3_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: MakeDir(KTestDirNameSurrogatePair1); sl@0: r = TheFs.GetShortName(KTestDirNameSurrogatePair1, sn); sl@0: test_KErrNone(r); sl@0: r = sn.Compare(KTestDirNameSurrogatePair1_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: MakeDir(KTestDirNameSurrogatePair2); sl@0: r = TheFs.GetShortName(KTestDirNameSurrogatePair2, sn); sl@0: test_KErrNone(r); sl@0: r = sn.Compare(KTestDirNameSurrogatePair2_ShortName); sl@0: test_Equal(r, 0); sl@0: sl@0: test_KErrNone(TheFs.RmDir(KTestDirName1)); sl@0: test_KErrNone(TheFs.RmDir(KTestDirName2)); sl@0: test_KErrNone(TheFs.RmDir(KTestDirName3)); sl@0: test_KErrNone(TheFs.RmDir(KTestDirNameSurrogatePair1)); sl@0: test_KErrNone(TheFs.RmDir(KTestDirNameSurrogatePair2)); sl@0: sl@0: test.Next(_L("--TestDuplicateLongDirNames")); sl@0: } sl@0: sl@0: void CallTestsL(void) sl@0: { sl@0: sl@0: test.Title(); sl@0: test.Start(_L("Starting T_SURROGATEPAIR tests")); sl@0: sl@0: #if defined(_DEBUG) || defined(_DEBUG_RELEASE) sl@0: sl@0: // Test only runs on Fat file systems sl@0: TheFs.SessionPath(gSessionPath); sl@0: TInt driveNum = CurrentDrive(); sl@0: TFSName name; sl@0: TInt r = TheFs.FileSystemName(name, driveNum); sl@0: if (KErrNone == r) sl@0: { sl@0: if (name.Compare(_L("Fat")) != 0) sl@0: { sl@0: test.Printf(_L("Test only runs on 'Fat' drives")); sl@0: } sl@0: else sl@0: { sl@0: // Check for the default implementation sl@0: // Disables codepage dll implementation of LocaleUtils functions sl@0: r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions); sl@0: test_KErrNone(r); sl@0: sl@0: CreateTestDirectory(_L("\\F32-TST\\T_SURROGATEPAIR\\")); sl@0: sl@0: TestVolumeLabel(); sl@0: TestShortNameCharacter(); sl@0: TestConsistentShortNameGeneration(); sl@0: TestConsistentShortNameExtGeneration(); sl@0: TestDuplicateLongFileNames(); sl@0: TestDuplicateLongDirNames(); sl@0: sl@0: DeleteTestDirectory(); sl@0: sl@0: // Disables codepage dll implementation of LocaleUtils functions for other base tests sl@0: r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions); sl@0: test_KErrNone(r); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L("Drive %C: is not ready!"), 'A'+driveNum); sl@0: test(EFalse); sl@0: } sl@0: #else sl@0: test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.")); sl@0: #endif // _DEBUG) || _DEBUG_RELEASE sl@0: test.End(); sl@0: }