sl@0: // Copyright (c) 1998-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: sl@0: #if defined(__VC32__) && !defined(_DEBUG) sl@0: #pragma warning(disable : 4710) // function not expanded. MSVC 4.0 is stupid sl@0: #endif sl@0: sl@0: LOCAL_D RTest test(_L("t_dbapi : Test DBMS API")); sl@0: LOCAL_D CTrapCleanup* TheTrapCleanup; sl@0: LOCAL_D RDbs TheDbs; sl@0: LOCAL_D RDbNamedDatabase TheDatabase; sl@0: LOCAL_D RDbTable TheTable; sl@0: LOCAL_D RDbView TheView; sl@0: LOCAL_D RFs TheFs; sl@0: LOCAL_D TBuf8<0x200> TheBuf8; sl@0: LOCAL_D TBuf16<0x100> TheBuf16; sl@0: sl@0: const TInt KTestCleanupStack=0x40; sl@0: const TPtrC KTestDatabase=_L("C:\\DBMS-TST\\T_DBMS.DB"); sl@0: const TPtrC8 KTestText8(_S8("Text used for test columns when testing")); sl@0: const TPtrC8 KTestShortText8(_S8("a")); sl@0: const TPtrC8 KTestLongText8(_S8("Text which is used to set Long ASCII Text columns and ensure they are not inlined, and therefore needs to be very long indeed............." \ sl@0: "Text which is used to set Long ASCII Text columns and ensure they are not inlined, and therefore needs to be very long indeed.............")); sl@0: const TPtrC16 KTestText16(_S16("Text used for test columns when testing")); sl@0: const TPtrC16 KTestShortText16(_S16("a")); sl@0: const TPtrC16 KTestLongText16(_S16("Text which is used to set Long UNICODE Text columns and ensure they are not inlined, and therefore needs to be very long indeed.............")); sl@0: const TPtrC KTableName(_S("TestTable")); sl@0: const TPtrC KTableName2(_S("TestTable2")); sl@0: const TPtrC KTestViewTable(_L("TestViewTable")); sl@0: const TPtrC KTestTypesTable(_L("TestTypesTable")); sl@0: const TPtrC KTestFindTable(_L("TestFindTable")); sl@0: const TPtrC KTestMultiTable(_L("TestMultiTable")); sl@0: const TPtrC KIndexName(_S("Index1")); sl@0: const TPtrC KIndexName2(_S("Index2")); sl@0: const TPtrC KIndexName3(_S("Index3")); sl@0: const TInt KBlobItems=1000; sl@0: sl@0: const TPtrC KNull=TPtrC(); sl@0: const TPtrC KPass1(_S("wibble")); sl@0: const TPtrC KPass2(_S("wobble")); sl@0: sl@0: const TReal32 KMinTReal32=(TReal32)1.2345e-37; sl@0: const TReal32 KMaxTReal32=(TReal32)9.8765e37; sl@0: const TReal64 KMinTReal64=1.23456789e-300; sl@0: const TReal64 KMaxTReal64=9.87654321e300; sl@0: sl@0: const TTime KMinTTime=Time::MinTTime(); sl@0: const TTime KMaxTTime=Time::MaxTTime(); sl@0: sl@0: struct SColDef sl@0: { sl@0: const TText* iName; sl@0: TDbColType iType; sl@0: TInt iAttributes; sl@0: }; sl@0: LOCAL_D SColDef const SingleColumn[]= sl@0: { sl@0: {_S("Column1"),EDbColInt32,0}, sl@0: {0} sl@0: }; sl@0: LOCAL_D SColDef const DoubleColumn[]= sl@0: { sl@0: {_S("Column1"),EDbColInt32,0}, sl@0: {_S("c2"),EDbColInt64,0}, sl@0: {0} sl@0: }; sl@0: LOCAL_D SColDef const ViewTestColumns[]= sl@0: { sl@0: {_S("Int"),EDbColInt32,0}, sl@0: {_S("Long1"),EDbColLongText8,0}, sl@0: {_S("Long2"),EDbColLongText8,0}, sl@0: {_S("Long3"),EDbColLongText8,0}, sl@0: {_S("Long4"),EDbColLongText8,0}, sl@0: {_S("Long5"),EDbColLongText8,0}, sl@0: {0} sl@0: }; sl@0: LOCAL_D SColDef const AllColumns[]= sl@0: { sl@0: {_S("counter"),EDbColInt32,TDbCol::ENotNull|TDbCol::EAutoIncrement}, sl@0: {_S("bit"),EDbColBit,TDbCol::ENotNull}, sl@0: {_S("int8"),EDbColInt8,TDbCol::ENotNull}, sl@0: {_S("uint8"),EDbColUint8,TDbCol::ENotNull}, sl@0: {_S("int16"),EDbColInt16,TDbCol::ENotNull}, sl@0: {_S("uint16"),EDbColUint16,TDbCol::ENotNull}, sl@0: {_S("int32"),EDbColInt32,TDbCol::ENotNull}, sl@0: {_S("uint32"),EDbColUint32,TDbCol::ENotNull}, sl@0: {_S("int64"),EDbColInt64,TDbCol::ENotNull}, sl@0: {_S("real32"),EDbColReal32,TDbCol::ENotNull}, sl@0: {_S("real64"),EDbColReal64,TDbCol::ENotNull}, sl@0: {_S("date_time"),EDbColDateTime,TDbCol::ENotNull}, sl@0: {_S("text8"),EDbColText8,TDbCol::ENotNull}, sl@0: {_S("text16"),EDbColText16,TDbCol::ENotNull}, sl@0: {_S("binary"),EDbColBinary,TDbCol::ENotNull}, sl@0: {_S("longtext8"),EDbColLongText8,TDbCol::ENotNull}, sl@0: {_S("longtext16"),EDbColLongText16,TDbCol::ENotNull}, sl@0: {_S("longbinary"),EDbColLongBinary,TDbCol::ENotNull}, sl@0: {_S("bit_null"),EDbColBit,0}, sl@0: {_S("int8_null"),EDbColInt8,0}, sl@0: {_S("uint8_null"),EDbColUint8,0}, sl@0: {_S("int16_null"),EDbColInt16,0}, sl@0: {_S("uint16_null"),EDbColUint16,0}, sl@0: {_S("int32_null"),EDbColInt32,0}, sl@0: {_S("uint32_null"),EDbColUint32,0}, sl@0: {_S("int64_null"),EDbColInt64,0}, sl@0: {_S("real32_null"),EDbColReal32,0}, sl@0: {_S("real64_null"),EDbColReal64,0}, sl@0: {_S("date_time_null"),EDbColDateTime,0}, sl@0: {_S("text8_null"),EDbColText8,0}, sl@0: {_S("text16_null"),EDbColText16,0}, sl@0: {_S("binary_null"),EDbColBinary,0}, sl@0: {_S("longtext8_null"),EDbColLongText8,0}, sl@0: {_S("longtext16_null"),EDbColLongText16,0}, sl@0: {_S("longbinary_null"),EDbColLongBinary,0}, sl@0: {_S("force_null"),EDbColInt32,0}, sl@0: {0} sl@0: }; sl@0: const TInt KColumns=sizeof(AllColumns)/sizeof(AllColumns[0])-1; sl@0: enum TColumns sl@0: { sl@0: ECounter, sl@0: EBit,EInt8,EUint8,EInt16,EUint16,EInt32,EUint32,EInt64, sl@0: EReal32,EReal64,ETime,EText8,EText16,ETBinary, sl@0: ELongText8,ELongText16,ELongBinary, sl@0: EBitNull,EInt8Null,EUint8Null,EInt16Null,EUint16Null,EInt32Null,EUint32Null,EInt64Null, sl@0: EReal32Null,EReal64Null,ETimeNull,EText8Null,EText16Null,ETBinaryNull, sl@0: ELongText8Null,ELongText16Null,ELongBinaryNull,EForceNull sl@0: }; sl@0: LOCAL_D TDbColNo TheMap[KColumns]; sl@0: sl@0: CDbColSet* ColumnSetL(const SColDef* aDef) sl@0: { sl@0: CDbColSet *set=CDbColSet::NewLC(); sl@0: for (;aDef->iName;++aDef) sl@0: { sl@0: TDbCol col(TPtrC(aDef->iName),aDef->iType); sl@0: col.iAttributes=aDef->iAttributes; sl@0: set->AddL(col); sl@0: } sl@0: CleanupStack::Pop(); sl@0: return set; sl@0: } sl@0: sl@0: enum TColSet {EAllTypes,ESingleColumn,EDoubleColumn,EViewTestTable}; sl@0: LOCAL_D const SColDef* const ColSetDef[]= sl@0: { sl@0: AllColumns, sl@0: SingleColumn, sl@0: DoubleColumn, sl@0: ViewTestColumns sl@0: }; sl@0: LOCAL_C CDbColSet* CreateColSetL(TColSet aType) sl@0: { sl@0: return ColumnSetL(ColSetDef[aType]); sl@0: } sl@0: sl@0: inline TPtrC ColName(const SColDef* aSet,TInt aColumn) sl@0: {return TPtrC(aSet[aColumn].iName);} sl@0: sl@0: enum TKeySet {EKeyAsc,EKeyDesc,EKeyMulti,EKeySingle}; sl@0: LOCAL_C CDbKey* CreateKeyL(TKeySet aType) sl@0: { sl@0: CDbKey *k=CDbKey::NewLC(); sl@0: switch(aType) sl@0: { sl@0: case EKeyAsc: sl@0: k->AddL(ColName(AllColumns,EInt32)); sl@0: break; sl@0: case EKeyDesc: sl@0: k->AddL(TDbKeyCol(ColName(AllColumns,EInt32),TDbKeyCol::EDesc)); sl@0: k->MakeUnique(); sl@0: break; sl@0: case EKeyMulti: sl@0: k->AddL(ColName(AllColumns,EInt32)).AddL(ColName(AllColumns,EText8)); sl@0: k->SetComparison(EDbCompareFolded); sl@0: break; sl@0: case EKeySingle: sl@0: k->AddL(ColName(SingleColumn,0)); sl@0: break; sl@0: } sl@0: CleanupStack::Pop(); sl@0: return k; sl@0: } sl@0: sl@0: LOCAL_C void CloseDatabase() sl@0: { sl@0: TheDatabase.Close(); sl@0: } sl@0: sl@0: sl@0: // sl@0: // Open a shared database (SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version) sl@0: // sl@0: LOCAL_C TInt OpenSharedDatabase() sl@0: { sl@0: return TheDatabase.Open(TheDbs,KTestDatabase); sl@0: } sl@0: sl@0: // sl@0: // Create a local database (SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version) sl@0: // sl@0: LOCAL_C void CreateClientDatabase() sl@0: { sl@0: TInt r=TheDatabase.Replace(TheFs,KTestDatabase); sl@0: test (r==KErrNone); sl@0: } sl@0: sl@0: // sl@0: // Create a shared database (SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version) sl@0: // sl@0: LOCAL_C void CreateSharedDatabase() sl@0: { sl@0: CreateClientDatabase(); sl@0: CloseDatabase(); sl@0: TInt r=OpenSharedDatabase(); sl@0: test (r==KErrNone); sl@0: } sl@0: sl@0: // sl@0: // Open a shared database (SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version) sl@0: // sl@0: LOCAL_C void OpenDatabase() sl@0: { sl@0: TInt r=OpenSharedDatabase(); sl@0: test (r==KErrNone); sl@0: } sl@0: sl@0: // sl@0: // Create a shared database (SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version) sl@0: // sl@0: LOCAL_C void CreateDatabase() sl@0: { sl@0: CreateSharedDatabase(); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void DestroyDatabase() sl@0: { sl@0: TInt r=TheDatabase.Destroy(); sl@0: test (r==KErrNone); sl@0: } sl@0: sl@0: // sl@0: // Check the database has this many tables sl@0: // sl@0: LOCAL_C void CountTablesL(TInt aCount) sl@0: { sl@0: CDbNames* names=TheDatabase.TableNamesL(); sl@0: test (names->Count()==aCount); sl@0: delete names; sl@0: } sl@0: sl@0: // sl@0: // Compare two column sets sl@0: // sl@0: LOCAL_C void CompareL(const TDesC& aTable,const CDbColSet& aSet) sl@0: { sl@0: CDbColSet* set=TheDatabase.ColSetL(aTable); sl@0: test(set->Count()==aSet.Count()); sl@0: for (TDbColSetIter iter(*set);iter;++iter) sl@0: { sl@0: const TDbCol* pRight=aSet.Col(iter->iName); sl@0: test(pRight!=NULL); sl@0: test(iter->iType==pRight->iType); sl@0: test(iter->iMaxLength==KDbUndefinedLength || pRight->iMaxLength==KDbUndefinedLength || iter->iMaxLength==pRight->iMaxLength); sl@0: test((iter->iAttributes&pRight->iAttributes)==iter->iAttributes); sl@0: } sl@0: delete set; sl@0: } sl@0: sl@0: // sl@0: // Check the database has this many tables sl@0: // sl@0: LOCAL_C void CountIndexesL(const TDesC& aTable,TInt aCount) sl@0: { sl@0: CDbNames* names=TheDatabase.IndexNamesL(aTable); sl@0: test (names->Count()==aCount); sl@0: delete names; sl@0: } sl@0: sl@0: // sl@0: // Compare index definition sl@0: // sl@0: LOCAL_C void CompareL(const TDesC& aIndex,const TDesC& aTable,const CDbKey& aKey) sl@0: { sl@0: CDbKey* key=TheDatabase.KeyL(aIndex,aTable); sl@0: test(key->Count()==aKey.Count()); sl@0: test(key->Comparison()==aKey.Comparison()); sl@0: test(key->IsUnique()==aKey.IsUnique()); sl@0: for (TInt ii=aKey.Count();--ii>=0;) sl@0: { sl@0: const TDbKeyCol& left=(*key)[ii]; sl@0: const TDbKeyCol& right=aKey[ii]; sl@0: test (left.iName==right.iName); sl@0: test (left.iOrder==right.iOrder); sl@0: test (left.iLength==right.iLength || right.iLength==KDbUndefinedLength); sl@0: } sl@0: delete key; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-0594 sl@0: @SYMTestCaseDesc Tests the database definition and enquiry functions sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for creation and opening of a database,creation of a table sl@0: Tests for comparing column and table column sets sl@0: Tests for altering a table and creation of an index. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDDL() sl@0: { sl@0: test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0594 Create Database ")); sl@0: CreateDatabase(); sl@0: CountTablesL(0); sl@0: CloseDatabase(); sl@0: test.Next(_L("Open Database")); sl@0: OpenDatabase(); sl@0: CountTablesL(0); sl@0: test.Next(_L("CreateTable")); sl@0: CDbColSet* cs=CreateColSetL(EAllTypes); sl@0: test(TheDatabase.CreateTable(KTableName,*cs)==KErrNone); sl@0: CountTablesL(1); sl@0: test.Next(_L("Compare column sets")); sl@0: CompareL(KTableName,*cs); sl@0: CloseDatabase(); sl@0: test.Next(_L("Re-open database")); sl@0: OpenDatabase(); sl@0: CountTablesL(1); sl@0: test.Next(_L("Compare table column sets")); sl@0: CompareL(KTableName,*cs); sl@0: delete cs; sl@0: test.Next(_L("Add another table")); sl@0: cs=CreateColSetL(ESingleColumn); sl@0: test(TheDatabase.CreateTable(KTableName2,*cs)==KErrNone); sl@0: CompareL(KTableName2,*cs); sl@0: delete cs; sl@0: CountTablesL(2); sl@0: // sl@0: test.Next(_L("Alter table")); sl@0: cs=CreateColSetL(EDoubleColumn); sl@0: test(TheDatabase.AlterTable(KTableName2,*cs)==KErrNone); sl@0: CompareL(KTableName2,*cs); sl@0: delete cs; sl@0: CountTablesL(2); sl@0: // sl@0: test.Next(_L("Test index creation")); sl@0: CountIndexesL(KTableName,0); sl@0: CountIndexesL(KTableName2,0); sl@0: CDbKey* key=CreateKeyL(EKeyAsc); sl@0: test (TheDatabase.CreateIndex(KIndexName,KTableName,*key)==KErrNone); sl@0: CompareL(KIndexName,KTableName,*key); sl@0: delete key; sl@0: key=CreateKeyL(EKeyDesc); sl@0: test (TheDatabase.CreateIndex(KIndexName2,KTableName,*key)==KErrNone); sl@0: CompareL(KIndexName2,KTableName,*key); sl@0: delete key; sl@0: key=CreateKeyL(EKeySingle); sl@0: test (TheDatabase.CreateIndex(KIndexName,KTableName2,*key)==KErrNone); sl@0: CompareL(KIndexName,KTableName2,*key); sl@0: delete key; sl@0: key=CreateKeyL(EKeyMulti); sl@0: test (TheDatabase.CreateIndex(KIndexName3,KTableName,*key)==KErrNone); sl@0: CompareL(KIndexName3,KTableName,*key); sl@0: CountIndexesL(KTableName,3); sl@0: CountIndexesL(KTableName2,1); sl@0: CloseDatabase(); sl@0: OpenDatabase(); sl@0: CountIndexesL(KTableName,3); sl@0: CountIndexesL(KTableName2,1); sl@0: CompareL(KIndexName3,KTableName,*key); sl@0: delete key; sl@0: test.Next(_L("Drop indexes")); sl@0: test (TheDatabase.DropIndex(KIndexName,KTableName)==KErrNone); sl@0: CountIndexesL(KTableName,2); sl@0: test (TheDatabase.DropIndex(KIndexName2,KTableName)==KErrNone); sl@0: CountIndexesL(KTableName,1); sl@0: test (TheDatabase.DropIndex(KIndexName,KTableName2)==KErrNone); sl@0: CountIndexesL(KTableName2,0); sl@0: test.Next(_L("Drop table")); sl@0: test(TheDatabase.DropTable(KTableName)==KErrNone); sl@0: CountTablesL(1); sl@0: test(TheDatabase.DropTable(KTableName2)==KErrNone); sl@0: CountTablesL(0); sl@0: CloseDatabase(); sl@0: OpenDatabase(); sl@0: CountTablesL(0); sl@0: DestroyDatabase(); sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void AddRowL() sl@0: { sl@0: test(TheView.Prepare(TheDatabase,_L("select * from testviewtable"))==KErrNone); sl@0: test(TheView.EvaluateAll()==KErrNone); sl@0: TheView.InsertL(); sl@0: TheView.SetColL(1,(TInt32)12345); sl@0: TheView.PutL(); sl@0: TheView.InsertL(); sl@0: TheView.Cancel(); sl@0: TheView.FirstL(); sl@0: TheView.NextL(); sl@0: test(TheView.AtEnd()); // should be only 1 row as second insert was cancelled sl@0: TheView.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-1318 sl@0: @SYMTestCaseDesc Tests for RDbView class sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for navigation of the cursor in the generated row sets. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestEmptyNavigationL(const TDesC& aQuery) sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1318 Test navigation states ")); sl@0: test(TheView.Prepare(TheDatabase,aQuery,TheView.EReadOnly)==KErrNone); sl@0: test(TheView.EvaluateAll()==KErrNone); sl@0: TheView.FirstL(); sl@0: test(!TheView.AtBeginning()); sl@0: test(!TheView.AtRow()); sl@0: test(TheView.AtEnd()); sl@0: TheView.PreviousL(); sl@0: test(TheView.AtBeginning()); sl@0: test(!TheView.AtRow()); sl@0: test(!TheView.AtEnd()); sl@0: TheView.NextL(); sl@0: test(!TheView.AtBeginning()); sl@0: test(!TheView.AtRow()); sl@0: test(TheView.AtEnd()); sl@0: TheView.LastL(); sl@0: test(TheView.AtBeginning()); sl@0: test(!TheView.AtRow()); sl@0: test(!TheView.AtEnd()); sl@0: TheView.NextL(); sl@0: test(TheView.AtEnd()); sl@0: TheView.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-1319 sl@0: @SYMTestCaseDesc Tests for RDbView class sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for navigation of the cursor in the generated row sets. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestNavigationL(const TDesC& aQuery) sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1319 Test navigation states ")); sl@0: test(TheView.Prepare(TheDatabase,aQuery,TheView.EReadOnly)==KErrNone); sl@0: test(TheView.EvaluateAll()==KErrNone); sl@0: TheView.FirstL(); sl@0: test(!TheView.AtBeginning()); sl@0: test(TheView.AtRow()); sl@0: test(!TheView.AtEnd()); sl@0: TheView.GetL(); sl@0: test(TheView.ColInt32(1)==12345); sl@0: TheView.PreviousL(); sl@0: test(TheView.AtBeginning()); sl@0: test(!TheView.AtRow()); sl@0: test(!TheView.AtEnd()); sl@0: TheView.NextL(); sl@0: test(!TheView.AtBeginning()); sl@0: test(TheView.AtRow()); sl@0: test(!TheView.AtEnd()); sl@0: TheView.NextL(); sl@0: test(!TheView.AtBeginning()); sl@0: test(!TheView.AtRow()); sl@0: test(TheView.AtEnd()); sl@0: TheView.PreviousL(); sl@0: test(!TheView.AtBeginning()); sl@0: test(TheView.AtRow()); sl@0: test(!TheView.AtEnd()); sl@0: TheView.LastL(); sl@0: test(!TheView.AtBeginning()); sl@0: test(TheView.AtRow()); sl@0: test(!TheView.AtEnd()); sl@0: TheView.NextL(); sl@0: test(TheView.AtEnd()); sl@0: TheView.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-1320 sl@0: @SYMTestCaseDesc RDbView updation test sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for updation of row sets sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: static void TestUpdateL() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1320 Update and delete the row ")); sl@0: test(TheView.Prepare(TheDatabase,_L("select * from TestViewTable"))==KErrNone); sl@0: test(TheView.EvaluateAll()==KErrNone); sl@0: TheView.FirstL(); sl@0: TheView.UpdateL(); sl@0: TheView.SetColL(1,(TInt32)54321); sl@0: TheView.PutL(); sl@0: TheView.FirstL(); sl@0: TheView.GetL(); sl@0: test(TheView.ColInt32(1)==54321); sl@0: TheView.UpdateL(); sl@0: TheView.SetColL(1,(TInt32)12345); sl@0: TheView.Cancel(); sl@0: TheView.FirstL(); sl@0: TheView.GetL(); sl@0: test(TheView.ColInt32(1)==54321); sl@0: TheView.DeleteL(); sl@0: TheView.PreviousL(); sl@0: test(TheView.AtBeginning()); sl@0: TheView.NextL(); sl@0: test(TheView.AtEnd()); sl@0: TheView.Close(); sl@0: } sl@0: sl@0: #include sl@0: sl@0: void writeBLOBL(TDbColNo aCol,const TDesC8& aDes) sl@0: { sl@0: CBufSeg* buf=CBufSeg::NewL(128); sl@0: CleanupStack::PushL(buf); sl@0: buf->InsertL(0,aDes); sl@0: RBufReadStream read(*buf); sl@0: RDbColWriteStream blob; sl@0: blob.OpenLC(TheView,aCol); sl@0: // blob.WriteL(aDes); sl@0: blob.WriteL(read,aDes.Length()); sl@0: blob.CommitL(); sl@0: CleanupStack::PopAndDestroy(); sl@0: CleanupStack::PopAndDestroy(); // buf sl@0: test (TheView.ColLength(aCol)==aDes.Length()); sl@0: test (TheView.ColSize(aCol)==aDes.Size()); sl@0: } sl@0: sl@0: void checkBLOBL(TDbColNo aCol,const TDesC8& aDes) sl@0: { sl@0: RDbColReadStream blob; sl@0: blob.OpenLC(TheView,aCol); sl@0: blob.ReadL(TheBuf8,TheView.ColLength(aCol)); sl@0: CleanupStack::PopAndDestroy(); sl@0: test(TheBuf8==aDes); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-1321 sl@0: @SYMTestCaseDesc BLOB tests sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Test long column tracking through insert/put/update/cancel sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void TestBLOBL() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1321 Long column tracking ")); sl@0: test(TheView.Prepare(TheDatabase,_L("select * from TestViewTable"))==KErrNone); sl@0: test(TheView.EvaluateAll()==KErrNone); sl@0: TheView.InsertL(); sl@0: writeBLOBL(2,KTestShortText8); sl@0: writeBLOBL(3,KTestShortText8); sl@0: TheView.PutL(); sl@0: TheView.InsertL(); sl@0: writeBLOBL(4,KTestShortText8); sl@0: writeBLOBL(5,KTestShortText8); sl@0: TheView.Cancel(); sl@0: // change in behaviour--writing BLOBs forces a true rollback here. So reset sl@0: TheView.Reset(); sl@0: test(TheView.EvaluateAll()==KErrNone); sl@0: // check the one row we should have sl@0: TheView.FirstL(); sl@0: TheView.GetL(); sl@0: checkBLOBL(2,KTestShortText8); sl@0: checkBLOBL(3,KTestShortText8); sl@0: test(TheView.IsColNull(4)); sl@0: test(TheView.IsColNull(5)); sl@0: test(TheView.IsColNull(6)); sl@0: TheView.NextL(); sl@0: test(TheView.AtEnd()); sl@0: // update/cancel the row sl@0: TheView.FirstL(); sl@0: TheView.UpdateL(); sl@0: TheView.SetColNullL(3); sl@0: writeBLOBL(4,KTestLongText8); sl@0: writeBLOBL(5,KTestLongText8); sl@0: // check pre-cancel sl@0: checkBLOBL(2,KTestShortText8); sl@0: test(TheView.IsColNull(3)); sl@0: checkBLOBL(4,KTestLongText8); sl@0: checkBLOBL(5,KTestLongText8); sl@0: test(TheView.IsColNull(6)); sl@0: // cancel and check sl@0: TheView.Cancel(); sl@0: // change in behaviour--writing BLOBs forces a true rollback here. So reset sl@0: TheView.Reset(); sl@0: test(TheView.EvaluateAll()==KErrNone); sl@0: TheView.FirstL(); sl@0: TheView.GetL(); sl@0: checkBLOBL(2,KTestShortText8); sl@0: checkBLOBL(3,KTestShortText8); sl@0: test(TheView.IsColNull(4)); sl@0: test(TheView.IsColNull(5)); sl@0: test(TheView.IsColNull(6)); sl@0: TheView.NextL(); sl@0: test(TheView.AtEnd()); sl@0: // update/put the row sl@0: TheView.FirstL(); sl@0: TheView.UpdateL(); sl@0: TheView.SetColNullL(3); sl@0: writeBLOBL(4,KTestLongText8); sl@0: writeBLOBL(5,KTestLongText8); sl@0: // check pre-put sl@0: checkBLOBL(2,KTestShortText8); sl@0: test(TheView.IsColNull(3)); sl@0: checkBLOBL(4,KTestLongText8); sl@0: checkBLOBL(5,KTestLongText8); sl@0: test(TheView.IsColNull(6)); sl@0: // put and check sl@0: TheView.PutL(); sl@0: TheView.FirstL(); sl@0: TheView.GetL(); sl@0: checkBLOBL(2,KTestShortText8); sl@0: test(TheView.IsColNull(3)); sl@0: checkBLOBL(4,KTestLongText8); sl@0: checkBLOBL(5,KTestLongText8); sl@0: test(TheView.IsColNull(6)); sl@0: TheView.NextL(); sl@0: test(TheView.AtEnd()); sl@0: // update/put the row again sl@0: TheView.FirstL(); sl@0: TheView.UpdateL(); sl@0: TheView.SetColNullL(2); sl@0: writeBLOBL(3,KTestShortText8); sl@0: writeBLOBL(4,KTestShortText8); sl@0: writeBLOBL(5,KTestShortText8); sl@0: // check sl@0: test(TheView.IsColNull(2)); sl@0: checkBLOBL(3,KTestShortText8); sl@0: checkBLOBL(4,KTestShortText8); sl@0: checkBLOBL(5,KTestShortText8); sl@0: test(TheView.IsColNull(6)); sl@0: // modify again sl@0: writeBLOBL(2,KTestLongText8); sl@0: TheView.SetColNullL(3); sl@0: TheView.SetColNullL(4); sl@0: writeBLOBL(5,KTestLongText8); sl@0: // check pre-put sl@0: checkBLOBL(2,KTestLongText8); sl@0: test(TheView.IsColNull(3)); sl@0: test(TheView.IsColNull(4)); sl@0: checkBLOBL(5,KTestLongText8); sl@0: test(TheView.IsColNull(6)); sl@0: // put and check sl@0: TheView.PutL(); sl@0: TheView.FirstL(); sl@0: TheView.GetL(); sl@0: checkBLOBL(2,KTestLongText8); sl@0: test(TheView.IsColNull(3)); sl@0: test(TheView.IsColNull(4)); sl@0: checkBLOBL(5,KTestLongText8); sl@0: test(TheView.IsColNull(6)); sl@0: TheView.NextL(); sl@0: test(TheView.AtEnd()); sl@0: // insert copy sl@0: TheView.LastL(); sl@0: TheView.InsertCopyL(); sl@0: TheView.SetColNullL(2); sl@0: writeBLOBL(3,KTestLongText8); sl@0: // check pre-put sl@0: test(TheView.IsColNull(2)); sl@0: checkBLOBL(3,KTestLongText8); sl@0: test(TheView.IsColNull(4)); sl@0: checkBLOBL(5,KTestLongText8); sl@0: test(TheView.IsColNull(6)); sl@0: // put and check sl@0: TheView.PutL(); sl@0: TheView.LastL(); sl@0: TheView.GetL(); sl@0: test(TheView.IsColNull(2)); sl@0: checkBLOBL(3,KTestLongText8); sl@0: test(TheView.IsColNull(4)); sl@0: checkBLOBL(5,KTestLongText8); sl@0: test(TheView.IsColNull(6)); sl@0: // delete previous one and check sl@0: TheView.PreviousL(); sl@0: TheView.DeleteL(); sl@0: TheView.NextL(); sl@0: TheView.GetL(); sl@0: test(TheView.IsColNull(2)); sl@0: checkBLOBL(3,KTestLongText8); sl@0: test(TheView.IsColNull(4)); sl@0: checkBLOBL(5,KTestLongText8); sl@0: test(TheView.IsColNull(6)); sl@0: TheView.NextL(); sl@0: test(TheView.AtEnd()); sl@0: // delete sl@0: TheView.FirstL(); sl@0: TheView.DeleteL(); sl@0: // finish sl@0: TheView.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-0596 sl@0: @SYMTestCaseDesc Tests for navigation states sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for view state cycle, navigation, Insert/Update/Delete sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void TestViewL() sl@0: { sl@0: test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0596 Create the Test table ")); sl@0: CreateDatabase(); sl@0: CDbColSet* cs=CreateColSetL(EViewTestTable); sl@0: test(TheDatabase.CreateTable(KTestViewTable,*cs)==KErrNone); sl@0: delete cs; sl@0: TestEmptyNavigationL(_L("select * from TestViewTable")); sl@0: test.Next(_L("Insert and Put/Cancel")); sl@0: AddRowL(); sl@0: TestNavigationL(_L("select * from TestViewTable")); sl@0: TestNavigationL(_L("select * from TestViewTable where Int is not null")); sl@0: TestEmptyNavigationL(_L("select * from TestViewTable where Int is null")); sl@0: TestUpdateL(); sl@0: TestBLOBL(); sl@0: test.Next(_L("Close")); sl@0: CloseDatabase(); sl@0: test.End(); sl@0: } sl@0: sl@0: // sl@0: // Check the integral set/get functions for different width types sl@0: // sl@0: LOCAL_C void CheckIntAccessorsL() sl@0: { sl@0: TheView.InsertL(); sl@0: // bit column sl@0: TDbColNo ord=TheMap[EBit]; sl@0: TheView.SetColL(ord,TUint32(1)); sl@0: test (TheView.ColUint(ord)==1); sl@0: TheView.SetColL(ord,TInt32(0)); sl@0: test (TheView.ColUint(ord)==0); sl@0: TheView.SetColL(ord,TInt64(1)); sl@0: test (TheView.ColUint(ord)==1); sl@0: test (TheView.ColUint8(ord)==1); sl@0: test (TheView.ColUint16(ord)==1); sl@0: test (TheView.ColUint32(ord)==1); sl@0: test (TheView.ColInt8(ord)==1); sl@0: test (TheView.ColInt16(ord)==1); sl@0: test (TheView.ColInt32(ord)==1); sl@0: test (TheView.ColInt64(ord)==1); sl@0: // uint8 column sl@0: ord=TheMap[EUint8]; sl@0: TheView.SetColL(ord,TUint32(255)); sl@0: test (TheView.ColUint(ord)==255); sl@0: TheView.SetColL(ord,TInt32(0)); sl@0: test (TheView.ColUint(ord)==0); sl@0: TheView.SetColL(ord,TInt64(1)); sl@0: test (TheView.ColUint(ord)==1); sl@0: test (TheView.ColUint8(ord)==1); sl@0: test (TheView.ColUint16(ord)==1); sl@0: test (TheView.ColUint32(ord)==1); sl@0: test (TheView.ColInt16(ord)==1); sl@0: test (TheView.ColInt32(ord)==1); sl@0: test (TheView.ColInt64(ord)==1); sl@0: // uint16 column sl@0: ord=TheMap[EUint16]; sl@0: TheView.SetColL(ord,TUint32(65535)); sl@0: test (TheView.ColUint(ord)==65535); sl@0: TheView.SetColL(ord,TInt32(0)); sl@0: test (TheView.ColUint(ord)==0); sl@0: TheView.SetColL(ord,TInt64(1)); sl@0: test (TheView.ColUint(ord)==1); sl@0: test (TheView.ColUint16(ord)==1); sl@0: test (TheView.ColUint32(ord)==1); sl@0: test (TheView.ColInt32(ord)==1); sl@0: test (TheView.ColInt64(ord)==1); sl@0: // uint32 column sl@0: ord=TheMap[EUint32]; sl@0: TheView.SetColL(ord,TUint32(0)); sl@0: test (TheView.ColUint(ord)==0); sl@0: TheView.SetColL(ord,TInt32(KMaxTInt)); sl@0: test (TInt(TheView.ColUint(ord))==KMaxTInt); sl@0: TheView.SetColL(ord,TInt64(KMaxTUint)); sl@0: test (TheView.ColUint(ord)==KMaxTUint); sl@0: test (TheView.ColUint32(ord)==KMaxTUint); sl@0: test (TheView.ColInt64(ord)==KMaxTUint); sl@0: // int8 column sl@0: ord=TheMap[EInt8]; sl@0: TheView.SetColL(ord,TUint32(127)); sl@0: test (TheView.ColInt(ord)==127); sl@0: TheView.SetColL(ord,TInt32(0)); sl@0: test (TheView.ColInt(ord)==0); sl@0: TheView.SetColL(ord,TInt64(-128)); sl@0: test (TheView.ColInt(ord)==-128); sl@0: test (TheView.ColInt8(ord)==-128); sl@0: test (TheView.ColInt16(ord)==-128); sl@0: test (TheView.ColInt32(ord)==-128); sl@0: test (TheView.ColInt64(ord)==-128); sl@0: // int16 column sl@0: ord=TheMap[EInt16]; sl@0: TheView.SetColL(ord,TUint32(32767)); sl@0: test (TheView.ColInt(ord)==32767); sl@0: TheView.SetColL(ord,TInt32(0)); sl@0: test (TheView.ColInt(ord)==0); sl@0: TheView.SetColL(ord,TInt64(-32768)); sl@0: test (TheView.ColInt(ord)==-32768); sl@0: test (TheView.ColInt16(ord)==-32768); sl@0: test (TheView.ColInt32(ord)==-32768); sl@0: test (TheView.ColInt64(ord)==-32768); sl@0: // int32 column sl@0: ord=TheMap[EInt32]; sl@0: TheView.SetColL(ord,TUint32(KMaxTInt)); sl@0: test (TheView.ColInt(ord)==KMaxTInt); sl@0: TheView.SetColL(ord,TInt32(0)); sl@0: test (TheView.ColInt(ord)==0); sl@0: TheView.SetColL(ord,TInt64(KMinTInt)); sl@0: test (TheView.ColInt(ord)==KMinTInt); sl@0: test (TheView.ColInt32(ord)==KMinTInt); sl@0: test (TheView.ColInt64(ord)==KMinTInt); sl@0: // sl@0: TheView.Cancel(); sl@0: } sl@0: sl@0: // sl@0: // Write the values to nullable column types sl@0: // sl@0: LOCAL_C void WriteMinValuesL(TInt anOffset) sl@0: { sl@0: TheView.SetColL(TheMap[anOffset+EBit],TUint(0)); sl@0: TheView.SetColL(TheMap[anOffset+EInt8],KMinTInt8); sl@0: TheView.SetColL(TheMap[anOffset+EUint8],TUint(0)); sl@0: TheView.SetColL(TheMap[anOffset+EInt16],KMinTInt16); sl@0: TheView.SetColL(TheMap[anOffset+EUint16],TUint(0)); sl@0: TheView.SetColL(TheMap[anOffset+EInt32],KMinTInt32); sl@0: TheView.SetColL(TheMap[anOffset+EUint32],TUint(0)); sl@0: TheView.SetColL(TheMap[anOffset+EInt64],KMinTInt64); sl@0: TheView.SetColL(TheMap[anOffset+EReal32],KMinTReal32); sl@0: TheView.SetColL(TheMap[anOffset+EReal64],KMinTReal64); sl@0: TheView.SetColL(TheMap[anOffset+ETime],KMinTTime); sl@0: TheView.SetColL(TheMap[anOffset+EText8],KTestShortText8); sl@0: TheView.SetColL(TheMap[anOffset+EText16],KTestShortText16); sl@0: { sl@0: TUint8 val=0; sl@0: TheView.SetColL(TheMap[anOffset+ETBinary],TPtrC8(&val,sizeof(val))); sl@0: } sl@0: TheView.SetColL(TheMap[anOffset+ELongText8],KTestShortText8); sl@0: TheView.SetColL(TheMap[anOffset+ELongText16],KTestShortText16); sl@0: RDbColWriteStream out; sl@0: out.OpenLC(TheView,TheMap[anOffset+ELongBinary]); sl@0: out.WriteUint8L(0); sl@0: out.CommitL(); sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: sl@0: // sl@0: // Write a row with the minimum (or small) column values sl@0: // return the value in the counter column sl@0: // sl@0: LOCAL_C TInt WriteMinimumL() sl@0: { sl@0: TheView.InsertL(); sl@0: WriteMinValuesL(0); sl@0: WriteMinValuesL(EBitNull-EBit); sl@0: test(!TheView.IsColNull(TheMap[ECounter])); sl@0: TInt cc=TheView.ColInt(TheMap[ECounter]); sl@0: TheView.PutL(); sl@0: return cc; sl@0: } sl@0: sl@0: LOCAL_C void CheckMinValuesL(TInt anOffset) sl@0: { sl@0: test(TheView.ColUint8(TheMap[anOffset+EBit])==0); sl@0: test(TheView.ColUint16(TheMap[anOffset+EBit])==0); sl@0: test(TheView.ColUint32(TheMap[anOffset+EBit])==0); sl@0: test(TheView.ColUint(TheMap[anOffset+EBit])==0); sl@0: test(TheView.ColInt8(TheMap[anOffset+EInt8])==KMinTInt8); sl@0: test(TheView.ColInt16(TheMap[anOffset+EInt8])==KMinTInt8); sl@0: test(TheView.ColInt32(TheMap[anOffset+EInt8])==KMinTInt8); sl@0: test(TheView.ColInt(TheMap[anOffset+EInt8])==KMinTInt8); sl@0: test(TheView.ColUint8(TheMap[anOffset+EUint8])==0); sl@0: test(TheView.ColUint16(TheMap[anOffset+EUint8])==0); sl@0: test(TheView.ColUint32(TheMap[anOffset+EUint8])==0); sl@0: test(TheView.ColUint(TheMap[anOffset+EUint8])==0); sl@0: test(TheView.ColInt16(TheMap[anOffset+EInt16])==KMinTInt16); sl@0: test(TheView.ColInt32(TheMap[anOffset+EInt16])==KMinTInt16); sl@0: test(TheView.ColInt(TheMap[anOffset+EInt16])==KMinTInt16); sl@0: test(TheView.ColUint16(TheMap[anOffset+EUint16])==0); sl@0: test(TheView.ColUint32(TheMap[anOffset+EUint16])==0); sl@0: test(TheView.ColUint(TheMap[anOffset+EUint16])==0); sl@0: test(TheView.ColInt32(TheMap[anOffset+EInt32])==KMinTInt32); sl@0: test(TheView.ColInt(TheMap[anOffset+EInt32])==KMinTInt32); sl@0: test(TheView.ColUint32(TheMap[anOffset+EUint32])==0); sl@0: test(TheView.ColUint(TheMap[anOffset+EUint32])==0); sl@0: test(TheView.ColInt64(TheMap[anOffset+EInt64])==KMinTInt64); sl@0: test(TheView.ColReal32(TheMap[anOffset+EReal32])==KMinTReal32); sl@0: test(TheView.ColReal64(TheMap[anOffset+EReal64])==KMinTReal64); sl@0: test(TheView.ColReal(TheMap[anOffset+EReal64])==KMinTReal64); sl@0: test(TheView.ColTime(TheMap[anOffset+ETime])==KMinTTime); sl@0: test(TheView.ColDes8(TheMap[anOffset+EText8])==KTestShortText8); sl@0: test(TheView.ColSize(TheMap[anOffset+EText8])==KTestShortText8.Size()); sl@0: test(TheView.ColLength(TheMap[anOffset+EText8])==KTestShortText8.Length()); sl@0: test(TheView.ColDes16(TheMap[anOffset+EText16])==KTestShortText16); sl@0: test(TheView.ColSize(TheMap[anOffset+EText16])==KTestShortText16.Size()); sl@0: test(TheView.ColLength(TheMap[anOffset+EText16])==KTestShortText16.Length()); sl@0: { sl@0: TUint8 val=0; sl@0: test(TheView.ColDes8(TheMap[anOffset+ETBinary])==TPtrC8(&val,sizeof(val))); sl@0: } sl@0: test(TheView.ColSize(TheMap[anOffset+ETBinary])==1); sl@0: test(TheView.ColLength(TheMap[anOffset+ETBinary])==1); sl@0: // sl@0: test(TheView.ColSize(TheMap[anOffset+ELongText8])==KTestShortText8.Size()); sl@0: test(TheView.ColLength(TheMap[anOffset+ELongText8])==KTestShortText8.Length()); sl@0: RDbColReadStream in; sl@0: in.OpenLC(TheView,TheMap[anOffset+ELongText8]); sl@0: in.ReadL(TheBuf8,TheView.ColLength(TheMap[anOffset+ELongText8])); sl@0: CleanupStack::PopAndDestroy(); sl@0: test(TheBuf8==KTestShortText8); sl@0: // sl@0: test(TheView.ColSize(TheMap[anOffset+ELongText16])==KTestShortText16.Size()); sl@0: test(TheView.ColLength(TheMap[anOffset+ELongText16])==KTestShortText16.Length()); sl@0: in.OpenLC(TheView,TheMap[anOffset+ELongText16]); sl@0: in.ReadL(TheBuf16,TheView.ColLength(TheMap[anOffset+ELongText16])); sl@0: CleanupStack::PopAndDestroy(); sl@0: test(TheBuf16==KTestShortText16); sl@0: // sl@0: test(TheView.ColSize(TheMap[anOffset+ELongBinary])==1); sl@0: test(TheView.ColLength(TheMap[anOffset+ELongBinary])==1); sl@0: in.OpenLC(TheView,TheMap[anOffset+ELongBinary]); sl@0: test(in.ReadUint8L()==0); sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: sl@0: // sl@0: // Check the row is the same as was written sl@0: // sl@0: LOCAL_C void CheckMinimumL(TInt aCounter) sl@0: { sl@0: TheView.GetL(); sl@0: test(TheView.ColInt32(TheMap[ECounter])==aCounter); sl@0: CheckMinValuesL(0); sl@0: CheckMinValuesL(EBitNull-EBit); sl@0: } sl@0: sl@0: LOCAL_C void WriteMaxValuesL(TInt anOffset) sl@0: { sl@0: TheView.SetColL(TheMap[anOffset+EBit],TUint(1)); sl@0: TheView.SetColL(TheMap[anOffset+EInt8],KMaxTInt8); sl@0: TheView.SetColL(TheMap[anOffset+EUint8],TUint(KMaxTUint8)); sl@0: TheView.SetColL(TheMap[anOffset+EInt16],KMaxTInt16); sl@0: TheView.SetColL(TheMap[anOffset+EUint16],TUint(KMaxTUint16)); sl@0: TheView.SetColL(TheMap[anOffset+EInt32],KMaxTInt32); sl@0: TheView.SetColL(TheMap[anOffset+EUint32],KMaxTUint32); sl@0: TheView.SetColL(TheMap[anOffset+EInt64],KMaxTInt64); sl@0: TheView.SetColL(TheMap[anOffset+EReal32],KMaxTReal32); sl@0: TheView.SetColL(TheMap[anOffset+EReal64],KMaxTReal64); sl@0: TheView.SetColL(TheMap[anOffset+ETime],KMaxTTime); sl@0: TheView.SetColL(TheMap[anOffset+EText8],KTestText8); sl@0: TheView.SetColL(TheMap[anOffset+EText16],KTestText16); sl@0: TheView.SetColL(TheMap[anOffset+ETBinary],TPtrC8((TUint8*)&TheMap[0],sizeof(TheMap))); sl@0: TheView.SetColL(TheMap[anOffset+ELongText8],KTestLongText8); sl@0: TheView.SetColL(TheMap[anOffset+ELongText16],KTestLongText16); sl@0: RDbColWriteStream out; sl@0: out.OpenLC(TheView,TheMap[anOffset+ELongBinary]); sl@0: for (TInt ii=0;ii sl@0: void TestOverflowL(TDbColNo aCol,const T& aValue) sl@0: { sl@0: TheView.UpdateL(); sl@0: TheView.SetColL(aCol,aValue); sl@0: TRAPD(r,TheView.PutL()); sl@0: test(r==KErrOverflow); sl@0: TheView.Cancel(); sl@0: } sl@0: sl@0: LOCAL_C void TestWriteNullL(TDbColNo aCol) sl@0: { sl@0: TheView.UpdateL(); sl@0: TheView.SetColNullL(aCol); sl@0: TRAPD(r,TheView.PutL()); sl@0: test(r==KErrNotFound); sl@0: TheView.Cancel(); sl@0: } sl@0: sl@0: LOCAL_C void TestValidationL() sl@0: { sl@0: TheView.InsertL(); sl@0: WriteMinValuesL(0); sl@0: TheView.PutL(); sl@0: TestOverflowL(TheMap[EBit],TUint(2)); sl@0: TestOverflowL(TheMap[EBit],TUint(0xffffffffu)); sl@0: TestOverflowL(TheMap[EInt8],TInt(-129)); sl@0: TestOverflowL(TheMap[EInt8],TInt(128)); sl@0: TestOverflowL(TheMap[EUint8],TUint(0xffffffffu)); sl@0: TestOverflowL(TheMap[EUint8],TUint(256)); sl@0: TestOverflowL(TheMap[EInt16],TInt(-32769)); sl@0: TestOverflowL(TheMap[EInt16],TInt(32768)); sl@0: TestOverflowL(TheMap[EUint16],TUint(0xffffffffu)); sl@0: TestOverflowL(TheMap[EUint16],TUint(65536)); sl@0: { sl@0: TBuf8 buf; sl@0: buf.SetMax(); sl@0: buf.Fill('x'); sl@0: TestOverflowL(TheMap[EText8],buf); sl@0: } sl@0: { sl@0: TBuf16 buf; sl@0: buf.SetMax(); sl@0: buf.Fill('x'); sl@0: TestOverflowL(TheMap[EText16],buf); sl@0: } sl@0: for (TInt ii=EBit;iiColNo(TPtrC(AllColumns[ii].iName)); sl@0: delete cs; sl@0: test.Next(_L("Test integral accessors")); sl@0: CheckIntAccessorsL(); sl@0: test.Next(_L("Add row of minimum values")); sl@0: TInt c1=WriteMinimumL(); sl@0: test.Next(_L("Add row of maximum values")); sl@0: TInt c2=WriteMaximumL(); sl@0: test(c2>c1); sl@0: test.Next(_L("Add row of Null values")); sl@0: TInt c3=WriteNullL(); sl@0: test(c3>c2); sl@0: test.Next(_L("Add a copy of the last row")); sl@0: TInt c4=WriteCopyL(); sl@0: test(c4>c3); sl@0: test.Next(_L("Check minimum values")); sl@0: TheView.FirstL(); sl@0: CheckMinimumL(c1); sl@0: test.Next(_L("Check maximum values")); sl@0: TheView.NextL(); sl@0: CheckMaximumL(c2); sl@0: test.Next(_L("Check Null values")); sl@0: TheView.NextL(); sl@0: CheckNullL(c3); sl@0: TheView.NextL(); sl@0: CheckNullL(c4); sl@0: test.Next(_L("Test column value Validation")); sl@0: TestValidationL(); sl@0: TheView.Close(); sl@0: CloseDatabase(); sl@0: test.End(); sl@0: } sl@0: sl@0: const TPtrC KColumnID(_S("id")); sl@0: const TPtrC KColumnText(_S("txt")); sl@0: const TPtrC KColumnOther(_S("other")); sl@0: const TPtrC KBlobText(_S("text")); sl@0: const TPtrC KFind1(_S("id=1")); sl@0: const TPtrC KFind2(_S("id is null")); sl@0: sl@0: // records will be: sl@0: // 0: "text" sl@0: // 1: "aaa...aaatext" sl@0: // 2: "textaaa...aaa" sl@0: // 3: "aaa...aaa" sl@0: // 4: "aaa...aaatextaaa...aaa" sl@0: // 5: "" sl@0: sl@0: struct STest sl@0: { sl@0: const TText* iText; sl@0: TUint iRecs; sl@0: }; sl@0: sl@0: LOCAL_D STest const Tests[]= sl@0: { sl@0: {_S("txt like 'a*'"),0x010110}, sl@0: {_S("txt like 'a*' or other like 'a*'"),0x111111}, sl@0: {_S("txt like 'a*' and other like 'a*'"),0x010110}, sl@0: {_S("txt < 'text'"),0x010111}, sl@0: {_S("txt > 'text'"),0x001000}, sl@0: {_S("txt > ''"),0x111110}, sl@0: {_S("txt like 'text'"),0x100000}, sl@0: {_S("txt like '*TEXT'"),0x110000}, sl@0: {_S("txt like 'text*'"),0x101000}, sl@0: {_S("txt like '*text*'"),0x111010}, sl@0: {_S("txt like '*'"),0x111111}, sl@0: {_S("txt like '?*'"),0x111110}, sl@0: {_S("txt like '*t*t*'"),0x111010}, sl@0: {_S("txt like '*a??t*'"),0x010010}, sl@0: {_S("txt like 'aA*aa'"),0x000110}, sl@0: {_S("txt like 'teXT'"),0x100000}, sl@0: {_S("txt like '*text'"),0x110000}, sl@0: {_S("txt like '*tExt*'"),0x111010}, sl@0: {_S("txt like ''"),0x000001}, sl@0: {_S("txt is null"),0x000001} sl@0: }; sl@0: sl@0: LOCAL_C void CreateFindTableL() sl@0: { sl@0: CDbColSet *pC=CDbColSet::NewL(); sl@0: CleanupStack::PushL(pC); sl@0: pC->AddL(TDbCol(KColumnID,EDbColUint32)); sl@0: pC->AddL(TDbCol(KColumnText,EDbColLongText,200)); sl@0: pC->AddL(TDbCol(KColumnOther,EDbColText,200)); sl@0: test(TheDatabase.CreateTable(KTestFindTable,*pC)==KErrNone); sl@0: CleanupStack::PopAndDestroy(); sl@0: test(TheTable.Open(TheDatabase,KTestFindTable,TheTable.EInsertOnly)==KErrNone); sl@0: TBuf<0x40> garbage; sl@0: garbage.SetMax(); sl@0: garbage.Fill('a'); sl@0: TBuf<0xff> col; sl@0: for (TUint ii=0;ii<6;++ii) sl@0: { sl@0: TheTable.InsertL(); sl@0: TheTable.SetColL(1,ii); sl@0: TheTable.SetColL(3,_L("abcdef")); sl@0: sl@0: switch (ii) sl@0: { sl@0: case 0: sl@0: TheTable.SetColL(2,KBlobText); sl@0: break; sl@0: case 1: sl@0: col=garbage; sl@0: col+=KBlobText; sl@0: TheTable.SetColL(2,col); sl@0: break; sl@0: case 2: sl@0: col=KBlobText; sl@0: col+=garbage; sl@0: TheTable.SetColL(2,col); sl@0: break; sl@0: case 3: sl@0: TheTable.SetColL(2,garbage); sl@0: break; sl@0: case 4: sl@0: col=garbage; sl@0: col+=KBlobText; sl@0: col+=garbage; sl@0: TheTable.SetColL(2,col); sl@0: break; sl@0: case 5: sl@0: break; sl@0: } sl@0: TheTable.PutL(); sl@0: } sl@0: TheTable.Close(); sl@0: CDbKey* key=CDbKey::NewLC(); sl@0: key->AddL(KColumnID); sl@0: key->MakeUnique(); sl@0: test(TheDatabase.CreateIndex(KIndexName,KTestFindTable,*key)==KErrNone); sl@0: key->Clear(); sl@0: key->AddL(TDbKeyCol(KColumnText,100)); sl@0: key->MakeUnique(); sl@0: key->SetComparison(EDbCompareFolded); sl@0: test(TheDatabase.CreateIndex(KIndexName2,KTestFindTable,*key)==KErrNone); sl@0: CleanupStack::PopAndDestroy(); //key sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-0598 sl@0: @SYMTestCaseDesc Tests for RDbRowConstraint::Open() function sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for the specified SQL search-condition for matching against rows in the specified rowset sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestMatchL() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0598 Match ")); sl@0: test(TheTable.Open(TheDatabase,KTestFindTable,TheTable.EReadOnly)==KErrNone); sl@0: for (TInt ii=0;ii>(TheTable.ColUint32(1)*4); sl@0: test((bit&mask)==0); sl@0: mask|=bit; sl@0: } sl@0: } sl@0: match.Close(); sl@0: test(mask==Tests[ii].iRecs); sl@0: } sl@0: TheTable.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-0599 sl@0: @SYMTestCaseDesc Tests for RDbRowSet::FindL(),RDbRowSet::GetL() functions sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for finding a match through a rowset sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestFindL(RDbRowSet& aSet) sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0599 ")); sl@0: CDbColSet* cs=aSet.ColSetL(); sl@0: test(cs!=0); sl@0: TDbColNo col=cs->ColNo(KColumnID); sl@0: test(col!=KDbNullColNo); sl@0: delete cs; sl@0: aSet.FirstL(); sl@0: TInt p1=aSet.FindL(aSet.EForwards,KFind1); sl@0: test(p1>=0); sl@0: aSet.GetL(); sl@0: test(aSet.ColUint(col)==1); sl@0: test(aSet.FindL(aSet.EForwards,KFind1)==0); sl@0: aSet.GetL(); sl@0: test(aSet.ColUint(col)==1); sl@0: if (aSet.NextL()) sl@0: test(aSet.FindL(aSet.EForwards,KFind1)==KErrNotFound); sl@0: aSet.FirstL(); sl@0: test(aSet.FindL(aSet.EForwards,KFind2)==KErrNotFound); sl@0: aSet.LastL(); sl@0: TInt p2=aSet.FindL(aSet.EBackwards,KFind1); sl@0: test(p2>=0); sl@0: aSet.GetL(); sl@0: test(aSet.ColUint(col)==1); sl@0: test(aSet.FindL(aSet.EBackwards,KFind1)==0); sl@0: aSet.GetL(); sl@0: test(aSet.ColUint(col)==1); sl@0: if (aSet.PreviousL()) sl@0: test(aSet.FindL(aSet.EBackwards,KFind1)==KErrNotFound); sl@0: aSet.LastL(); sl@0: test(aSet.FindL(aSet.EBackwards,KFind2)==KErrNotFound); sl@0: test(p1+p2+1==aSet.CountL()); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-0600 sl@0: @SYMTestCaseDesc Tests for SQL find sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for SQL querying a table sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestSQLFindL(const TText* aSql) sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0600 ")); sl@0: test(TheView.Prepare(TheDatabase,TDbQuery(TPtrC(aSql),EDbCompareFolded),TheView.EReadOnly)==KErrNone); sl@0: test(TheView.EvaluateAll()==KErrNone); sl@0: TestFindL(TheView); sl@0: TheView.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-0601 sl@0: @SYMTestCaseDesc Tests for DBMS limits sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for maximum length boundaries sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDbmsBoundaries() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0601 ")); sl@0: // Test KMaxSegmentLength boundary sl@0: sl@0: _LIT(KMaxSegmentLengthMinusOne,"txt like \ sl@0: '*01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567@0.com*' \ sl@0: or other like \ sl@0: '*01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567@0.com*'"); sl@0: _LIT(KMaxSegmentLengthExact,"txt like \ sl@0: '*012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678@0.com*' \ sl@0: or other like \ sl@0: '*012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678@0.com*'"); sl@0: _LIT(KMaxSegmentLengthPlusOne,"txt like \ sl@0: '*0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789@0.com*' \ sl@0: or other like \ sl@0: '*0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789@0.com*'"); sl@0: sl@0: TInt ret=KErrNone; sl@0: RDbRowConstraint match; sl@0: sl@0: test(TheTable.Open(TheDatabase,KTestFindTable,TheTable.EReadOnly)==KErrNone); sl@0: sl@0: // Test one less than the boundary sl@0: ret = match.Open(TheTable,TDbQuery(KMaxSegmentLengthMinusOne,EDbCompareFolded)); sl@0: match.Close(); sl@0: test(ret==KErrNone); sl@0: sl@0: // Test the boundary sl@0: ret = match.Open(TheTable,TDbQuery(KMaxSegmentLengthExact,EDbCompareFolded)); sl@0: match.Close(); sl@0: test(ret==KErrNone); sl@0: sl@0: // Test one more than the boundary sl@0: ret = match.Open(TheTable,TDbQuery(KMaxSegmentLengthPlusOne,EDbCompareFolded)); sl@0: match.Close(); sl@0: test(ret==KErrArgument); sl@0: sl@0: TheTable.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-0602 sl@0: @SYMTestCaseDesc Tests for table order,SQL query, sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for finding a row in a rowset,dbms boundaries,SQL querying sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestFindL() sl@0: { sl@0: test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0602 Table order ")); sl@0: test(TheTable.Open(TheDatabase,KTestFindTable,TheTable.EReadOnly)==KErrNone); sl@0: TestFindL(TheTable); sl@0: test.Next(_L("Index order")); sl@0: test(TheTable.SetIndex(KIndexName)==KErrNone); sl@0: TestFindL(TheTable); sl@0: test(TheTable.SetIndex(KIndexName2)==KErrNone); sl@0: TestFindL(TheTable); sl@0: TheTable.Close(); sl@0: sl@0: test.Next(_L("SQL query test boundary")); sl@0: TestDbmsBoundaries(); sl@0: sl@0: test.Next(_L("SQL query")); sl@0: TestSQLFindL(_S("select id from TestFindTable where id=1")); sl@0: TestSQLFindL(_S("select * from TestFindTable where id<=2")); sl@0: TestSQLFindL(_S("select txt,id from TestFindTable order by id desc")); sl@0: TestSQLFindL(_S("select id,txt from TestFindTable where id=1 or txt like '*text*'")); sl@0: TestSQLFindL(_S("select * from TestFindTable where id=1 or txt is not null order by id")); sl@0: TestSQLFindL(_S("select id from TestFindTable where id<>3 order by txt")); sl@0: test.End(); sl@0: } sl@0: sl@0: LOCAL_C void TestBookmarkL(RDbRowSet& aSet) sl@0: { sl@0: aSet.BeginningL(); sl@0: while (aSet.NextL()) sl@0: { sl@0: aSet.GetL(); sl@0: TUint id=aSet.ColUint(1); sl@0: TDbBookmark mark=aSet.Bookmark(); sl@0: aSet.BeginningL(); sl@0: aSet.GotoL(mark); sl@0: aSet.GetL(); sl@0: test(aSet.ColUint(1)==id); sl@0: aSet.NextL(); sl@0: aSet.PreviousL(); sl@0: aSet.PreviousL(); sl@0: aSet.NextL(); sl@0: aSet.GetL(); sl@0: test(aSet.ColUint(1)==id); sl@0: aSet.GotoL(mark); sl@0: }; sl@0: } sl@0: sl@0: LOCAL_C void TestSQLBookmarkL(const TText* aSql) sl@0: { sl@0: test(TheView.Prepare(TheDatabase,TDbQuery(TPtrC(aSql),EDbCompareFolded),TheView.EReadOnly)==KErrNone); sl@0: test(TheView.EvaluateAll()==KErrNone); sl@0: TestBookmarkL(TheView); sl@0: TheView.Close(); sl@0: } sl@0: sl@0: LOCAL_C void TestBookmarkL() sl@0: { sl@0: test.Start(_L("Table order")); sl@0: test(TheTable.Open(TheDatabase,KTestFindTable,TheTable.EReadOnly)==KErrNone); sl@0: TestBookmarkL(TheTable); sl@0: test.Next(_L("Index order")); sl@0: test(TheTable.SetIndex(KIndexName)==KErrNone); sl@0: TestBookmarkL(TheTable); sl@0: test(TheTable.SetIndex(KIndexName2)==KErrNone); sl@0: TestBookmarkL(TheTable); sl@0: TheTable.Close(); sl@0: test.Next(_L("SQL query")); sl@0: TestSQLBookmarkL(_S("select * from TestFindTable where id=1")); sl@0: TestSQLBookmarkL(_S("select * from TestFindTable where id>2")); sl@0: TestSQLBookmarkL(_S("select * from TestFindTable order by id desc")); sl@0: TestSQLBookmarkL(_S("select * from TestFindTable where txt like '*text*'")); sl@0: TestSQLBookmarkL(_S("select * from TestFindTable where txt is not null order by id")); sl@0: TestSQLBookmarkL(_S("select * from TestFindTable where id <> 3 order by txt")); sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-0603 sl@0: @SYMTestCaseDesc Tests for find and bookmark sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Executes Match,Find,Bookmarks tests sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestFindAndBookmarkL() sl@0: { sl@0: test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0603 Create Table ")); sl@0: OpenDatabase(); sl@0: CreateFindTableL(); sl@0: TestMatchL(); sl@0: test.Next(_L("Find")); sl@0: TestFindL(); sl@0: test.Next(_L("Bookmarks")); sl@0: TestBookmarkL(); sl@0: test.Next(_L("Close")); sl@0: CloseDatabase(); sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-0604 sl@0: @SYMTestCaseDesc Tests for multi view sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for adding and deleting rows sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestMultiViewL() sl@0: { sl@0: test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0604 Create Table ")); sl@0: OpenDatabase(); sl@0: CDbColSet* set=CreateColSetL(ESingleColumn); sl@0: test(TheDatabase.CreateTable(KTestMultiTable,*set)==KErrNone); sl@0: delete set; sl@0: test.Next(_L("Add and modify rows")); sl@0: test(TheTable.Open(TheDatabase,KTestMultiTable)==KErrNone); sl@0: test(TheView.Prepare(TheDatabase,_L("select * from TestMultiTable"))==KErrNone); sl@0: test(TheView.EvaluateAll()==KErrNone); sl@0: for (TInt ii=1;ii<=10;++ii) sl@0: { sl@0: TheTable.InsertL(); sl@0: TheTable.SetColL(1,ii); sl@0: TheTable.PutL(); sl@0: TheView.NextL(); sl@0: TheView.GetL(); sl@0: test(TheView.ColInt(1)==ii); sl@0: TheView.UpdateL(); sl@0: TheView.SetColL(1,ii+100); sl@0: TheView.PutL(); sl@0: test(TheTable.ColInt(1)==ii); sl@0: TheTable.GetL(); sl@0: test(TheTable.ColInt(1)==ii+100); sl@0: } sl@0: test.Next(_L("delete rows")); sl@0: TheView.FirstL(); sl@0: TheTable.FirstL(); sl@0: TheView.GetL(); sl@0: test (TheView.ColInt(1)==1+100); sl@0: TheTable.DeleteL(); sl@0: TRAPD(r,TheView.GetL()); sl@0: test(r!=KErrNone); sl@0: TheView.NextL(); sl@0: TheView.GetL(); sl@0: test (TheView.ColInt(1)==2+100); sl@0: TheView.DeleteL(); sl@0: test(!TheView.PreviousL()); sl@0: TheTable.NextL(); sl@0: test(!TheTable.PreviousL()); sl@0: test.End(); sl@0: TheView.Close(); sl@0: TheTable.Close(); sl@0: CloseDatabase(); sl@0: } sl@0: sl@0: LOCAL_C void ValidateUID3(const TDesC& aDbName, const TUid& aUid) sl@0: { sl@0: test.Next(_L("Read DB header")); sl@0: RFile dbFile; sl@0: TInt err = dbFile.Open(TheFs, aDbName, EFileRead); sl@0: test(err==KErrNone); sl@0: TBuf8<100> contents; // header of a new DB is approx 77 bytes sl@0: err = dbFile.Read(contents); sl@0: dbFile.Close(); sl@0: test(err==KErrNone); sl@0: sl@0: test.Next(_L("Check UID3")); sl@0: const TPtrC8 ptr((const TUint8*) &aUid.iUid, sizeof(aUid.iUid)); sl@0: TInt pos = contents.Find(ptr); sl@0: test(pos==8); // UID3 begins at byte pos 8 sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-DBMS-CT-1372 sl@0: @SYMTestCaseDesc Tests for UID3 being set in DB header sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Creates a new DB and checks UID3 sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDbUID3() sl@0: { sl@0: const TUid KOrigUid = {0x19768253}; // random UID sl@0: const TUid KReplaceUid = {0x24731264}; // different random UID sl@0: const TPtrC KTempDbName(_S("C:\\DBMS-TST\\T_DBMS_UID3.DB")); sl@0: sl@0: (void)TheFs.Delete(KTempDbName); sl@0: sl@0: test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1372 Create Database ")); sl@0: RDbNamedDatabase tempDb; sl@0: TInt err = tempDb.Create(TheFs, KTempDbName, KOrigUid.Name()); sl@0: test(err==KErrNone); sl@0: tempDb.Close(); sl@0: sl@0: ValidateUID3(KTempDbName, KOrigUid); sl@0: sl@0: test.Next(_L("Replace Database")); sl@0: err = tempDb.Replace(TheFs, KTempDbName, KReplaceUid.Name()); sl@0: test(err==KErrNone); sl@0: tempDb.Close(); sl@0: sl@0: ValidateUID3(KTempDbName, KReplaceUid); sl@0: sl@0: test.Next(_L("Replace Database using default UID3")); sl@0: err = tempDb.Replace(TheFs, KTempDbName); sl@0: test(err==KErrNone); sl@0: tempDb.Close(); sl@0: sl@0: ValidateUID3(KTempDbName, KNullUid); sl@0: sl@0: (void)TheFs.Delete(KTempDbName); sl@0: test.End(); sl@0: } sl@0: sl@0: LOCAL_C void Test() sl@0: { sl@0: __UHEAP_MARK; sl@0: test.Start(_L("DDL")); sl@0: TRAPD(r,TestDDL();) sl@0: test(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: __UHEAP_MARK; sl@0: test.Next(_L("Navigation/Edit")); sl@0: TRAP(r,TestViewL();) sl@0: test(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: __UHEAP_MARK; sl@0: test.Next(_L("Column Types")); sl@0: TRAP(r,TestTypesL();) sl@0: test(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: __UHEAP_MARK; sl@0: test.Next(_L("Find, Match & Bookmarks")); sl@0: TRAP(r,TestFindAndBookmarkL();) sl@0: test(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: __UHEAP_MARK; sl@0: test.Next(_L("Multiple view updates")); sl@0: TRAP(r,TestMultiViewL();) sl@0: test(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: __UHEAP_MARK; sl@0: test.Next(_L("Database UID3")); sl@0: TRAP(r,TestDbUID3();) sl@0: test(r==KErrNone); sl@0: test.End(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: // sl@0: // Prepare the test directory. sl@0: // sl@0: LOCAL_C void setupTestDirectory() sl@0: { sl@0: TInt r=TheFs.Connect(); sl@0: test(r==KErrNone); sl@0: // sl@0: r=TheFs.MkDir(KTestDatabase); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: } sl@0: sl@0: // sl@0: // Initialise the cleanup stack. sl@0: // sl@0: LOCAL_C void setupCleanup() sl@0: { sl@0: TheTrapCleanup=CTrapCleanup::New(); sl@0: test(TheTrapCleanup!=NULL); sl@0: TRAPD(r,\ sl@0: {\ sl@0: for (TInt i=KTestCleanupStack;i>0;i--)\ sl@0: CleanupStack::PushL((TAny*)0);\ sl@0: CleanupStack::Pop(KTestCleanupStack);\ sl@0: }); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void DeleteDataFile(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: RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName); sl@0: err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Print(_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: RDebug::Print(_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: RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName); sl@0: } sl@0: } sl@0: sl@0: // sl@0: // Test streaming conversions. sl@0: // sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: test.Title(); sl@0: setupTestDirectory(); sl@0: setupCleanup(); sl@0: __UHEAP_MARK; sl@0: // sl@0: TInt r=TheDbs.Connect(); sl@0: test (r==KErrNone); sl@0: test.Start(_L("Standard database")); sl@0: Test(); sl@0: test.Next(_L("Secure database")); sl@0: Test(); sl@0: TheDbs.Close(); sl@0: test.End(); sl@0: // sl@0: __UHEAP_MARKEND; sl@0: delete TheTrapCleanup; sl@0: sl@0: ::DeleteDataFile(KTestDatabase); sl@0: sl@0: TheFs.Close(); sl@0: test.Close(); sl@0: return 0; sl@0: }