1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/server/t_cp_plugintest.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,799 @@
1.4 +/*
1.5 +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#define __E32TEST_EXTENSION__
1.23 +
1.24 +#include <e32test.h>
1.25 +#include <HAL.H>
1.26 +#include <f32fsys.h>
1.27 +#include <f32dbg.h>
1.28 +#include "..\server\t_server.h"
1.29 +#include "fat_utils.h"
1.30 +
1.31 +
1.32 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.33 +using namespace Fat_Test_Utils;
1.34 +static RRawDisk TheDisk;
1.35 +static TFatBootSector gBootSector;
1.36 +
1.37 +#define MakeFile_CPTest(filename) \
1.38 + { \
1.39 + test.Printf(_L("MakeFile(%S) at LINE:%d\n"),&filename,__LINE__); \
1.40 + MakeFile(filename); \
1.41 + }
1.42 +
1.43 +void QuickFormat()
1.44 + {
1.45 + FormatFatDrive(TheFs, CurrentDrive(), ETrue);
1.46 + }
1.47 +
1.48 +void ReadBootSector(TFatBootSector& aBootSector)
1.49 + {
1.50 + TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector);
1.51 + test(nRes == KErrNone);
1.52 +
1.53 + if(!aBootSector.IsValid())
1.54 + {
1.55 + test.Printf(_L("Wrong bootsector! Dump:\n"));
1.56 + aBootSector.PrintDebugInfo();
1.57 + test(0);
1.58 + }
1.59 + }
1.60 +
1.61 +void GetBootInfo()
1.62 + {
1.63 + QuickFormat();
1.64 + ReadBootSector(gBootSector);
1.65 + }
1.66 +
1.67 +void doDirNameTest(const TDesC& aLongName, const TDesC& aShortName)
1.68 + {
1.69 + TBuf<KMaxFileName> longDirNamePath;
1.70 + TBuf<KMaxFileName> shortDirNamePath;
1.71 + TBuf<KMaxFileName> longName;
1.72 + TBuf<KMaxFileName> shortName;
1.73 + longDirNamePath = gSessionPath;
1.74 + longDirNamePath += aLongName;
1.75 + longDirNamePath.Append('\\');
1.76 +
1.77 + // Create new directory and check creation
1.78 + TInt r = TheFs.MkDir(longDirNamePath);
1.79 + test(r==KErrNone);
1.80 +
1.81 + TUint dumUint=0;
1.82 + CDir* dumDir;
1.83 + r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir);
1.84 + test(r==KErrNone);
1.85 + test_NotNull(dumDir);
1.86 + delete dumDir;
1.87 +
1.88 + // Check short name
1.89 + r = TheFs.GetShortName(longDirNamePath, shortName);
1.90 + test(r==KErrNone);
1.91 + r = shortName.Compare(aShortName);
1.92 + test(r==0);
1.93 +
1.94 + // Check long name
1.95 + shortDirNamePath = gSessionPath;
1.96 + shortDirNamePath += shortName;
1.97 + shortDirNamePath.Append('\\');
1.98 + r = TheFs.GetLongName(shortDirNamePath, longName);
1.99 + test(r==KErrNone);
1.100 + r = longName.Compare(aLongName);
1.101 + test(r==0);
1.102 +
1.103 + r = TheFs.RmDir(longDirNamePath);
1.104 + test(r==KErrNone);
1.105 + }
1.106 +
1.107 +void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName)
1.108 + {
1.109 + TFileName lgnFullPath;
1.110 + TFileName shnFullPath;
1.111 + TFileName lgn;
1.112 + TFileName shn;
1.113 +
1.114 + TInt r = TheFs.SessionPath(gSessionPath);
1.115 + test(r==KErrNone);
1.116 + lgnFullPath = gSessionPath;
1.117 + lgnFullPath += aLongName;
1.118 +
1.119 + MakeFile_CPTest(lgnFullPath);
1.120 + // Check short name
1.121 + r = TheFs.GetShortName(lgnFullPath, shn);
1.122 + test(r==KErrNone);
1.123 + r = shn.Compare(aShortName);
1.124 + test(r==0);
1.125 +
1.126 + // Check long name
1.127 + shnFullPath = gSessionPath;
1.128 + shnFullPath += aShortName;
1.129 +
1.130 + r = TheFs.GetLongName(shnFullPath, lgn);
1.131 + test(r==KErrNone);
1.132 + r = lgn.Compare(aLongName);
1.133 + test(r==0);
1.134 +
1.135 + r = TheFs.Delete(lgnFullPath);
1.136 + test(r==KErrNone);
1.137 +
1.138 + }
1.139 +#endif //_DEBUG || _DEBUG_RELEASE
1.140 +
1.141 +//----------------------------------------------------------------------------------------------
1.142 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-0407
1.143 +//! @SYMTestType CIT
1.144 +//! @SYMDEF DEF101875
1.145 +//! @SYMTestCaseDesc This test case is to test volume label setting with Unicode characters
1.146 +//! @SYMTestActions 1. Changes locale to load testing codepage dll, check returning error code
1.147 +//! 2. Sets volume label with Unicode (less than 11 bytes long), test setting
1.148 +//! success, gets volume label and compares it with the original Unicode string;
1.149 +//! 3. Sets volume label with a Unicode string contains less than 11 characters
1.150 +//! but occupies bigger than 11 bytes, checks the returning error code;
1.151 +//! 4. Compares the volume label with the Unicode string used in action 2
1.152 +//! @SYMTestExpectedResults
1.153 +//! 1. KErrNone should be returned;
1.154 +//! 2. The comparison should return 0;
1.155 +//! 3. KErrBadName should be returned;
1.156 +//! 4. The comparison should return 0;
1.157 +//! @SYMTestPriority High
1.158 +//! @SYMTestStatus Implemented
1.159 +//----------------------------------------------------------------------------------------------
1.160 +void TestUnicodeVolumeLabel()
1.161 + {
1.162 + test.Next(_L("Test unicode volume labels"));
1.163 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.164 +
1.165 + TInt r = TheFs.SessionPath(gSessionPath);
1.166 + test(r==KErrNone);
1.167 + TInt driveNum;
1.168 + r = TheFs.CharToDrive(gSessionPath[0], driveNum);
1.169 + test(r==KErrNone);
1.170 +
1.171 + // Retrieves the original volume label
1.172 + TVolumeInfo vInfo;
1.173 + r = TheFs.Volume(vInfo, driveNum);
1.174 + const TInt KVolumeLabelSize = 11;
1.175 + TBuf<KVolumeLabelSize> originalVolumeLabel(vInfo.iName);
1.176 +
1.177 + // Tests setting volume label with unicode characters
1.178 + _LIT(KUnicodeVolumeLabel, "\x65B0\x65B0\x65B0");
1.179 +
1.180 + r = TheFs.SetVolumeLabel(KUnicodeVolumeLabel, driveNum);
1.181 + test(r==KErrNone);
1.182 + r = TheFs.Volume(vInfo, driveNum);
1.183 + test(r==KErrNone);
1.184 + r = vInfo.iName.Compare(KUnicodeVolumeLabel);
1.185 + test(r==KErrNone);
1.186 +
1.187 + // Tests setting volume label with unicode characters that bigger than 11 bytes
1.188 + _LIT(KVolumeLabelOverflow, "\x65B0\x65B0\x65B0\x65B0\x65B0\x65B0");
1.189 + r = TheFs.SetVolumeLabel(KVolumeLabelOverflow, driveNum);
1.190 + test(r==KErrOverflow);
1.191 +
1.192 + // Sets back the original volume label
1.193 + r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum);
1.194 + test(r==KErrNone);
1.195 + r = TheFs.Volume(vInfo, driveNum);
1.196 + test(r==KErrNone);
1.197 + r = vInfo.iName.Compare(originalVolumeLabel);
1.198 + test(r==0);
1.199 +#else
1.200 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.201 +#endif // _DEBUG) || _DEBUG_RELEASE
1.202 + }
1.203 +
1.204 +//----------------------------------------------------------------------------------------------
1.205 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-0408
1.206 +//! @SYMTestType CIT
1.207 +//! @SYMDEF DEF101875
1.208 +//! @SYMTestCaseDesc This test case is to test the "8 bytes" boundary of short name length,
1.209 +//! which is defined in FAT Specification.
1.210 +//! @SYMTestActions 1. Creates files and directories with different Unicode strings that
1.211 +//! have different combinations of length (of characters) and size (of
1.212 +//! bytes occupied), check for error of creation.
1.213 +//! 2. Gets their short name, compares with expected values, gets their long
1.214 +//! name, compares with original Unicode strings.
1.215 +//! The strings and short name tested are as below:
1.216 +//! 2.1. original string: "Abc"
1.217 +//! expected short name: "ABC";
1.218 +//! 2.2. original string: "\x65B0\x6587\x4EF6\x4EF6"
1.219 +//! expected short name: "\x65B0\x6587\x4EF6\x4EF6";
1.220 +//! 2.3. original string: "\x65B0\x6587\x4EF6(01)"
1.221 +//! expected short name: "\x65B0\x6587\x4EF6~1";
1.222 +//! 2.4. original string: "Abcdefghi"
1.223 +//! expected short name: "ABCDEF~1";
1.224 +//! 2.5. original string: "\x65B0(Abcdefgh)"
1.225 +//! expected short name: "\x65B0(ABC~1";
1.226 +//! @SYMTestExpectedResults
1.227 +//! 1. File should be created with no error;
1.228 +//! 2. Comparisons should return 0;
1.229 +//! @SYMTestPriority High
1.230 +//! @SYMTestStatus Implemented
1.231 +//----------------------------------------------------------------------------------------------
1.232 +void TestShortNameBoundary()
1.233 + {
1.234 + test.Next(_L("8 bytes' name boundary tests"));
1.235 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.236 +
1.237 + // File names will be used for testing boundaries
1.238 + _LIT(KTestFileName3C3B, "Abc"); // 3 characters, 3 bytes long
1.239 + _LIT(KTestFileName3C3B_short, "ABC"); // Expected short name
1.240 + _LIT(KTestFileName4C8B, "\x65B0\x6587\x4EF6\x4EF6");// 4 characters, 8 bytes long
1.241 + _LIT(KTestFileName4C8B_short, "\x65B0\x6587\x4EF6\x4EF6");// Expected short name
1.242 + _LIT(KTestFileName7C10B, "\x65B0\x6587\x4EF6(01)"); // 7 characters, 10 bytes long
1.243 + _LIT(KTestFileName7C10B_short, "\x65B0\x6587\x4EF6~1"); // Expected short name
1.244 + _LIT(KTestFileName9C9B, "Abcdefghi"); // 9 characters, 9 bytes long
1.245 + _LIT(KTestFileName9C9B_short, "ABCDEF~1"); // Expected short name
1.246 + _LIT(KTestFileName9C10B, "\x65B0(Abcdefgh)"); // 9 characters, 10 bytes long
1.247 + _LIT(KTestFileName9C10B_short, "\x65B0(ABC~1"); // Expected short name
1.248 +
1.249 + // Test file creation and long/short name generation
1.250 + doFileNameTest(KTestFileName3C3B, KTestFileName3C3B_short);
1.251 + doFileNameTest(KTestFileName4C8B, KTestFileName4C8B_short);
1.252 + doFileNameTest(KTestFileName7C10B, KTestFileName7C10B_short);
1.253 + doFileNameTest(KTestFileName9C9B, KTestFileName9C9B_short);
1.254 + doFileNameTest(KTestFileName9C10B, KTestFileName9C10B_short);
1.255 +
1.256 + doDirNameTest(KTestFileName3C3B, KTestFileName3C3B_short);
1.257 + doDirNameTest(KTestFileName4C8B, KTestFileName4C8B_short);
1.258 + doDirNameTest(KTestFileName7C10B, KTestFileName7C10B_short);
1.259 + doDirNameTest(KTestFileName9C9B, KTestFileName9C9B_short);
1.260 + doDirNameTest(KTestFileName9C10B, KTestFileName9C10B_short);
1.261 +
1.262 +#else
1.263 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.264 +#endif // _DEBUG) || _DEBUG_RELEASE
1.265 + }
1.266 +
1.267 +//----------------------------------------------------------------------------------------------
1.268 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-0794
1.269 +//! @SYMTestCaseDesc This test case is to test the extensions of the short names generated are consistent for file names
1.270 +//! consisting of UNICODE characters. In a shortname, if the character at the third location (in 8.3 format)
1.271 +//! is a head byte of a UNICODE character then it should be ignored.
1.272 +//! @SYMTestActions 1. Creates files and directories with different Unicode strings that
1.273 +//! have different combinations of extension length (of characters) and size (of
1.274 +//! bytes occupied), check for error of creation.
1.275 +//! 2. Gets their short name, compares with expected values, gets their long
1.276 +//! name, compares with original Unicode strings.
1.277 +//! The strings and short name tested are as below:
1.278 +//! 2.1. original string: "abcdef.\x65B0"
1.279 +//! expected short name: "ABCDEF.\x65B0";
1.280 +//! 2.2. original string: "abcdef.t\x65B0"
1.281 +//! expected short name: "ABCDEF.T\x65B0";
1.282 +//! 2.3. original string: "abcdef.\x65B0t"
1.283 +//! expected short name: "ABCDEF.\x65B0T";
1.284 +//! 2.4. original string: "abcdefg.\x65B0\x65B0"
1.285 +//! expected short name: "ABCDEF~1.\x65B0";
1.286 +//!
1.287 +//! @SYMTestExpectedResults
1.288 +//! 1. File should be created with no error;
1.289 +//! 2. Comparisons should return 0;
1.290 +//! @SYMTestPriority High
1.291 +//! @SYMTestStatus Implemented
1.292 +//----------------------------------------------------------------------------------------------
1.293 +
1.294 +void TestConsistentShortNameExtGeneration()
1.295 + {
1.296 + test.Next(_L("Test consistent short name extensions are generated"));
1.297 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.298 +
1.299 + // File names will be used for testing boundaries
1.300 + _LIT(KTestFileNameExt1C2B, "abcdefg.\x65B0"); // 1 characters, 2 bytes long ;only one Unicode character in the extension
1.301 + _LIT(KTestFileNameExt1C2B_short, "ABCDEFG.\x65B0"); //Expected short name
1.302 + _LIT(KTestFileNameExt2C3B2U, "abcdefg.t\x65B0"); // 2 characters, 3 bytes long ;Unicode character at the 2nd location of the extension
1.303 + _LIT(KTestFileNameExt2C3B2U_short, "ABCDEFG.T\x65B0"); //Expected short name
1.304 + _LIT(KTestFileNameExt2C3B1U, "abcdefg.\x65B0t"); // 2 characters, 3 bytes long ;Unicode character at the 1st location of the extension
1.305 + _LIT(KTestFileNameExt2C3B1U_short, "ABCDEFG.\x65B0T"); //Expected short name
1.306 + _LIT(KTestFileNameExt2C4B, "abcdefg.\x65B0\x65B0");// 2 characters, 4 bytes long ;both are Unicode characters in the extension
1.307 + _LIT(KTestFileNameExt2C4B_short, "ABCDEF~1.\x65B0"); //Expected short name
1.308 +
1.309 +
1.310 + // Test file creation and long/short name generation
1.311 + doFileNameTest(KTestFileNameExt1C2B, KTestFileNameExt1C2B_short);
1.312 + doFileNameTest(KTestFileNameExt2C3B2U, KTestFileNameExt2C3B2U_short);
1.313 + doFileNameTest(KTestFileNameExt2C3B1U, KTestFileNameExt2C3B1U_short);
1.314 + doFileNameTest(KTestFileNameExt2C4B, KTestFileNameExt2C4B_short);
1.315 +
1.316 + doDirNameTest(KTestFileNameExt1C2B, KTestFileNameExt1C2B_short);
1.317 + doDirNameTest(KTestFileNameExt2C3B2U, KTestFileNameExt2C3B2U_short);
1.318 + doDirNameTest(KTestFileNameExt2C3B1U, KTestFileNameExt2C3B1U_short);
1.319 + doDirNameTest(KTestFileNameExt2C4B, KTestFileNameExt2C4B_short);
1.320 +#else
1.321 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.322 +#endif // _DEBUG) || _DEBUG_RELEASE
1.323 + }
1.324 +
1.325 +
1.326 +//----------------------------------------------------------------------------------------------
1.327 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-0795
1.328 +//! @SYMTestCaseDesc This test case is to test whether the short names generated for file names
1.329 +//! consisting of UNICODE characters are consistent or not. In a shortname, if the character immediately
1.330 +//! preceding the tilde(~) is a head byte of a UNICODE character then it should be ignored.
1.331 +//! @SYMTestActions 1. Creates files and directories with different Unicode strings that
1.332 +//! have different combinations of length (of characters) and size (of
1.333 +//! bytes occupied), check for error of creation.
1.334 +//! 2. Gets their short name, compares with expected values, gets their long
1.335 +//! name, compares with original Unicode strings.
1.336 +//! The strings and short name tested are as below:
1.337 +//! 2.1. original string: "a\x65B0(bcd)"
1.338 +//! expected short name: "A\x65B0(BCD)";
1.339 +//! 2.2. original string: "ab\x65B0(cdef)"
1.340 +//! expected short name: "AB\x65B0(C~1")";
1.341 +//! 2.3. original string: "abc\x65B0(def)"
1.342 +//! expected short name: "ABC\x65B0(~1";
1.343 +//! 2.4. original string: "abcd\x65B0(ef)"
1.344 +//! expected short name: "ABCD\x65B0~1";
1.345 +//! 2.5. original string: "abcde\x65B0(f)"
1.346 +//! expected short name: "ABCDE~1";
1.347 +//! @SYMTestExpectedResults
1.348 +//! 1. File should be created with no error;
1.349 +//! 2. Comparisons should return 0;
1.350 +//! @SYMTestPriority High
1.351 +//! @SYMTestStatus Implemented
1.352 +//----------------------------------------------------------------------------------------------
1.353 +void TestConsistentShortNameGeneration()
1.354 + {
1.355 + test.Next(_L("Test consistent short name generation"));
1.356 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.357 +
1.358 + //unicode characters.
1.359 +
1.360 + _LIT(KTestFileName7C8B2U, "a\x65B0(bcd)"); // 7 characters, 8 bytes long ,Unicode character at the 2nd location.
1.361 + _LIT(KTestFileName7C8B2U_short, "A\x65B0(BCD)"); // Expected short name
1.362 + _LIT(KTestFileName9C10B3U, "ab\x65B0(cdef)"); // 9 characters, 10 bytes long ,Unicode character at the 3rd location.
1.363 + _LIT(KTestFileName9C10B3U_short,"AB\x65B0(C~1"); // Expected short name
1.364 + _LIT(KTestFileName9C10B4U, "abc\x65B0(def)"); // 9 characters, 10 bytes long ,Unicode character at the 4th location.
1.365 + _LIT(KTestFileName9C10B4U_short,"ABC\x65B0(~1"); // Expected short name
1.366 + _LIT(KTestFileName9C10B5U, "abcd\x65B0(ef)"); // 9 characters, 10 bytes long ,Unicode character at the 6th location.
1.367 + _LIT(KTestFileName9C10B5U_short,"ABCD\x65B0~1"); // Expected short name
1.368 + _LIT(KTestFileName9C10B6U, "abcde\x65B0(f)"); // 9 characters, 10 bytes long ,repeat Unicode character at the 6th location.
1.369 + _LIT(KTestFileName9C10B6U_short,"ABCDE~1"); // Expected short name
1.370 +
1.371 + // Test file creation and long/short name generation
1.372 + doFileNameTest(KTestFileName7C8B2U, KTestFileName7C8B2U_short);
1.373 + doFileNameTest(KTestFileName9C10B3U, KTestFileName9C10B3U_short);
1.374 + doFileNameTest(KTestFileName9C10B4U, KTestFileName9C10B4U_short);
1.375 + doFileNameTest(KTestFileName9C10B5U, KTestFileName9C10B5U_short);
1.376 + doFileNameTest(KTestFileName9C10B6U, KTestFileName9C10B6U_short);
1.377 +
1.378 + doDirNameTest(KTestFileName7C8B2U, KTestFileName7C8B2U_short);
1.379 + doDirNameTest(KTestFileName9C10B3U, KTestFileName9C10B3U_short);
1.380 + doDirNameTest(KTestFileName9C10B4U, KTestFileName9C10B4U_short);
1.381 + doDirNameTest(KTestFileName9C10B5U, KTestFileName9C10B5U_short);
1.382 + doDirNameTest(KTestFileName9C10B6U, KTestFileName9C10B6U_short);
1.383 +#else
1.384 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.385 +#endif // _DEBUG) || _DEBUG_RELEASE
1.386 + }
1.387 +
1.388 +//----------------------------------------------------------------------------------------------
1.389 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-0409
1.390 +//! @SYMTestType CIT
1.391 +//! @SYMDEF DEF101875 INC100580
1.392 +//! @SYMTestCaseDesc This test case is to test creation of files with their Unicode names are
1.393 +//! duplicate to existing files.
1.394 +//! @SYMTestActions 1. Creates a file with its name contains 4 Unicode characters but occupies
1.395 +//! 8 bytes ("\x65B0\x6587\x4EF6\x4EF6"), check for creation;
1.396 +//! 2. Creates a file with 11 bytes' long Unicode name and first 8 bytes are
1.397 +//! identical with the file created in Action 1 ("\x65B0\x6587\x4EF6\x4EF6(A)"),
1.398 +//! check for file creation;
1.399 +//! 3. Gets the short name of the file created in Action 2, compares it with
1.400 +//! expected short name ("\x65B0\x6587\x4EF6~1"), gets the long name of this
1.401 +//! file and compares it with its original Unicode name;
1.402 +//! 4. Creates a file with 12 bytes' long Unicode name and first 8 bytes are
1.403 +//! identical with the file created in Action 1 and Action 2
1.404 +//! ("\x65B0\x6587\x4EF6\x4EF6(AB)"), check for file creation;
1.405 +//! 5. Gets the short name of the file created in Action 4, compares it with
1.406 +//! expected values ("\x65B0\x6587\x4EF6~2"), gets the long name of this file
1.407 +//! and compares it with its original Unicode name;
1.408 +//! @SYMTestExpectedResults
1.409 +//! 1. File creation should return KErrNone;
1.410 +//! 2. File creation should return KErrNone;
1.411 +//! 3. Comparisons should return 0;
1.412 +//! 4. File creation should return KErrNone;
1.413 +//! 5. Comparisons should return 0;
1.414 +//! @SYMTestPriority High
1.415 +//! @SYMTestStatus Implemented
1.416 +//----------------------------------------------------------------------------------------------
1.417 +void TestDuplicateLongFileNames()
1.418 + {
1.419 + test.Next(_L("Testing tilde and numbers (\"~n\") are applied correctly for multiple long-named files"));
1.420 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.421 +
1.422 + // These are to test "~1", "~2" behaviours when the first 8 bytes of new files
1.423 + // are identical with existing files
1.424 + _LIT(KTestFileName4C8B, "\x65B0\x6587\x4EF6\x4EF6.TXT");
1.425 + _LIT(KTestFileName7C11B, "\x65B0\x6587\x4EF6\x4EF6(A).TXT");
1.426 + _LIT(KTestFileName7C11B_short, "\x65B0\x6587\x4EF6~1.TXT");
1.427 + _LIT(KTestFileName8C12B, "\x65B0\x6587\x4EF6\x4EF6(AB).TXT");
1.428 + _LIT(KTestFileName8C12B_short, "\x65B0\x6587\x4EF6~2.TXT");
1.429 +
1.430 + ////////////////////////////////////////
1.431 + // 1. Test duplicate long file names
1.432 + ////////////////////////////////////////
1.433 + TFileName sn;
1.434 + TInt r;
1.435 + MakeFile_CPTest(KTestFileName4C8B);
1.436 + MakeFile_CPTest(KTestFileName7C11B);
1.437 + r = TheFs.GetShortName(KTestFileName7C11B, sn);
1.438 + test(r==KErrNone);
1.439 + r = sn.Compare(KTestFileName7C11B_short);
1.440 + test(r==0);
1.441 +
1.442 +
1.443 + MakeFile_CPTest(KTestFileName8C12B);
1.444 + r = TheFs.GetShortName(KTestFileName8C12B, sn);
1.445 + test(r==KErrNone);
1.446 + r = sn.Compare(KTestFileName8C12B_short);
1.447 + test(r==0);
1.448 +
1.449 + r = TheFs.Delete(KTestFileName4C8B);
1.450 + test(r==KErrNone);
1.451 +
1.452 + r = TheFs.Delete(KTestFileName7C11B);
1.453 + test(r==KErrNone);
1.454 +
1.455 + r = TheFs.Delete(KTestFileName8C12B);
1.456 + test(r==KErrNone);
1.457 +
1.458 +#else
1.459 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.460 +#endif // _DEBUG) || _DEBUG_RELEASE
1.461 + }
1.462 +
1.463 +
1.464 +//----------------------------------------------------------------------------------------------
1.465 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-0410
1.466 +//! @SYMTestType CIT
1.467 +//! @SYMDEF DEF101875 INC100580
1.468 +//! @SYMTestCaseDesc This test case is to test creation of directories with their Unicode names are
1.469 +//! duplicate to existing directories .
1.470 +//! @SYMTestActions 1. Creates a directories with its name contains 4 Unicode characters but occupies
1.471 +//! 8 bytes ("\x65B0\x6587\x4EF6\x4EF6"), check for creation;
1.472 +//! 2. Creates a directories with 11 bytes' long Unicode name and first 8 bytes are
1.473 +//! identical with the directories created in Action 1 ("\x65B0\x6587\x4EF6\x4EF6(A)"),
1.474 +//! check for file creation;
1.475 +//! 3. Gets the short name of the directories created in Action 2, compares it with
1.476 +//! expected short name ("\x65B0\x6587\x4EF6~1"), gets the long name of this
1.477 +//! directories and compares it with its original Unicode name;
1.478 +//! 4. Creates a directories with 12 bytes' long Unicode name and first 8 bytes are
1.479 +//! identical with the directories created in Action 1 and Action 2
1.480 +//! ("\x65B0\x6587\x4EF6\x4EF6(AB)"), check for directories creation;
1.481 +//! 5. Gets the short name of the directories created in Action 4, compares it with
1.482 +//! expected values ("\x65B0\x6587\x4EF6~2"), gets the long name of this directories
1.483 +//! and compares it with its original Unicode name;
1.484 +//! @SYMTestExpectedResults
1.485 +//! 1. Dir creation should return KErrNone;
1.486 +//! 2. Dir creation should return KErrNone;
1.487 +//! 3. Comparisons should return 0;
1.488 +//! 4. Dir creation should return KErrNone;
1.489 +//! 5. Comparisons should return 0;
1.490 +//! @SYMTestPriority High
1.491 +//! @SYMTestStatus Implemented
1.492 +//----------------------------------------------------------------------------------------------
1.493 +void TestDuplicateLongDirNames()
1.494 + {
1.495 + test.Next(_L("Testing tilde and number appended correctly for duplicate long name dirs"));
1.496 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.497 + TheFs.SessionPath(gSessionPath);
1.498 +
1.499 + // These are to test "~1", "~2" behaviours when the first 8 bytes of new directories
1.500 + // are identical with existing directories
1.501 + _LIT(KTestDirName4C8B, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x65B0\x6587\x4EF6\x4EF6\\");
1.502 + _LIT(KTestDirName7C11B, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x65B0\x6587\x4EF6\x4EF6(A)\\");
1.503 + _LIT(KTestDirName7C11B_short, "\x65B0\x6587\x4EF6~1");
1.504 + _LIT(KTestDirName8C12B, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x65B0\x6587\x4EF6\x4EF6(AB)\\");
1.505 + _LIT(KTestDirName8C12B_short, "\x65B0\x6587\x4EF6~2");
1.506 +
1.507 + // Create 1st file with 8 bytes long/short name
1.508 + TInt r;
1.509 + MakeDir(KTestDirName4C8B);
1.510 + MakeDir(KTestDirName7C11B);
1.511 +
1.512 + TFileName sn;
1.513 +
1.514 + r = TheFs.GetShortName(KTestDirName7C11B, sn);
1.515 + test(r==KErrNone);
1.516 + r = sn.Compare(KTestDirName7C11B_short);
1.517 + test(r==0);
1.518 +
1.519 + MakeDir(KTestDirName8C12B);
1.520 + r = TheFs.GetShortName(KTestDirName8C12B, sn);
1.521 + test(r==KErrNone);
1.522 + r = sn.Compare(KTestDirName8C12B_short);
1.523 + test(r==0);
1.524 +
1.525 +#else
1.526 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.527 +#endif // _DEBUG) || _DEBUG_RELEASE
1.528 + }
1.529 +
1.530 +//----------------------------------------------------------------------------------------------
1.531 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-0791
1.532 +//! @SYMTestType CIT
1.533 +//! @SYMDEF DEF117345
1.534 +//! @SYMTestCaseDesc This test case is to test short name with 'E5' as the leading byte is correctly
1.535 +//! handled on FAT implementations
1.536 +//! @SYMTestActions 1. Creates a file with unicode long name "\x88F9.TXT", it will be converted into
1.537 +//! "\xE5E5.TXT" according to codepage 932 when creating short name.
1.538 +//! 2. Gets the short name and compare it with its original unicode "\x88F9.TXT", make
1.539 +//! sure the conversion "\xE5E5.TXT" has been handled correctly
1.540 +//! @SYMTestExpectedResults
1.541 +//! 1. Comparisons should return 0;
1.542 +//! @SYMTestPriority High
1.543 +//! @SYMTestStatus Implemented
1.544 +//----------------------------------------------------------------------------------------------
1.545 +void TestLeadingE5Handling()
1.546 + {
1.547 + test.Next(_L("Test Leading \'E5\' byte handling (DEF117345)"));
1.548 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.549 + TheFs.SessionPath(gSessionPath);
1.550 +
1.551 + _LIT(KTestFilePathAndName, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x88F9.TXT");
1.552 + _LIT(KTestFileShortName, "\x88F9.TXT");
1.553 +
1.554 + TInt r;
1.555 + MakeFile_CPTest(KTestFilePathAndName);
1.556 + TFileName sn;
1.557 + r = TheFs.GetShortName(KTestFilePathAndName, sn);
1.558 + test(r==KErrNone);
1.559 + r = sn.Compare(KTestFileShortName);
1.560 + test(r==0);
1.561 +
1.562 +#else
1.563 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.564 +#endif // _DEBUG) || _DEBUG_RELEASE
1.565 + }
1.566 +//----------------------------------------------------------------------------------------------
1.567 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-2320
1.568 +//! @SYMTestType CIT
1.569 +//! @SYMDEF PDEF130334
1.570 +//! @SYMTestCaseDesc This test case is to test creating a file with "\u3005" name correctly
1.571 +//! @SYMTestActions 1. Creates a file with unicode long name "\u3005.TXT"
1.572 +//! 2. Gets the short name and compare it with its original unicode "\u3005.TXT"
1.573 +//! 3. Gets the long name and compare it with its original unicode "\u3005.TXT"
1.574 +//! @SYMTestExpectedResults
1.575 +//! 1. Comparisons should return 0;
1.576 +//! @SYMTestPriority High
1.577 +//! @SYMTestStatus Implemented
1.578 +//----------------------------------------------------------------------------------------------
1.579 +void TestDEF130334()
1.580 + {
1.581 + test.Next(_L("Test creating a file with \\x3005 name correctly (DEF128521)"));
1.582 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.583 + TheFs.SessionPath(gSessionPath);
1.584 +
1.585 + _LIT(KTestFilePathAndName, "\\F32-TST\\T_CODEPAGE_PLUGIN\\\x3005.TXT");
1.586 + _LIT(KTestFileName, "\x3005.TXT");
1.587 +
1.588 + TInt r;
1.589 + MakeFile_CPTest(KTestFilePathAndName);
1.590 +
1.591 + TFileName sn;
1.592 + r = TheFs.GetShortName(KTestFilePathAndName, sn);
1.593 + test(r==KErrNone);
1.594 + r = sn.Compare(KTestFileName);
1.595 + test(r==0);
1.596 + TFileName ln;
1.597 + r = TheFs.GetLongName(KTestFilePathAndName, ln);
1.598 + test(r==KErrNone);
1.599 + r = ln.Compare(KTestFileName);
1.600 + test(r==0);
1.601 +
1.602 +#else
1.603 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.604 +#endif
1.605 + }
1.606 +//----------------------------------------------------------------------------------------------
1.607 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-1359
1.608 +//! @SYMTestType CIT
1.609 +//! @SYMDEF INC125768
1.610 +//! @SYMTestCaseDesc This test case is to test the compatibility of file opening, to make sure files
1.611 +//! with only one DOS entry which contains unicode short name is accessible on Symbian OS
1.612 +//! from version 9.3 onwards.
1.613 +//! @SYMTestActions Manually creates a single entried, unicode named file under root direcotry, then
1.614 +//! access it via RFs::Entry() API using its uniocde name. Check the entry is accessible.
1.615 +//! @SYMTestExpectedResults
1.616 +//! RFs::Entry() should return with KErrNone;
1.617 +//! @SYMTestPriority High
1.618 +//! @SYMTestStatus Implemented
1.619 +//----------------------------------------------------------------------------------------------
1.620 +void TestCompatibility()
1.621 + {
1.622 + test.Next(_L("test file opening compatibility"));
1.623 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.624 + GetBootInfo();
1.625 +
1.626 + RFile file;
1.627 + TFileName fn = _L("\\ABCD");
1.628 +
1.629 + TInt r=file.Create(TheFs,fn,EFileRead);
1.630 + test(r==KErrNone);
1.631 + file.Close();
1.632 +
1.633 + // Assume this file is the first entry in the root directory
1.634 + r=TheDisk.Open(TheFs,CurrentDrive());
1.635 + test(r==KErrNone);
1.636 +
1.637 + //-- read the 1st dir entry, it should be a DOS entry
1.638 + const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
1.639 +
1.640 + TFatDirEntry fatEntry1;
1.641 + TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
1.642 + test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone);
1.643 + test(!fatEntry1.IsVFatEntry());
1.644 +
1.645 + // Manually modify the short name into unicode characters
1.646 + // Unicode: 0x(798F 5C71 96C5 6CBB)
1.647 + // Shift-JIS: 0x(959F 8E52 89EB 8EA1)
1.648 +
1.649 + TBuf8<8> unicodeSN = _L8("ABCD1234");
1.650 + unicodeSN[0] = 0x95;
1.651 + unicodeSN[1] = 0x9F;
1.652 + unicodeSN[2] = 0x8E;
1.653 + unicodeSN[3] = 0x52;
1.654 + unicodeSN[4] = 0x89;
1.655 + unicodeSN[5] = 0xEB;
1.656 + unicodeSN[6] = 0x8E;
1.657 + unicodeSN[7] = 0xA1;
1.658 +
1.659 + fatEntry1.SetName(unicodeSN);
1.660 + test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
1.661 + TheDisk.Close();
1.662 +
1.663 + fn = _L("\\ABCD");
1.664 + fn[1] = 0x798F;
1.665 + fn[2] = 0x5C71;
1.666 + fn[3] = 0x96C5;
1.667 + fn[4] = 0x6CBB;
1.668 +
1.669 + TEntry entry;
1.670 + TInt err = TheFs.Entry(fn, entry);
1.671 + test(err==KErrNone);
1.672 + err = TheFs.Delete(fn);
1.673 + test(err==KErrNone);
1.674 +#else
1.675 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.676 +#endif // _DEBUG) || _DEBUG_RELEASE
1.677 + }
1.678 +
1.679 +//----------------------------------------------------------------------------------------------
1.680 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-1395
1.681 +//! @SYMTestType CIT
1.682 +//! @SYMDEF INC126563
1.683 +//! @SYMTestCaseDesc This test case is to test the definition of valid DOS characters on Symbian
1.684 +//! FAT/FAT32 complies with FAT Spec.
1.685 +//! @SYMTestActions Manually creates a file with "0x7F" characters in its name, then check it can
1.686 +//! ben accessed successfully.
1.687 +//! @SYMTestExpectedResults
1.688 +//! RFs::Entry() should return with KErrNone;
1.689 +//! @SYMTestPriority High
1.690 +//! @SYMTestStatus Implemented
1.691 +//----------------------------------------------------------------------------------------------
1.692 +void TestINC126563()
1.693 + {
1.694 + test.Next(_L("Test INC126563: FAT/FAT32: unable to open or delete file whose name contains illegal characters"));
1.695 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.696 + GetBootInfo();
1.697 +
1.698 + RFile file;
1.699 + TFileName fn = _L("\\AB");
1.700 +
1.701 + test.Next(_L("create file \"AB\" under root directory"));
1.702 + TInt r=file.Create(TheFs,fn,EFileRead);
1.703 + test(r==KErrNone);
1.704 + file.Close();
1.705 +
1.706 + test.Next(_L("manually change file name to \"0x7F0x450x7F0x45\" via raw disk accessing"));
1.707 + // Assume this file is the first entry in the root directory
1.708 + r=TheDisk.Open(TheFs,CurrentDrive());
1.709 + test(r==KErrNone);
1.710 +
1.711 + //-- read the first dir entry, it should be a DOS entry
1.712 + const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
1.713 +
1.714 + TFatDirEntry fatEntry1;
1.715 + TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
1.716 + test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone);
1.717 + test(!fatEntry1.IsVFatEntry());
1.718 +
1.719 + TBuf8<8> unicodeSN = _L8("ABCD");
1.720 + unicodeSN[0] = 0x7F;
1.721 + unicodeSN[1] = 0x45;
1.722 + unicodeSN[2] = 0x7F;
1.723 + unicodeSN[3] = 0x45;
1.724 +
1.725 + fatEntry1.SetName(unicodeSN);
1.726 + test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
1.727 + TheDisk.Close();
1.728 +
1.729 + test.Next(_L("access entries under root directory via RDir::Open()"));
1.730 + RDir dir;
1.731 + r = dir.Open(TheFs, _L("\\"), KEntryAttNormal);
1.732 + test(KErrNone == r);
1.733 + TEntryArray entryArray;
1.734 + r = dir.Read(entryArray);
1.735 + test(entryArray.Count()==1);
1.736 + TBuf<0x10> name;
1.737 + TEntry entry;
1.738 + entry = entryArray[0];
1.739 + test.Printf(_L("entryArray[0] = \"%S\"\n"), &entry.iName);
1.740 + name = entry.iName;
1.741 + dir.Close();
1.742 +
1.743 + TFileName fullname= _L("\\");
1.744 + fullname.Append(name);
1.745 +
1.746 + test.Next(_L("try to open or delete file entries retrieved"));
1.747 + r = file.Open(TheFs, fullname, EFileRead);
1.748 + test(KErrNone == r);
1.749 + file.Close();
1.750 +
1.751 + r = TheFs.Delete(fullname);
1.752 + test(KErrNone == r);
1.753 +#else
1.754 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.755 +#endif // _DEBUG) || _DEBUG_RELEASE
1.756 + }
1.757 +
1.758 +//----------------------------------------------------------------------------------------------
1.759 +//! @SYMTestCaseID PBASE-t_fatcharsetconv-1402
1.760 +//! @SYMTestType CIT
1.761 +//! @SYMDEF INC127905
1.762 +//! @SYMTestCaseDesc This test case is to test RFs::ScanDrive() does not incorrectly remove files
1.763 +//! with unicode short file names.
1.764 +//! @SYMTestActions Creates a file with unicode file names then check if the file is still accessible
1.765 +//! after scandrive operations.
1.766 +//! @SYMTestExpectedResults
1.767 +//! RFs::Delete() should return with KErrNone;
1.768 +//! @SYMTestPriority High
1.769 +//! @SYMTestStatus Implemented
1.770 +//----------------------------------------------------------------------------------------------
1.771 +void TestINC127905()
1.772 + {
1.773 + test.Next(_L("Test INC127905: Unicode name file deleted after Scandrive"));
1.774 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.775 + TFileName fn = _L("ABCDE");
1.776 + fn[0] = 0x3055;
1.777 + fn[1] = 0x307E;
1.778 + fn[2] = 0x3056;
1.779 + fn[3] = 0x307E;
1.780 + fn[4] = 0x306A;
1.781 +
1.782 +
1.783 + TInt r;
1.784 + MakeFile_CPTest(fn);
1.785 +
1.786 + _LIT(KShortName, "\x3055\x307E\x3056~1");
1.787 + TFileName sn;
1.788 + r = TheFs.GetShortName(fn, sn);
1.789 + test(r==KErrNone);
1.790 + r = sn.Compare(KShortName);
1.791 + test(r==0);
1.792 +
1.793 + r = TheFs.ScanDrive(_L("gSessionPath"));
1.794 + test(r==KErrNone);
1.795 +
1.796 + r = TheFs.Delete(fn);
1.797 + test(r == KErrNone);
1.798 +#else
1.799 + test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
1.800 +#endif // _DEBUG) || _DEBUG_RELEASE
1.801 + }
1.802 +