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 |
// Declarations for the t_localtime test. This tests functionality introduced
|
sl@0
|
15 |
// in CR1084 ie. That removable (in practice this means FAT) file systems
|
sl@0
|
16 |
// can be made to use local time for timestamps.
|
sl@0
|
17 |
//
|
sl@0
|
18 |
//
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@file
|
sl@0
|
22 |
@test
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
#ifndef T_LOCALTIME_H
|
sl@0
|
27 |
#define T_LOCALTIME_H
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <f32file.h>
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
Provides a common test interface for files and directories.
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
class CFileSystemEntry : public CBase
|
sl@0
|
37 |
{
|
sl@0
|
38 |
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
virtual ~CFileSystemEntry()=0;
|
sl@0
|
41 |
virtual TInt Delete();
|
sl@0
|
42 |
virtual TInt Create()=0;
|
sl@0
|
43 |
virtual void SetPath(const TDesC& aPath);
|
sl@0
|
44 |
virtual void SetFileServer(RFs* aFs);
|
sl@0
|
45 |
virtual TInt Open()=0;
|
sl@0
|
46 |
virtual TInt DeleteCreate();
|
sl@0
|
47 |
virtual void Close();
|
sl@0
|
48 |
virtual TTime ModificationTimeL()=0;
|
sl@0
|
49 |
virtual TInt SetModificationTime(const TTime&)=0;
|
sl@0
|
50 |
virtual TTime CreationTimeL();
|
sl@0
|
51 |
virtual CFileSystemEntry* CopyL()=0;
|
sl@0
|
52 |
virtual const TDesC& Name() const;
|
sl@0
|
53 |
|
sl@0
|
54 |
protected:
|
sl@0
|
55 |
CFileSystemEntry(const TDesC& aPath, RFs* aFs);
|
sl@0
|
56 |
RFs* iRFs; ///<A pointer to some external RFs
|
sl@0
|
57 |
TFileName iFullPath; ///<Name of the file or directory.
|
sl@0
|
58 |
TPtrC iName;
|
sl@0
|
59 |
};
|
sl@0
|
60 |
|
sl@0
|
61 |
_LIT(KTestDirectoryName, "Directory");
|
sl@0
|
62 |
/**
|
sl@0
|
63 |
Implementation of interface to directories
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
class CTestDirectory : public CFileSystemEntry
|
sl@0
|
66 |
{
|
sl@0
|
67 |
public:
|
sl@0
|
68 |
CTestDirectory(const TDesC& aPath, RFs* aFs = NULL);
|
sl@0
|
69 |
virtual TInt Open();
|
sl@0
|
70 |
virtual TInt Delete();
|
sl@0
|
71 |
virtual TInt Create();
|
sl@0
|
72 |
virtual TTime ModificationTimeL();
|
sl@0
|
73 |
virtual TInt SetModificationTime(const TTime&);
|
sl@0
|
74 |
virtual CFileSystemEntry* CopyL();
|
sl@0
|
75 |
};
|
sl@0
|
76 |
|
sl@0
|
77 |
_LIT(KTestFileRFile, "File - accessed with RFile");
|
sl@0
|
78 |
/**
|
sl@0
|
79 |
File interface, uses RFile to access mod time
|
sl@0
|
80 |
*/
|
sl@0
|
81 |
class CTestFile : public CFileSystemEntry
|
sl@0
|
82 |
{
|
sl@0
|
83 |
public:
|
sl@0
|
84 |
CTestFile(const TDesC& aPath, RFs* aFs = NULL);
|
sl@0
|
85 |
virtual TInt Open();
|
sl@0
|
86 |
virtual TInt Create();
|
sl@0
|
87 |
virtual void Close();
|
sl@0
|
88 |
virtual TTime ModificationTimeL();
|
sl@0
|
89 |
virtual TInt SetModificationTime(const TTime&);
|
sl@0
|
90 |
virtual CFileSystemEntry* CopyL();
|
sl@0
|
91 |
virtual ~CTestFile();
|
sl@0
|
92 |
|
sl@0
|
93 |
protected:
|
sl@0
|
94 |
RFile iRFile; ///< Handle to the file the class is wrapping.
|
sl@0
|
95 |
};
|
sl@0
|
96 |
|
sl@0
|
97 |
_LIT(KTestFileRFs, "File - accessed with RFs");
|
sl@0
|
98 |
/**
|
sl@0
|
99 |
File interface-uses RFs to access mod time
|
sl@0
|
100 |
*/
|
sl@0
|
101 |
class CTestFileRFs : public CTestFile
|
sl@0
|
102 |
{
|
sl@0
|
103 |
public:
|
sl@0
|
104 |
CTestFileRFs(const TDesC& aPath, RFs* aFs = NULL);
|
sl@0
|
105 |
virtual TTime ModificationTimeL();
|
sl@0
|
106 |
virtual TInt SetModificationTime(const TTime&);
|
sl@0
|
107 |
virtual ~CTestFileRFs();
|
sl@0
|
108 |
|
sl@0
|
109 |
};
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
|
sl@0
|
113 |
_LIT(KTestGroupName, "Local timestamps on removable media");
|
sl@0
|
114 |
|
sl@0
|
115 |
_LIT(KTestDir, "F32-TST\\t_localtime");
|
sl@0
|
116 |
|
sl@0
|
117 |
|
sl@0
|
118 |
//For emulator
|
sl@0
|
119 |
_LIT(KNonRemovableDrive, "Y:\\");
|
sl@0
|
120 |
_LIT(KRemovableDrive, "X:\\");
|
sl@0
|
121 |
|
sl@0
|
122 |
|
sl@0
|
123 |
_LIT(KFile,"utc-test-file");
|
sl@0
|
124 |
_LIT(KDirectory,"utc-test-dir\\");
|
sl@0
|
125 |
_LIT(KRemMedia, "removable-media");
|
sl@0
|
126 |
_LIT(KNonRemMedia, "non-removable-media");
|
sl@0
|
127 |
|
sl@0
|
128 |
|
sl@0
|
129 |
_LIT(KFatFileSystem, "Fat");
|
sl@0
|
130 |
_LIT(KFat32FileSystem, "FAT32");
|
sl@0
|
131 |
_LIT(KFat16FileSystem, "FAT16");
|
sl@0
|
132 |
|
sl@0
|
133 |
const TInt KSecondsPerHour(3600);
|
sl@0
|
134 |
const TInt KHoursOffset(6);
|
sl@0
|
135 |
const TTimeIntervalSeconds KTimeOffset(KHoursOffset*KSecondsPerHour);
|
sl@0
|
136 |
const TTimeIntervalSeconds KNullTimeOffset(0);
|
sl@0
|
137 |
const TTimeIntervalSeconds KModTimeThreshold(3); //FAT timestamp resolution is 2 seconds, +1 tolerence for delays.
|
sl@0
|
138 |
|
sl@0
|
139 |
/**
|
sl@0
|
140 |
Base class for the t_localtime tests. Defines generic test steps as well as utility
|
sl@0
|
141 |
functions. Subclassed tests implement RunTests to call specific test steps.
|
sl@0
|
142 |
|
sl@0
|
143 |
*/
|
sl@0
|
144 |
class CLocalTimeTest : public CBase
|
sl@0
|
145 |
{
|
sl@0
|
146 |
public:
|
sl@0
|
147 |
/**
|
sl@0
|
148 |
Used as a parameter to tell test what type of drive to use
|
sl@0
|
149 |
*/
|
sl@0
|
150 |
enum TDriveType
|
sl@0
|
151 |
{
|
sl@0
|
152 |
ERemovable,
|
sl@0
|
153 |
ENonRemovable
|
sl@0
|
154 |
};
|
sl@0
|
155 |
|
sl@0
|
156 |
enum TBuild
|
sl@0
|
157 |
{
|
sl@0
|
158 |
EUdeb,
|
sl@0
|
159 |
EUrel
|
sl@0
|
160 |
};
|
sl@0
|
161 |
|
sl@0
|
162 |
enum TTestType
|
sl@0
|
163 |
{
|
sl@0
|
164 |
EPositive, ///< Times are expected to be translated
|
sl@0
|
165 |
ENegative, ///<Times are expected to be preserved
|
sl@0
|
166 |
ENoTest ///<Tests won't be carried out.
|
sl@0
|
167 |
};
|
sl@0
|
168 |
|
sl@0
|
169 |
static CLocalTimeTest* NewLC(RTest& aTest, const TDesC& aDriveLetter, TBuild aBuild);
|
sl@0
|
170 |
virtual ~CLocalTimeTest();
|
sl@0
|
171 |
|
sl@0
|
172 |
void RunTestsL(); ///<Defines what steps the test will carry out.
|
sl@0
|
173 |
|
sl@0
|
174 |
/////// Generic test steps ///////////
|
sl@0
|
175 |
void TestDebugInterfaceL();
|
sl@0
|
176 |
void TestReadCreationTimeL(CFileSystemEntry* aFsEntry);
|
sl@0
|
177 |
void TestReadModificationTimeL(CFileSystemEntry* aFsEntry);
|
sl@0
|
178 |
void TestSetModificationTimeL(CFileSystemEntry* aFsEntry);
|
sl@0
|
179 |
void TestCopyL(CFileSystemEntry* aFsEntry);
|
sl@0
|
180 |
void TestCopyDirL();
|
sl@0
|
181 |
|
sl@0
|
182 |
////////Utility Functions/////////
|
sl@0
|
183 |
static TBool FuzzyTimeMatch(const TTime& aTestTime, const TTime& aRefTime);
|
sl@0
|
184 |
void LocalTimeForRemMediaOnL();
|
sl@0
|
185 |
void LocalTimeForRemMediaOffL();
|
sl@0
|
186 |
TBool IsLocalTimeOnRemMediaL();
|
sl@0
|
187 |
void PrintTimeL(const TDesC& aMessg, const TTime& aTime) const;
|
sl@0
|
188 |
const TDesC& DriveLetter() const;
|
sl@0
|
189 |
TInt DriveNumber() const;
|
sl@0
|
190 |
void PrintExpectedOffset() const;
|
sl@0
|
191 |
void PrintDrive() const;
|
sl@0
|
192 |
|
sl@0
|
193 |
protected:
|
sl@0
|
194 |
CLocalTimeTest(RTest& aTest, const TDesC& aDriveLetter, TBuild aBuild);
|
sl@0
|
195 |
void ConstructL();
|
sl@0
|
196 |
|
sl@0
|
197 |
void MakeTestPathL();
|
sl@0
|
198 |
void SetTestTypeL();
|
sl@0
|
199 |
|
sl@0
|
200 |
TDriveType iDriveType; ///< Can be removable or non-removable
|
sl@0
|
201 |
TInt iDrive; ///<Stores the number of the drive in use.
|
sl@0
|
202 |
TBuf<1> iDriveLetter; ///<Stores the letter of the drive in use.
|
sl@0
|
203 |
|
sl@0
|
204 |
CTestFile* iTestFile; ///<The file or directory to be used in the test
|
sl@0
|
205 |
CTestFileRFs* iTestFileRFs;
|
sl@0
|
206 |
CTestDirectory* iTestDirectory;
|
sl@0
|
207 |
|
sl@0
|
208 |
TPath iTestPath; ///<The absolute path of the test directory
|
sl@0
|
209 |
RTest& iTest; ///<The test to be used
|
sl@0
|
210 |
TTestType iTestType;
|
sl@0
|
211 |
TBuild iBuild;
|
sl@0
|
212 |
|
sl@0
|
213 |
/**
|
sl@0
|
214 |
The expected time difference the test expects to see between files' or directories'
|
sl@0
|
215 |
actual timestamps and the ones reported through the api. If local time timestamps are not in
|
sl@0
|
216 |
use then this member will be 0.
|
sl@0
|
217 |
*/
|
sl@0
|
218 |
TTimeIntervalSeconds iExpectedTimeStampOffset;
|
sl@0
|
219 |
|
sl@0
|
220 |
RFs iRFs; ///< File server handle for the test.
|
sl@0
|
221 |
TBool iOriginalUseLocalTimeFlag; ///<Stored at begginng of test, must be restored at end
|
sl@0
|
222 |
};
|
sl@0
|
223 |
|
sl@0
|
224 |
|
sl@0
|
225 |
/**
|
sl@0
|
226 |
Defines opcodes for RFs::ControlIO functions used. These definitions must match
|
sl@0
|
227 |
up with those in F32\sfat\inc\sl_std.h and F32\sfat32\inc\sl_std.h
|
sl@0
|
228 |
*/
|
sl@0
|
229 |
enum TUTCControlIO
|
sl@0
|
230 |
{
|
sl@0
|
231 |
ELocalTimeForRemovableMediaOn=10, ///< 10
|
sl@0
|
232 |
ELocalTimeForRemovableMediaOff=11, ///< 11
|
sl@0
|
233 |
ELocalTimeUsedOnRemovableMedia=12, ///< 12
|
sl@0
|
234 |
ECreationTime=13 ///<13
|
sl@0
|
235 |
};
|
sl@0
|
236 |
|
sl@0
|
237 |
|
sl@0
|
238 |
|
sl@0
|
239 |
#endif// T_LOCALTIME_H
|
sl@0
|
240 |
|