sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: static RTest TheTest(_L("t_dbperf3")); sl@0: static CTrapCleanup* TheTrapCleanup; sl@0: static RFs TheFs; sl@0: static RDbs TheDbs; sl@0: static RDbNamedDatabase TheDatabase; sl@0: static RDbRowSet TheRowSet, TheRowSet2; sl@0: static RFile TheTestFile; sl@0: static TFileName TheDatabaseFileName; sl@0: sl@0: #define COUNT_OF(array) (sizeof(array)/sizeof(array[0])) sl@0: sl@0: const TInt KTrackRecordCount = 200; sl@0: const TInt KCategoryRecordCount = 50; sl@0: const TInt KStatsRecordCount = 50; sl@0: const TInt KTestBlobSize = 4096; sl@0: sl@0: //_LIT(KCreateTrackTable, "CREATE TABLE TRACKS (id INTEGER, marked_2_play INTEGER, category_id INTEGER, artist_last_name CHAR(15) NOT NULL,artist_first_name CHAR(15) NOT NULL, title CHAR(16) NOT NULL,download_site CHAR(30) NOT NULL,band_name CHAR(20) NOT NULL,origin CHAR(16),autostart INTEGER, init_volume INTEGER, music_file LONG VARCHAR)"); sl@0: _LIT(KCreateTrackIndex, "CREATE INDEX IDX1 ON TRACKS(id,marked_2_play,category_id)"); sl@0: _LIT(KCreateTrackTable, "CREATE TABLE TRACKS (id INTEGER, marked_2_play INTEGER, category_id INTEGER, artist_last_name CHAR(15) NOT NULL,artist_first_name CHAR(15) NOT NULL, title CHAR(16) NOT NULL,download_site CHAR(30) NOT NULL,band_name CHAR(20) NOT NULL,origin CHAR(16),autostart INTEGER, init_volume INTEGER)"); sl@0: _LIT(KCreateTrackTable2, "CREATE TABLE TRACKS2 (id INTEGER, music_file LONG VARCHAR)"); sl@0: //_LIT(KCreateTrackIndex2, "CREATE INDEX IDX4 ON TRACKS2(id)"); sl@0: sl@0: //_LIT(KTrackTable,"TRACKS"); sl@0: sl@0: _LIT(KId,"id"); sl@0: _LIT(KLastName,"artist_last_name"); sl@0: _LIT(KFirstName,"artist_first_name"); sl@0: _LIT(KTitle,"title"); sl@0: _LIT(KDownloadSite,"download_site"); sl@0: _LIT(KBandName,"band_name"); sl@0: _LIT(KOrigin,"origin"); sl@0: _LIT(KAutoStart,"autostart"); sl@0: _LIT(KInitVolume,"init_volume"); sl@0: _LIT(KMarked2Play,"marked_2_play"); sl@0: _LIT(KCategoryId,"category_id"); sl@0: _LIT(KMusicFile,"music_file"); sl@0: sl@0: sl@0: //category Table LITS sl@0: _LIT(KCreateCategoryTable, "CREATE TABLE CATEGORY (category_id INTEGER,category_name CHAR(20),genre INTEGER)"); sl@0: _LIT(KCreateCategoryIndex, "CREATE INDEX IDX2 ON CATEGORY(category_id)"); sl@0: sl@0: //_LIT(KCategoryTable,"CATEGORY"); sl@0: sl@0: //KCategoryId defined for category table sl@0: _LIT(KCategoryName,"category_name"); sl@0: _LIT(KGenre,"genre"); sl@0: sl@0: sl@0: //STATS Table LITS sl@0: _LIT(KCreatestatsTable, "CREATE TABLE STATS (category_id INTEGER, no_of_tracks INTEGER, no_autostart INTEGER,no_manualstart INTEGER,no_marked_2_play INTEGER, no_unmarked_2_play INTEGER, size_of_musicfiles INTEGER)"); sl@0: _LIT(KCreatestatsIndex, "CREATE UNIQUE INDEX IDX3 ON STATS(category_id)"); sl@0: sl@0: //_LIT(KStatsTable,"STATS"); sl@0: sl@0: //KCategoryId defined for category table sl@0: _LIT(KNoOfTracks,"no_of_tracks"); sl@0: _LIT(KNoMarked2Play,"no_marked_2_play"); sl@0: _LIT(KNoUnmarked2Play,"no_unmarked_2_play"); sl@0: _LIT(KNoAutostart,"no_autostart"); sl@0: _LIT(KNoManualStart,"no_manualstart"); sl@0: _LIT(KSizeOfMusicFiles,"size_of_musicfiles"); sl@0: sl@0: ////////////////////////////////////////////////////// sl@0: sl@0: static TInt TheCounterFreq = -10000000; sl@0: const TInt KMicroSecIn1Sec = 1000000; sl@0: sl@0: TUint32 CalcTickDiff(TUint32 aStartTicks, TUint32 aEndTicks) sl@0: { sl@0: TInt64 diffTicks = (TInt64)aEndTicks - (TInt64)aStartTicks; sl@0: if(diffTicks < 0) sl@0: { sl@0: diffTicks = KMaxTUint32 + diffTicks + 1; sl@0: } sl@0: return (TUint32)diffTicks; sl@0: } sl@0: sl@0: //Prints aFastCount parameter (converted to us) sl@0: void PrintFcDiffAsUs(const TDesC& aFormatStr, TUint32 aFastCount) sl@0: { sl@0: double v = ((double)aFastCount * KMicroSecIn1Sec) / (double)TheCounterFreq; sl@0: TInt v2 = (TInt)v; sl@0: TheTest.Printf(aFormatStr, v2); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: //Delete "aFullName" file. sl@0: static void DeleteFile(const TDesC& aFullName) sl@0: { sl@0: RFs fsSession; sl@0: TInt err = fsSession.Connect(); sl@0: if(err == KErrNone) sl@0: { sl@0: TEntry entry; sl@0: if(fsSession.Entry(aFullName, entry) == KErrNone) sl@0: { sl@0: err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly); sl@0: if(err != KErrNone) sl@0: { sl@0: TheTest.Printf(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName); sl@0: } sl@0: err = fsSession.Delete(aFullName); sl@0: if(err != KErrNone) sl@0: { sl@0: TheTest.Printf(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName); sl@0: } sl@0: } sl@0: fsSession.Close(); sl@0: } sl@0: else sl@0: { sl@0: TheTest.Printf(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName); sl@0: } sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: static void CloseAll() sl@0: { sl@0: TheRowSet2.Close(); sl@0: TheRowSet.Close(); sl@0: TheDatabase.Close(); sl@0: TheDbs.Close(); sl@0: TheFs.Close(); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: //Tests macros and functions. sl@0: //If (!aValue) then the test will be panicked, the test data files will be deleted. sl@0: static void Check(TInt aValue, TInt aLine) sl@0: { sl@0: if(!aValue) sl@0: { sl@0: CloseAll(); sl@0: DeleteFile(TheDatabaseFileName); sl@0: TheTest(EFalse, aLine); sl@0: } sl@0: } sl@0: //If (aValue != aExpected) then the test will be panicked, the test data files will be deleted. sl@0: static void Check(TInt aValue, TInt aExpected, TInt aLine) sl@0: { sl@0: if(aValue != aExpected) sl@0: { sl@0: TheTest.Printf(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); sl@0: CloseAll(); sl@0: DeleteFile(TheDatabaseFileName); sl@0: TheTest(EFalse, aLine); sl@0: } sl@0: } sl@0: //Use these to test conditions. sl@0: #define TEST(arg) ::Check((arg), __LINE__) sl@0: #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: void PrintFileSize() sl@0: { sl@0: RDbDatabase::TSize s = TheDatabase.Size(); sl@0: TheTest.Printf(_L("####FileSize: %d\r\n"), s.iSize); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: void FillRandomData(TDes& aData, TInt64 aSeed) sl@0: { sl@0: aData.Zero(); sl@0: for (TInt i=0; iDes()); sl@0: FillRandomData(randomData); sl@0: sl@0: RDbView view; sl@0: TInt err = view.Prepare(TheDatabase, _L("select * from TRACKS"), view.EInsertOnly); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: sl@0: CDbColSet* colSet = TheRowSet.ColSetL(); sl@0: const TInt KIdIdx = colSet->ColNo(KId); sl@0: const TInt KLastNameIdx = colSet->ColNo(KLastName); sl@0: const TInt KFirstNameIdx = colSet->ColNo(KFirstName); sl@0: const TInt KTitleIdx = colSet->ColNo(KTitle); sl@0: const TInt KDownloadSiteIdx = colSet->ColNo(KDownloadSite); sl@0: const TInt KBandNameIdx = colSet->ColNo(KBandName); sl@0: const TInt KOriginIdx = colSet->ColNo(KOrigin); sl@0: const TInt KAutoStartIdx = colSet->ColNo(KAutoStart); sl@0: const TInt KInitVolumeIdx = colSet->ColNo(KInitVolume); sl@0: const TInt KMarkedToPlayIdx = colSet->ColNo(KMarked2Play); sl@0: const TInt KCategoryIdIdx = colSet->ColNo(KCategoryId); sl@0: //const TInt KMusicFileIdx = colSet->ColNo(KMusicFile); sl@0: delete colSet; sl@0: colSet = NULL; sl@0: sl@0: err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: for (TInt ii=1;ii<=KTrackRecordCount;++ii) sl@0: { sl@0: TheRowSet.InsertL(); sl@0: TheRowSet.SetColL(KIdIdx, ii); sl@0: TheRowSet.SetColL(KLastNameIdx, _L("Dummy")); sl@0: TheRowSet.SetColL(KFirstNameIdx,_L("Dummy")); sl@0: TheRowSet.SetColL(KTitleIdx,_L("Dummy")); sl@0: TheRowSet.SetColL(KDownloadSiteIdx,_L("Dummy")); sl@0: TheRowSet.SetColL(KBandNameIdx,_L("Dummy")); sl@0: TheRowSet.SetColL(KOriginIdx,_L("Dummy")); sl@0: TheRowSet.SetColL(KAutoStartIdx,(ii%2)); sl@0: TheRowSet.SetColL(KInitVolumeIdx,(ii%2)); sl@0: TheRowSet.SetColL(KMarkedToPlayIdx,(ii%2)); sl@0: TheRowSet.SetColL(KCategoryIdIdx,(ii%KCategoryRecordCount)); sl@0: sl@0: //RDbColWriteStream musicfile; sl@0: //musicfile.OpenLC(TheRowSet, KMusicFileIdx); sl@0: //musicfile.WriteL(randomData,KTestBlobSize); sl@0: //musicfile.CommitL(); sl@0: //CleanupStack::PopAndDestroy(&musicfile); sl@0: sl@0: TheRowSet.PutL(); sl@0: } sl@0: sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //err = TheDatabase.Compact(); sl@0: //TEST2(err, KErrNone); sl@0: sl@0: TheRowSet.Close(); sl@0: sl@0: //////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: err = view.Prepare(TheDatabase, _L("select * from TRACKS2"), view.EInsertOnly); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: sl@0: colSet = TheRowSet.ColSetL(); sl@0: const TInt KIdIdx2 = colSet->ColNo(KId); sl@0: const TInt KMusicFileIdx2 = colSet->ColNo(KMusicFile); sl@0: delete colSet; sl@0: sl@0: err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: for (TInt ii=1;ii<=KTrackRecordCount;++ii) sl@0: { sl@0: TheRowSet.InsertL(); sl@0: TheRowSet.SetColL(KIdIdx2, ii); sl@0: sl@0: RDbColWriteStream musicfile; sl@0: musicfile.OpenLC(TheRowSet, KMusicFileIdx2); sl@0: musicfile.WriteL(randomData,KTestBlobSize); sl@0: musicfile.CommitL(); sl@0: CleanupStack::PopAndDestroy(&musicfile); sl@0: sl@0: TheRowSet.PutL(); sl@0: } sl@0: sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //err = TheDatabase.Compact(); sl@0: //TEST2(err, KErrNone); sl@0: sl@0: TheRowSet.Close(); sl@0: sl@0: CleanupStack::PopAndDestroy(randomDataBuf); sl@0: } sl@0: sl@0: void InsertCategoryTableL() sl@0: { sl@0: RDbView view; sl@0: TInt err = view.Prepare(TheDatabase, _L("select * from CATEGORY"), view.EInsertOnly); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: sl@0: CDbColSet* colSet = TheRowSet.ColSetL(); sl@0: const TInt KCategoryIdIdx = colSet->ColNo(KCategoryId); sl@0: const TInt KCategoryNameIdx = colSet->ColNo(KCategoryName); sl@0: const TInt KGenreIdx = colSet->ColNo(KGenre); sl@0: delete colSet; sl@0: sl@0: err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: for (TInt ii=1;ii<=KCategoryRecordCount;++ii) sl@0: { sl@0: TheRowSet.InsertL(); sl@0: TheRowSet.SetColL(KCategoryIdIdx, ii); sl@0: TheRowSet.SetColL(KCategoryNameIdx, _L("History")); sl@0: TheRowSet.SetColL(KGenreIdx,(ii*500)); sl@0: TheRowSet.PutL(); sl@0: } sl@0: sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //err = TheDatabase.Compact(); sl@0: //TEST2(err, KErrNone); sl@0: sl@0: TheRowSet.Close(); sl@0: } sl@0: sl@0: void InsertStatsTableL() sl@0: { sl@0: RDbView view; sl@0: TInt err = view.Prepare(TheDatabase, _L("select * from STATS"), view.EInsertOnly); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: sl@0: CDbColSet* colSet = TheRowSet.ColSetL(); sl@0: const TInt KCategoryIdIdx = colSet->ColNo(KCategoryId); sl@0: const TInt KTrackCntIdx = colSet->ColNo(KNoOfTracks); sl@0: const TInt KMarkedToPlayCntIdx = colSet->ColNo(KNoMarked2Play); sl@0: const TInt KUnmarkedToPlayCntIdx = colSet->ColNo(KNoUnmarked2Play); sl@0: const TInt KAutoStartCntIdx = colSet->ColNo(KNoAutostart); sl@0: const TInt KManualStartCntIdx = colSet->ColNo(KNoManualStart); sl@0: const TInt KSizeMusicFilesIdx = colSet->ColNo(KSizeOfMusicFiles); sl@0: delete colSet; sl@0: sl@0: TInt default_Stat = 0; sl@0: sl@0: err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: for (TInt ii=0;ii& aTracks) sl@0: { sl@0: TUint32 fc = User::FastCounter(); sl@0: RDbView view; sl@0: TUint32 fc2 = User::FastCounter(); sl@0: TInt err = view.Prepare(TheDatabase, _L("select id from TRACKS"), view.EReadOnly); sl@0: TEST2(err, KErrNone); sl@0: PrintFcDiffAsUs(_L("###\"Prepare()\",time=%d us\r\n"), CalcTickDiff(fc2, User::FastCounter())); sl@0: fc2 = User::FastCounter(); sl@0: err = view.EvaluateAll(); sl@0: TEST2(err, KErrNone); sl@0: PrintFcDiffAsUs(_L("###\"EvaluateAll()\",time=%d us\r\n"), CalcTickDiff(fc2, User::FastCounter())); sl@0: TheRowSet = view; sl@0: sl@0: TUint32 diff1 = 0, diff2 = 0; sl@0: TInt count = 0; sl@0: while(count < aCount) sl@0: { sl@0: fc2 = User::FastCounter(); sl@0: if(!TheRowSet.NextL()) sl@0: { sl@0: break; sl@0: } sl@0: diff1 += CalcTickDiff(fc2, User::FastCounter()); sl@0: fc2 = User::FastCounter(); sl@0: TheRowSet.GetL(); sl@0: diff2 += CalcTickDiff(fc2, User::FastCounter()); sl@0: aTracks.Append(TheRowSet.ColInt(1)); sl@0: ++count; sl@0: } sl@0: TEST2(count, aCount); sl@0: PrintFcDiffAsUs(_L("###\"Total NextL()\",time=%d us\r\n"), diff1); sl@0: PrintFcDiffAsUs(_L("###\"Total GetL()\",time=%d us\r\n"), diff2); sl@0: sl@0: fc2 = User::FastCounter(); sl@0: TheRowSet.Close(); sl@0: PrintFcDiffAsUs(_L("###\"Close()\",time=%d us\r\n"), CalcTickDiff(fc2, User::FastCounter())); sl@0: PrintFcDiffAsUs(_L("###\"SELECT FROM TRACKS\",time=%d us\r\n"), CalcTickDiff(fc, User::FastCounter())); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-DBMS-UT-4009 sl@0: @SYMTestCaseDesc DBMS performance tests. sl@0: @SYMTestPriority High sl@0: @SYMTestActions The test opens the test database and: sl@0: - selects the ids of the tracks to be deleted and collects them into an array; sl@0: - deletes the recods with matching track ids from TRACK table; sl@0: - deletes the recods with matching track ids from TRACK2 table; sl@0: The execution times are printed out. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ7141 sl@0: */ sl@0: void DeleteTracksL() sl@0: { sl@0: TheTest.Printf(_L("Record count: %d\r\n"), KTrackRecordCount); sl@0: sl@0: RArray tracks; sl@0: tracks.ReserveL(KTrackRecordCount); sl@0: CleanupClosePushL(tracks); sl@0: SelectTracksL(KTrackRecordCount, tracks); sl@0: // sl@0: _LIT(KDeleteSql, "DELETE FROM tracks WHERE id>=%d AND id<=%d"); sl@0: sl@0: TBuf<100> sql; sl@0: sql.Format(KDeleteSql, tracks[0], tracks[tracks.Count() - 1]); sl@0: sl@0: TUint32 fc2 = User::FastCounter(); sl@0: sl@0: TInt err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: TUint32 fc = User::FastCounter(); sl@0: TInt rc = TheDatabase.Execute(sql); sl@0: PrintFcDiffAsUs(_L("###\"DELETE FROM TRACKS\",time=%d us\r\n"), CalcTickDiff(fc, User::FastCounter())); sl@0: TEST2(rc, KTrackRecordCount); sl@0: TheTest.Printf(_L("Deleted record count: %d\r\n"), rc); sl@0: sl@0: sql.Replace(12, 6, _L("TRACKS2")); sl@0: fc = User::FastCounter(); sl@0: rc = TheDatabase.Execute(sql); sl@0: PrintFcDiffAsUs(_L("###\"DELETE FROM TRACKS2\",time=%d us\r\n"), CalcTickDiff(fc, User::FastCounter())); sl@0: TEST2(rc, KTrackRecordCount); sl@0: TheTest.Printf(_L("Deleted record count: %d\r\n"), rc); sl@0: sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: PrintFcDiffAsUs(_L("###Total \"DELETE FROM TRACKS\",time=%d us\r\n"), CalcTickDiff(fc2, User::FastCounter())); sl@0: sl@0: CleanupStack::PopAndDestroy(&tracks); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: //This test checks how RDbDatabase::Commit() works if there are some active RDbRowSet objects - sl@0: //read-only and updatable. The expectation is that the Commit() call won't fail, the RDbRowSet objects sl@0: //retain their pre-commit positions. sl@0: void CommitTestL() sl@0: { sl@0: //Create 2 test tables, insert some records in the first table sl@0: TheDatabase.Close(); sl@0: TInt err = TheDatabase.Replace(TheFs, TheDatabaseFileName); sl@0: TEST2(err, KErrNone); sl@0: err = TheDatabase.Execute(_L("CREATE TABLE AA1(Id INTEGER)")); sl@0: TEST2(err, KErrNone); sl@0: err = TheDatabase.Execute(_L("CREATE TABLE AA2(Id INTEGER)")); sl@0: TEST2(err, KErrNone); sl@0: err = TheDatabase.Execute(_L("INSERT INTO AA1(Id) VALUES(1)")); sl@0: TEST2(err, 1); sl@0: err = TheDatabase.Execute(_L("INSERT INTO AA1(Id) VALUES(2)")); sl@0: TEST2(err, 1); sl@0: err = TheDatabase.Execute(_L("INSERT INTO AA1(Id) VALUES(3)")); sl@0: TEST2(err, 1); sl@0: //Begin transaction sl@0: err = TheDatabase.Begin(); sl@0: TEST2(err, KErrNone); sl@0: //Prepare read-only view and call FirstL() (TheRowSet object) sl@0: RDbView view; sl@0: err = view.Prepare(TheDatabase, _L("select * from AA1"), RDbRowSet::EReadOnly); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet = view; sl@0: err = view.EvaluateAll(); //DBMS can use FirstL() without the EvaluateAll() call in this case sl@0: TEST2(err, KErrNone); sl@0: TBool rc = TheRowSet.FirstL(); sl@0: TEST(rc); sl@0: //Prepare updatable view and call NextL() (TheRowSet2 object) sl@0: err = view.Prepare(TheDatabase, _L("select * from AA1"), RDbRowSet::EUpdatable); sl@0: TEST2(err, KErrNone); sl@0: TheRowSet2 = view; sl@0: err = view.EvaluateAll(); //DBMS can use NextL() without the EvaluateAll() call in this case sl@0: TEST2(err, KErrNone); sl@0: rc = TheRowSet2.FirstL(); sl@0: TEST(rc); sl@0: rc = TheRowSet2.NextL(); sl@0: TEST(rc); sl@0: //Execute one INSERT statement sl@0: err = TheDatabase.Execute(_L("INSERT INTO AA2(Id) VALUES(1)")); sl@0: TEST2(err, 1); sl@0: //Commit transaction sl@0: err = TheDatabase.Commit(); sl@0: TEST2(err, KErrNone); sl@0: //Check the retrieved by TheRowSet record sl@0: TheRowSet.GetL(); sl@0: TEST2(TheRowSet.ColInt(1), 1); sl@0: //Check the retrieved by TheRowSet2 record sl@0: TheRowSet2.GetL(); sl@0: TEST2(TheRowSet2.ColInt(1), 2); sl@0: //Cleanup sl@0: TheRowSet2.Close(); sl@0: TheRowSet.Close(); sl@0: TheDatabase.Close(); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: void DoTestL() sl@0: { sl@0: TheTest.Start(_L("Get fast counter frequency")); sl@0: GetFastCounterFrequency(); sl@0: sl@0: TheTest.Next(_L("Create&Fill test database")); sl@0: CreateDatabase(); sl@0: FillDatabaseL(); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:PDS-DBMS-UT-4009 Delete tracks")); sl@0: DeleteTracksL(); sl@0: sl@0: TheTest.Next(_L("Commit() test (not a performance test)")); sl@0: CommitTestL(); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: //Usage: "t_dbperf3 [:]" sl@0: TInt E32Main() sl@0: { sl@0: TheTest.Title(); sl@0: sl@0: TheTrapCleanup = CTrapCleanup::New(); sl@0: TEST(TheTrapCleanup != NULL); sl@0: sl@0: //Construct test database file name sl@0: _LIT(KTestDatabase, "c:\\dbms-tst\\t_dbperf3.db"); sl@0: TFileName fname; sl@0: User::CommandLine(fname); sl@0: TParse parse; sl@0: parse.Set(fname, &KTestDatabase, 0); sl@0: const TDesC& dbFilePath = parse.FullName(); sl@0: TheDatabaseFileName.Copy(dbFilePath); sl@0: TheTest.Printf(_L("Test database: %S\r\n"), &TheDatabaseFileName); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TInt err = TheFs.Connect(); sl@0: TEST2(err, KErrNone); sl@0: err = TheFs.MkDir(TheDatabaseFileName); sl@0: TheTest.Printf(_L("MkDir(): err=%d\r\n"), err); sl@0: TEST(err == KErrNone || err == KErrAlreadyExists); sl@0: sl@0: DeleteFile(TheDatabaseFileName); sl@0: sl@0: TRAP(err, DoTestL()); sl@0: TEST2(err, KErrNone); sl@0: sl@0: CloseAll(); sl@0: DeleteFile(TheDatabaseFileName); sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: TheTest.End(); sl@0: TheTest.Close(); sl@0: sl@0: delete TheTrapCleanup; sl@0: return KErrNone; sl@0: }