diff -r d6ef85bc5971 -r 7a522c0700d3 persistentstorage/sql/TEST/t_sqlapi.cpp --- a/persistentstorage/sql/TEST/t_sqlapi.cpp Fri May 14 17:36:33 2010 +0300 +++ b/persistentstorage/sql/TEST/t_sqlapi.cpp Fri May 14 13:32:10 2010 +0100 @@ -299,22 +299,24 @@ { maxFileName = KMaxFileName -150;//The test will panic in PlatSim when the file name is too long. This line should be removed when platsim team fixes the file system defect. } - HBufC* dbPath = HBufC::NewLC(maxFileName); + HBufC* dbPath = HBufC::New(maxFileName); + TEST(dbPath != NULL); + TPtr dbPathPtr = dbPath->Des(); _LIT(KExt, ".DB"); - dbPath->Des().Copy(_L("C:")); - dbPath->Des().Append(KSecureUid.Name()); - TInt len = maxFileName + 1 - (dbPath->Length() + KExt().Length() + privatePath.Length()); + dbPathPtr.Copy(_L("C:")); + dbPathPtr.Append(KSecureUid.Name()); + TInt len = maxFileName + 1 - (dbPathPtr.Length() + KExt().Length() + privatePath.Length()); while(--len) { - dbPath->Des().Append(TChar('A')); + dbPathPtr.Append(TChar('A')); } - dbPath->Des().Append(KExt); - TEST(dbPath->Length() == (maxFileName - privatePath.Length())); - rc = db.Create(dbPath->Des(), securityPolicy); + dbPathPtr.Append(KExt); + TEST(dbPathPtr.Length() == (maxFileName - privatePath.Length())); + rc = db.Create(dbPathPtr, securityPolicy); TEST2(rc, KErrNone); db.Close(); - rc2 = RSqlDatabase::Delete(dbPath->Des()); + rc2 = RSqlDatabase::Delete(dbPathPtr); TEST2(rc2, KErrNone); // Private database with config @@ -330,19 +332,20 @@ //Public shared database file on an existing drive (C:). //Very long database file name. - dbPath->Des().Copy(_L("C:\\TEST\\D")); - len = maxFileName + 1 - (dbPath->Length() + KExt().Length()); + dbPathPtr.Copy(_L("C:\\TEST\\D")); + len = maxFileName + 1 - (dbPathPtr.Length() + KExt().Length()); while(--len) { - dbPath->Des().Append(TChar('A')); + dbPathPtr.Append(TChar('A')); } - dbPath->Des().Append(KExt); - TEST(dbPath->Length() == maxFileName); - rc = db.Create(dbPath->Des()); + dbPathPtr.Append(KExt); + TEST(dbPathPtr.Length() == maxFileName); + rc = db.Create(dbPathPtr); db.Close(); - rc2 = RSqlDatabase::Delete(dbPath->Des()); + rc2 = RSqlDatabase::Delete(dbPathPtr); - CleanupStack::PopAndDestroy(dbPath); + delete dbPath; + TEST2(rc, KErrNone); TEST2(rc2, KErrNone); @@ -410,6 +413,19 @@ TEST(rc==KSqlErrNotDb || rc==KErrNone); db.Close(); + //An attempt to open database with name containing non-convertible characters. + TBuf<6> invName; + invName.SetLength(6); + invName[0] = TChar('c'); + invName[1] = TChar(':'); + invName[2] = TChar('\\'); + invName[3] = TChar(0xD800); + invName[4] = TChar(0xFC00); + invName[5] = TChar(0x0000); + rc = db.Open(invName); + db.Close(); + TEST(rc != KErrNone); + //Copy the corrupted database file on drive C: TEST2(fs.Connect(), KErrNone); rc = BaflUtils::CopyFile(fs, KDbPath10, KTestDbName3); @@ -792,6 +808,7 @@ _LIT8(KStmt19, "INSERT INTO BBB(Fld1, Fld2, Fld3, Fld4, Fld5, Fld6)\ VALUES(:V1, :V2, :V3, :V4, :V5, :V6)"); _LIT8(KStmt20, "SELECT * FROM BBB"); +_LIT8(KStmt21, "SELECT fld1, fld2 FROM AAA;SELECT fld1, fld2 FROM AAA"); /** @SYMTestCaseID SYSLIB-SQL-CT-1606 @@ -824,6 +841,10 @@ ExecSqlStmt(db, stmt, KErrNone); stmt.Close(); + //String containg more than one SQL statement. + stmt = PrepareSqlStmt(db, KStmt21, KErrArgument); + stmt.Close(); + //SQL statement without parameters. Insert a record into the table. stmt = PrepareSqlStmt(db, KStmt13, KErrNone); ExecSqlStmt(db, stmt, KErrNone); @@ -1088,6 +1109,17 @@ rc = stmt.Next(); TEST2(rc, KSqlAtRow); + //An attempt to read integer column using binary stream + RSqlColumnReadStream strm2; + rc = strm2.ColumnBinary(stmt, 0); + strm2.Close(); + TEST2(rc, KErrArgument); + + //An attempt to read integer column using text stream + rc = strm2.ColumnText(stmt, 0); + strm2.Close(); + TEST2(rc, KErrArgument); + //Read the long text column using a stream RSqlColumnReadStream columnStream; rc = columnStream.ColumnText(stmt, 1); @@ -2358,6 +2390,48 @@ (void)RSqlDatabase::Delete(KTestDbName1); } +/** +@SYMTestCaseID PDS-SQL-CT-4205 +@SYMTestCaseDesc "PRAGMA count_changes" test. + When "count_changes" pragma is ON, sqlite3_step() is called two times by the + SQL server, before getting the SQLITE_DONE return code. + Everything else is the same (statement processing, etc.). +@SYMTestPriority High +@SYMTestActions "PRAGMA count_changes" test. +@SYMTestExpectedResults Test must not fail +*/ +void CountChangesTest() + { + (void)RSqlDatabase::Delete(KTestDbName1); + RSqlDatabase db; + TInt err = db.Create(KTestDbName1); + TEST2(err, KErrNone); + err = db.Exec(_L("CREATE TABLE A(I INTEGER)")); + TEST(err >= 0); + + err = db.Exec(_L("PRAGMA count_changes=ON")); + TEST(err >= 0); + + err = db.Exec(_L("INSERT INTO A VALUES(1)")); + TEST2(err, 1); + + err = db.Exec(_L8("INSERT INTO A VALUES(2)")); + TEST2(err, 1); + + RSqlStatement stmt; + err = stmt.Prepare(db, _L("DELETE FROM A WHERE I>=1 AND I<=2")); + TEST2(err, KErrNone); + err = stmt.Exec(); + TEST2(err, 2); + stmt.Close(); + + err = db.Exec(_L("PRAGMA count_changes=OFF")); + TEST(err >= 0); + + db.Close(); + (void)RSqlDatabase::Delete(KTestDbName1); + } + void DoTestsL() { TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1601 Create/Open/Close database tests ")); @@ -2427,6 +2501,9 @@ TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4041 RSqlDatabase::Size(RSqlDatabase::TSize&) - different compaction modes tests")); DiffCompactModeSize2Test(); + + TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4205 PRAGMA \"count_changes\" test")); + CountChangesTest(); } TInt E32Main()