46 @param aFileName the constant descriptor containing the filepath as specified by the user. |
46 @param aFileName the constant descriptor containing the filepath as specified by the user. |
47 @param aAppend is the TBool controlling whether files should be appended to or overwritten |
47 @param aAppend is the TBool controlling whether files should be appended to or overwritten |
48 ETrue=Append, EFalse=Overwrite |
48 ETrue=Append, EFalse=Overwrite |
49 @return KErrNone if command was prepared correctly and a system wide error code otherwise. |
49 @return KErrNone if command was prepared correctly and a system wide error code otherwise. |
50 */ |
50 */ |
51 TInt CUptCsvGenerator::Open(const TDesC& aFileName, const TBool& aAppend) |
51 TInt CUptCsvGenerator::OpenL(const TDesC& aFileName, const TBool& aAppend) |
52 { |
52 { |
53 |
53 |
54 iCsvFileSession.Connect(); |
54 iCsvFileSession.Connect(); |
55 //if the user has set for the file to be overwritten if it already exists |
55 //if the user has set for the file to be overwritten if it already exists |
56 //then this part with ensure this is carried out with write permissions |
56 //then this part with ensure this is carried out with write permissions |
87 |
87 |
88 /** This user-side method uses the RFile Session methods to find the end of the file described by iCSVFile and |
88 /** This user-side method uses the RFile Session methods to find the end of the file described by iCSVFile and |
89 appends a newline character. |
89 appends a newline character. |
90 @return KErrNone if command was prepared correctly and a system wide error code otherwise. |
90 @return KErrNone if command was prepared correctly and a system wide error code otherwise. |
91 */ |
91 */ |
92 TInt CUptCsvGenerator::WriteNewLine() |
92 TInt CUptCsvGenerator::WriteNewLineL() |
93 { |
93 { |
94 TInt filesize; |
94 TInt filesize; |
95 |
95 |
96 // find end of this file, and append the newline data field from here. |
96 // find end of this file, and append the newline data field from here. |
97 iCsvFile.Size(filesize); |
97 iCsvFile.Size(filesize); |
209 /** This user-side method writes the column titles (from the KLit string defined in the relevent test.cpp |
209 /** This user-side method writes the column titles (from the KLit string defined in the relevent test.cpp |
210 to the user-specified csv file, according to the parameters for aTestType. |
210 to the user-specified csv file, according to the parameters for aTestType. |
211 @param aTestType is the enum identifier for the test in question |
211 @param aTestType is the enum identifier for the test in question |
212 @return KErrNone if command was prepared correctly and a system wide error code otherwise. |
212 @return KErrNone if command was prepared correctly and a system wide error code otherwise. |
213 */ |
213 */ |
214 TInt CUptCsvGenerator::WriteHeader(const TInt& aTestType) |
214 TInt CUptCsvGenerator::WriteHeaderL(const TInt& aTestType) |
215 { |
215 { |
216 RBuf8 buf; |
216 RBuf8 buf; |
217 CleanupClosePushL(buf); |
217 CleanupClosePushL(buf); |
218 |
218 |
219 TInt numbytes = 0; |
219 TInt numbytes = 0; |
292 |
292 |
293 // what tests does it do? |
293 // what tests does it do? |
294 |
294 |
295 @return KErrNone if command was prepared correctly and system wide error code otherwise. |
295 @return KErrNone if command was prepared correctly and system wide error code otherwise. |
296 */ |
296 */ |
297 TInt CUptCsvGenerator::Test() |
297 TInt CUptCsvGenerator::TestL() |
298 { |
298 { |
299 //define filepaths for the test csv files according to the test platform. |
299 //define filepaths for the test csv files according to the test platform. |
300 #ifdef __WINSCW__ |
300 #ifdef __WINSCW__ |
301 _LIT(KTestFileAppend, "c:\\te_CSVoutputfileAppend.csv"); |
301 _LIT(KTestFileAppend, "c:\\te_CSVoutputfileAppend.csv"); |
302 _LIT(KTestFileOverwrite, "c:\\te_CSVoutputfileOverwrite.csv"); |
302 _LIT(KTestFileOverwrite, "c:\\te_CSVoutputfileOverwrite.csv"); |
336 // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 |
336 // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 |
337 // 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000 |
337 // 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000 |
338 TInt appendcount=3; |
338 TInt appendcount=3; |
339 for(TInt i=0; i!=appendcount;i++) |
339 for(TInt i=0; i!=appendcount;i++) |
340 { |
340 { |
341 Open(KTestFileAppend, ETrue); |
341 OpenL(KTestFileAppend, ETrue); |
342 WriteL(atestdata1); |
342 WriteL(atestdata1); |
343 WriteNewLine(); |
343 WriteNewLineL(); |
344 WriteL(atestdata2); |
344 WriteL(atestdata2); |
345 WriteNewLine(); |
345 WriteNewLineL(); |
346 Close(); |
346 Close(); |
347 } |
347 } |
348 |
348 |
349 |
349 |
350 //test the overwrite data option - outputfile should contain only 2 lines of data of the form: |
350 //test the overwrite data option - outputfile should contain only 2 lines of data of the form: |
351 // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 |
351 // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 |
352 // 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000 |
352 // 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000 |
353 for(TInt i=0; i!=appendcount;i++) |
353 for(TInt i=0; i!=appendcount;i++) |
354 { |
354 { |
355 Open(KTestFileOverwrite, EFalse); |
355 OpenL(KTestFileOverwrite, EFalse); |
356 WriteL(atestdata1); |
356 WriteL(atestdata1); |
357 WriteNewLine(); |
357 WriteNewLineL(); |
358 WriteL(atestdata2); |
358 WriteL(atestdata2); |
359 WriteNewLine(); |
359 WriteNewLineL(); |
360 Close(); |
360 Close(); |
361 } |
361 } |
362 |
362 |
363 // read the files back to check they are valid, as an automated check |
363 // read the files back to check they are valid, as an automated check |
364 |
364 |