Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Declarations for the t_localtime test. This tests functionality introduced
15 // in CR1084 ie. That removable (in practice this means FAT) file systems
16 // can be made to use local time for timestamps.
34 Provides a common test interface for files and directories.
36 class CFileSystemEntry : public CBase
40 virtual ~CFileSystemEntry()=0;
41 virtual TInt Delete();
42 virtual TInt Create()=0;
43 virtual void SetPath(const TDesC& aPath);
44 virtual void SetFileServer(RFs* aFs);
45 virtual TInt Open()=0;
46 virtual TInt DeleteCreate();
48 virtual TTime ModificationTimeL()=0;
49 virtual TInt SetModificationTime(const TTime&)=0;
50 virtual TTime CreationTimeL();
51 virtual CFileSystemEntry* CopyL()=0;
52 virtual const TDesC& Name() const;
55 CFileSystemEntry(const TDesC& aPath, RFs* aFs);
56 RFs* iRFs; ///<A pointer to some external RFs
57 TFileName iFullPath; ///<Name of the file or directory.
61 _LIT(KTestDirectoryName, "Directory");
63 Implementation of interface to directories
65 class CTestDirectory : public CFileSystemEntry
68 CTestDirectory(const TDesC& aPath, RFs* aFs = NULL);
70 virtual TInt Delete();
71 virtual TInt Create();
72 virtual TTime ModificationTimeL();
73 virtual TInt SetModificationTime(const TTime&);
74 virtual CFileSystemEntry* CopyL();
77 _LIT(KTestFileRFile, "File - accessed with RFile");
79 File interface, uses RFile to access mod time
81 class CTestFile : public CFileSystemEntry
84 CTestFile(const TDesC& aPath, RFs* aFs = NULL);
86 virtual TInt Create();
88 virtual TTime ModificationTimeL();
89 virtual TInt SetModificationTime(const TTime&);
90 virtual CFileSystemEntry* CopyL();
94 RFile iRFile; ///< Handle to the file the class is wrapping.
97 _LIT(KTestFileRFs, "File - accessed with RFs");
99 File interface-uses RFs to access mod time
101 class CTestFileRFs : public CTestFile
104 CTestFileRFs(const TDesC& aPath, RFs* aFs = NULL);
105 virtual TTime ModificationTimeL();
106 virtual TInt SetModificationTime(const TTime&);
107 virtual ~CTestFileRFs();
113 _LIT(KTestGroupName, "Local timestamps on removable media");
115 _LIT(KTestDir, "F32-TST\\t_localtime");
119 _LIT(KNonRemovableDrive, "Y:\\");
120 _LIT(KRemovableDrive, "X:\\");
123 _LIT(KFile,"utc-test-file");
124 _LIT(KDirectory,"utc-test-dir\\");
125 _LIT(KRemMedia, "removable-media");
126 _LIT(KNonRemMedia, "non-removable-media");
129 _LIT(KFatFileSystem, "Fat");
130 _LIT(KFat32FileSystem, "FAT32");
131 _LIT(KFat16FileSystem, "FAT16");
133 const TInt KSecondsPerHour(3600);
134 const TInt KHoursOffset(6);
135 const TTimeIntervalSeconds KTimeOffset(KHoursOffset*KSecondsPerHour);
136 const TTimeIntervalSeconds KNullTimeOffset(0);
137 const TTimeIntervalSeconds KModTimeThreshold(3); //FAT timestamp resolution is 2 seconds, +1 tolerence for delays.
140 Base class for the t_localtime tests. Defines generic test steps as well as utility
141 functions. Subclassed tests implement RunTests to call specific test steps.
144 class CLocalTimeTest : public CBase
148 Used as a parameter to tell test what type of drive to use
164 EPositive, ///< Times are expected to be translated
165 ENegative, ///<Times are expected to be preserved
166 ENoTest ///<Tests won't be carried out.
169 static CLocalTimeTest* NewLC(RTest& aTest, const TDesC& aDriveLetter, TBuild aBuild);
170 virtual ~CLocalTimeTest();
172 void RunTestsL(); ///<Defines what steps the test will carry out.
174 /////// Generic test steps ///////////
175 void TestDebugInterfaceL();
176 void TestReadCreationTimeL(CFileSystemEntry* aFsEntry);
177 void TestReadModificationTimeL(CFileSystemEntry* aFsEntry);
178 void TestSetModificationTimeL(CFileSystemEntry* aFsEntry);
179 void TestCopyL(CFileSystemEntry* aFsEntry);
182 ////////Utility Functions/////////
183 static TBool FuzzyTimeMatch(const TTime& aTestTime, const TTime& aRefTime);
184 void LocalTimeForRemMediaOnL();
185 void LocalTimeForRemMediaOffL();
186 TBool IsLocalTimeOnRemMediaL();
187 void PrintTimeL(const TDesC& aMessg, const TTime& aTime) const;
188 const TDesC& DriveLetter() const;
189 TInt DriveNumber() const;
190 void PrintExpectedOffset() const;
191 void PrintDrive() const;
194 CLocalTimeTest(RTest& aTest, const TDesC& aDriveLetter, TBuild aBuild);
197 void MakeTestPathL();
200 TDriveType iDriveType; ///< Can be removable or non-removable
201 TInt iDrive; ///<Stores the number of the drive in use.
202 TBuf<1> iDriveLetter; ///<Stores the letter of the drive in use.
204 CTestFile* iTestFile; ///<The file or directory to be used in the test
205 CTestFileRFs* iTestFileRFs;
206 CTestDirectory* iTestDirectory;
208 TPath iTestPath; ///<The absolute path of the test directory
209 RTest& iTest; ///<The test to be used
214 The expected time difference the test expects to see between files' or directories'
215 actual timestamps and the ones reported through the api. If local time timestamps are not in
216 use then this member will be 0.
218 TTimeIntervalSeconds iExpectedTimeStampOffset;
220 RFs iRFs; ///< File server handle for the test.
221 TBool iOriginalUseLocalTimeFlag; ///<Stored at begginng of test, must be restored at end
226 Defines opcodes for RFs::ControlIO functions used. These definitions must match
227 up with those in F32\sfat\inc\sl_std.h and F32\sfat32\inc\sl_std.h
231 ELocalTimeForRemovableMediaOn=10, ///< 10
232 ELocalTimeForRemovableMediaOff=11, ///< 11
233 ELocalTimeUsedOnRemovableMedia=12, ///< 12
234 ECreationTime=13 ///<13
239 #endif// T_LOCALTIME_H