1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
15 |
15 |
16 #include <e32test.h> |
16 #include <e32test.h> |
17 #include <bautils.h> |
17 #include <bautils.h> |
18 #include <sqldb.h> |
18 #include <sqldb.h> |
19 #include <hal.h> |
19 #include <hal.h> |
|
20 #include "t_sqlcmdlineutil.h" |
20 |
21 |
21 /////////////////////////////////////////////////////////////////////////////////////// |
22 /////////////////////////////////////////////////////////////////////////////////////// |
22 |
23 |
23 RTest TheTest(_L("t_sqlperformance4 test")); |
24 RTest TheTest(_L("t_sqlperformance4 test")); |
24 RSqlDatabase TheDbC; |
25 RSqlDatabase TheDbC; |
25 RFs TheFs; |
26 RFs TheFs; |
26 |
27 |
27 _LIT(KCDriveDatabase, "c:[a000017f]t_sqlperformance4.db"); |
28 _LIT(KCDriveDatabase, "c:[a000017f]t_sqlperformance4.db"); |
28 |
29 |
29 TFileName TheDbFileName; |
30 TFileName TheDbFileName; |
30 TBuf<256> TheCmd; |
31 TBuf<200> TheTestTitle; |
31 TDriveName TheDriveName; |
32 TCmdLineParams TheCmdLineParams; |
32 TParse TheParse; |
33 TBuf8<200> TheSqlConfigString; |
33 |
34 |
34 _LIT8( KMCSqlConfig, "cache_size=1024; page_size=1024; " ); |
35 _LIT(KUtf8, "UTF8 "); |
|
36 _LIT(KUtf16, "UTF16"); |
35 |
37 |
36 _LIT(KMusicCreateTable, "CREATE TABLE Music(" |
38 _LIT(KMusicCreateTable, "CREATE TABLE Music(" |
37 L"UniqueId INTEGER PRIMARY KEY," |
39 L"UniqueId INTEGER PRIMARY KEY," |
38 L"DbFlag INTEGER," |
40 L"DbFlag INTEGER," |
39 L"VolumeId INTEGER," |
41 L"VolumeId INTEGER," |
192 User::LeaveIfError(securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, readPolicy)); |
194 User::LeaveIfError(securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, readPolicy)); |
193 User::LeaveIfError(securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, writePolicy)); |
195 User::LeaveIfError(securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, writePolicy)); |
194 |
196 |
195 TheTest.Printf(_L("Creating Database %S\n"), &aDbName); |
197 TheTest.Printf(_L("Creating Database %S\n"), &aDbName); |
196 |
198 |
197 TInt err = TheDbC.Create(aDbName, securityPolicy, &KMCSqlConfig); |
199 TInt err = TheDbC.Create(aDbName, securityPolicy, &TheSqlConfigString); |
198 |
200 |
199 TBuf<64> tmp; |
|
200 tmp.Copy(KMCSqlConfig); |
|
201 tmp.Append(_L("\n")); |
|
202 |
|
203 TheTest.Printf(tmp); |
|
204 |
|
205 if (KErrAlreadyExists == err) |
201 if (KErrAlreadyExists == err) |
206 { |
202 { |
207 |
203 |
208 // the file already exists |
204 // the file already exists |
209 // make sure we delete the file |
205 // make sure we delete the file |
210 User::LeaveIfError(TheDbC.Delete(aDbName)); |
206 User::LeaveIfError(TheDbC.Delete(aDbName)); |
211 |
207 |
212 // try again |
208 // try again |
213 err = TheDbC.Create(aDbName, securityPolicy, &KMCSqlConfig); |
209 err = TheDbC.Create(aDbName, securityPolicy, &TheSqlConfigString); |
214 |
210 |
215 } |
211 } |
216 |
212 |
217 User::LeaveIfError(err); |
213 User::LeaveIfError(err); |
218 |
214 |
278 sqlFile.Close(); |
274 sqlFile.Close(); |
279 TEST2(err, KErrNone); |
275 TEST2(err, KErrNone); |
280 TEST2(sql.Length(), fileLen); |
276 TEST2(sql.Length(), fileLen); |
281 |
277 |
282 //Open main database |
278 //Open main database |
283 err = TheDbC.Open(TheDbFileName); |
279 err = TheDbC.Open(TheDbFileName, &TheSqlConfigString); |
284 TEST2(err, KErrNone); |
280 TEST2(err, KErrNone); |
285 |
281 |
286 TheTest.Printf(_L("Beginning INSERTS...\n")); |
282 TheTest.Printf(_L("Beginning INSERTS...\n")); |
287 |
283 |
288 const TInt KRecordCount = 6544; |
284 const TInt KRecordCount = 6544; |
370 /////////////////////////////////////////////////////////////////////////////////// |
366 /////////////////////////////////////////////////////////////////////////////////// |
371 /////////////////////////////////////////////////////////////////////////////////// |
367 /////////////////////////////////////////////////////////////////////////////////// |
372 |
368 |
373 void DoTests() |
369 void DoTests() |
374 { |
370 { |
375 TheTest.Start(_L("@SYMTestCaseID:PDS-SQL-UT-4151; SQL Music Player Db Performance Test")); |
371 TheTestTitle.Format(_L("@SYMTestCaseID:PDS-SQL-UT-4151; SQL Music Player Db Performance Test, encoding: \"%S\", page size: %d\r\n"), |
|
372 TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize); |
|
373 TheTest.Start(TheTestTitle); |
376 |
374 |
377 RunTest(); |
375 RunTest(); |
378 } |
376 } |
379 |
|
380 //Usage: "t_sqlperformance4 [<drive letter>:]" |
|
381 |
377 |
382 TInt E32Main() |
378 TInt E32Main() |
383 { |
379 { |
384 TheTest.Title(); |
380 TheTest.Title(); |
385 |
381 |
386 CTrapCleanup* tc = CTrapCleanup::New(); |
382 CTrapCleanup* tc = CTrapCleanup::New(); |
387 TheTest(tc != NULL); |
383 TheTest(tc != NULL); |
388 |
384 |
389 __UHEAP_MARK; |
385 __UHEAP_MARK; |
390 |
386 |
391 User::CommandLine(TheCmd); |
387 GetCmdLineParamsAndSqlConfigString(TheTest, _L("t_sqlperformance4"), TheCmdLineParams, TheSqlConfigString); |
392 TheCmd.TrimAll(); |
388 PrepareDbName(KCDriveDatabase, TheCmdLineParams.iDriveName, TheDbFileName); |
393 if(TheCmd.Length() > 0) |
389 |
394 { |
390 TheTest.Printf(_L("==Databases: %S\r\n"), &TheDbFileName); |
395 TheDriveName.Copy(TheCmd); |
|
396 } |
|
397 TheParse.Set(TheDriveName, &KCDriveDatabase, 0); |
|
398 const TDesC& dbFilePath = TheParse.FullName(); |
|
399 TheDbFileName.Copy(dbFilePath); |
|
400 TheTest.Printf(_L("==Database file name: %S\r\n"), &TheDbFileName); |
|
401 |
391 |
402 TestEnvInit(); |
392 TestEnvInit(); |
403 |
393 |
404 DoTests(); |
394 DoTests(); |
405 |
395 |