402 TEST2(err, KErrNone); |
402 TEST2(err, KErrNone); |
403 TEST2(fbuf.iFileWriteCount, 0); |
403 TEST2(fbuf.iFileWriteCount, 0); |
404 TEST2(fbuf.iFileWriteAmount, 0); |
404 TEST2(fbuf.iFileWriteAmount, 0); |
405 TEST2(fbuf.iFileSizeCount, 1); |
405 TEST2(fbuf.iFileSizeCount, 1); |
406 |
406 |
407 //Second write operation. The offset is 0. Data length: 12; |
407 //Second write operation. The offset is 0. Data length: 12, i.e. within the buffer - should have no write to the disk. |
408 err = fbuf.Write(0, _L8("ZZXXCCVVBBNN")); |
408 err = fbuf.Write(0, _L8("ZZXXCCVVBBNN")); |
|
409 TEST2(err, KErrNone); |
|
410 TEST2(fbuf.iFileWriteCount, 0); |
|
411 TEST2(fbuf.iFileWriteAmount, 0); |
|
412 TEST2(fbuf.iFileSizeCount, 1); |
|
413 |
|
414 //Third write operation. The offet is 18. Data length: 5. The buffer should be written out to the file |
|
415 // after "ab" is appended to the buffer. The new buffe after being emptied should have data "cde". |
|
416 err = fbuf.Write(18, _L8("abcde")); |
409 TEST2(err, KErrNone); |
417 TEST2(err, KErrNone); |
410 TEST2(fbuf.iFileWriteCount, 1); |
418 TEST2(fbuf.iFileWriteCount, 1); |
411 TEST2(fbuf.iFileWriteAmount, 20); |
419 TEST2(fbuf.iFileWriteAmount, 20); |
412 TEST2(fbuf.iFileSizeCount, 1); |
420 TEST2(fbuf.iFileSizeCount, 1); |
413 |
421 |
414 err = fbuf.Flush(); |
422 err = fbuf.Flush(); |
415 TEST2(err, KErrNone); |
423 TEST2(err, KErrNone); |
416 TEST2(fbuf.iFileWriteCount, 2); |
424 TEST2(fbuf.iFileWriteCount, 2); |
417 TEST2(fbuf.iFileFlushCount, 1); |
425 TEST2(fbuf.iFileFlushCount, 1); |
418 TEST2(fbuf.iFileWriteAmount, 20 + 12); |
426 TEST2(fbuf.iFileWriteAmount, 23); |
419 TEST2(fbuf.iFileSizeCount, 1); |
427 TEST2(fbuf.iFileSizeCount, 1); |
420 |
428 |
421 fbuf.Close(); |
429 fbuf.Close(); |
422 |
430 |
423 VerifyFileContent(_L8("ZZXXCCVVBBNN23456789")); |
431 VerifyFileContent(_L8("ZZXXCCVVBBNN234567abcde")); |
424 |
432 |
425 (void)TheFs.Delete(KTestFile); |
433 (void)TheFs.Delete(KTestFile); |
426 } |
434 } |
427 |
435 |
428 /** |
436 /** |
1254 |
1262 |
1255 (void)TheFs.Delete(KTestFile); |
1263 (void)TheFs.Delete(KTestFile); |
1256 delete databuf; |
1264 delete databuf; |
1257 } |
1265 } |
1258 |
1266 |
|
1267 /** |
|
1268 @SYMTestCaseID PDS-SQL-CT-4212 |
|
1269 @SYMTestCaseDesc RFileBuf64::Write() test. |
|
1270 The test performs file write operations using RFileBuf64 class. |
|
1271 Teh test sumilates the write operation at the conditions: |
|
1272 |
|
1273 1. There are 8 pages to be writted to the file. |
|
1274 2. Each page is 16 bytes |
|
1275 3. The size of RFileBuf64 is 4 pages, i.e. 64 bytes. |
|
1276 4. The order of write is not sequential. |
|
1277 |
|
1278 @SYMTestActions Write database pages. |
|
1279 @SYMTestExpectedResults Test must not fail |
|
1280 @SYMTestPriority High |
|
1281 */ |
|
1282 void TestSetSizeCounter() |
|
1283 { |
|
1284 const TInt KPageSize = 16; |
|
1285 const TInt KBufSize = 4 * KPageSize; |
|
1286 RFileBuf64 fbuf(KBufSize); |
|
1287 (void)TheFs.Delete(KTestFile); |
|
1288 TInt err = fbuf.Create(TheFs, KTestFile, EFileRead | EFileWrite); |
|
1289 TEST2(err, KErrNone); |
|
1290 const TInt KMaxPage = 8; |
|
1291 TUint8 fileData[KMaxPage][KPageSize]; |
|
1292 TPtrC8 pageData[KMaxPage]; |
|
1293 for(TInt i = 0;i <KMaxPage;++i) |
|
1294 { |
|
1295 Mem::Fill(fileData[i], KPageSize, TChar('a' + i)); |
|
1296 const TUint8* p = fileData[i]; |
|
1297 pageData[i].Set(p, KPageSize); |
|
1298 } |
|
1299 // |
|
1300 fbuf.ProfilerReset(); |
|
1301 //Write the first 4 pages |
|
1302 for (TInt ii = 0; ii < 4; ii++) |
|
1303 { |
|
1304 err = fbuf.Write(ii * KPageSize, pageData[ii]); |
|
1305 TEST2(err, KErrNone); |
|
1306 } |
|
1307 //Write page #2 |
|
1308 err = fbuf.Write(2 * KPageSize, pageData[2]); |
|
1309 TEST2(err, KErrNone); |
|
1310 // |
|
1311 TEST2(fbuf.iFileWriteCount, 0); |
|
1312 TEST2(fbuf.iFileSetSizeCount, 0); |
|
1313 //Write pages 5, 4, 6, 7 |
|
1314 err = fbuf.Write(5 * KPageSize, pageData[5]); |
|
1315 TEST2(err, KErrNone); |
|
1316 // |
|
1317 TEST2(fbuf.iFileWriteCount, 1); |
|
1318 TEST2(fbuf.iFileSetSizeCount, 0); |
|
1319 // |
|
1320 err = fbuf.Write(4 * KPageSize, pageData[4]); |
|
1321 TEST2(err, KErrNone); |
|
1322 err = fbuf.Write(6 * KPageSize, pageData[6]); |
|
1323 TEST2(err, KErrNone); |
|
1324 err = fbuf.Write(7 * KPageSize, pageData[7]); |
|
1325 TEST2(err, KErrNone); |
|
1326 // |
|
1327 TEST2(fbuf.iFileWriteCount, 1); |
|
1328 TEST2(fbuf.iFileSetSizeCount, 0); |
|
1329 // |
|
1330 err = fbuf.Flush(); |
|
1331 TEST2(err, KErrNone); |
|
1332 // |
|
1333 TEST2(fbuf.iFileWriteCount, 2); |
|
1334 TEST2(fbuf.iFileSetSizeCount, 0); |
|
1335 // |
|
1336 fbuf.Close(); |
|
1337 (void)TheFs.Delete(KTestFile); |
|
1338 } |
|
1339 |
1259 void DoTests() |
1340 void DoTests() |
1260 { |
1341 { |
1261 TheTest.Start(_L(" @SYMTestCaseID:PDS-SQL-UT-4132 RFileBuf64 write test 1")); |
1342 TheTest.Start(_L(" @SYMTestCaseID:PDS-SQL-UT-4132 RFileBuf64 write test 1")); |
1262 WriteTest1(); |
1343 WriteTest1(); |
1263 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4133 RFileBuf64 write test 2")); |
1344 TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4133 RFileBuf64 write test 2")); |