diff -r 5da8188e392b -r ae47d0499bee commsconfig/commsdatabaseshim/ts_commdb/Step_064_xx.cpp --- a/commsconfig/commsdatabaseshim/ts_commdb/Step_064_xx.cpp Tue Aug 24 14:43:02 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,190 +0,0 @@ -// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// This contains CommDb Unit Test Cases 0064.XX -// -// - -// EPOC includes -#include -#include - - -// Test system includes -#include -#include -#include "Teststepcommdb.h" -#include "TestSuiteCommdb.h" -#include "Step_064_xx.h" - -#include -#include -#include - - -// table name -_LIT(KCDTypeNameTestTable, "Test"); - -#define KCDTypeNameBinaryFieldTest _S("BinaryTest") - -// record type id -const TMDBElementId KCDTIdTestRecord = 0x5F800000; -// field type ids -const TMDBElementId KCDTIdTestBinaryField = 0x00150000; - - -static const SGenericRecordTypeInfo TestGenRecordInfoBinary[] = - { - MDB_GENERIC_TYPE_INFO(KCDTIdRecordTag, EUint32, ENoAttrs, KCDTypeNameRecordTag), - MDB_GENERIC_TYPE_INFO(KCDTIdRecordName, EText, ENotNull, KCDTypeNameRecordName), - MDB_GENERIC_TYPE_INFO(KCDTIdTestBinaryField, EDesC8, ENoAttrs, KCDTypeNameBinaryFieldTest), - MDB_GENERIC_TYPE_INFO(0, 0, ENoAttrs, KCDNull) - }; - - - -NONSHARABLE_CLASS(CCDTestBinaryRecord) : public CCDRecordBase - { -public : - - // Constructor - CCDTestBinaryRecord(TMDBElementId aElementId) - : CCDRecordBase(aElementId), - iBinaryField((aElementId & KCDMaskShowRecordType) | KCDTIdTestBinaryField), - iRecordTag((aElementId & KCDMaskShowRecordType) | KCDTIdRecordTag), - iRecordName((aElementId & KCDMaskShowRecordType) | KCDTIdRecordName) - {} - - const SRecordTypeInfo* GetRecordInfo(){return iRecordInfo;} - - DATA_VTABLE - -public : - - CMDBField iBinaryField; - CMDBField iRecordTag; - CMDBField iRecordName; - -private: - - static const SRecordTypeInfo iRecordInfo[]; - }; - - - - -const SRecordTypeInfo CCDTestBinaryRecord::iRecordInfo[]= - { - { KCDTIdRecordTag, EInt, ENoAttrs, KCDTypeNameRecordTag }, - { KCDTIdRecordName, EText, ENotNull, KCDTypeNameRecordName }, - { KCDTIdTestBinaryField, EDesC8, ENotNull, KCDTypeNameBinaryFieldTest }, - { 0, 0, ENoAttrs, KCDNull } - }; - - -START_ATTRIBUTE_TABLE(CCDTestBinaryRecord, KCDTIdTestRecord, KCDTIdTestRecord ) - X_REGISTER_ATTRIBUTE(CCDTestBinaryRecord, iBinaryField, TMDBBin) - X_REGISTER_ATTRIBUTE(CCDTestBinaryRecord, iRecordTag, TMDBNum ) - X_REGISTER_ATTRIBUTE(CCDTestBinaryRecord, iRecordName, TMDBText ) -END_ATTRIBUTE_TABLE() - - -_LIT8(KTestBinary, "a long binary string,a long binary string,a long binary string,a long binary string,a long binary string,a long binary string,a long binary string,end"); - - - - - -// -// Test step 064.001 -// - -// constructor -CCommDbTest064_01::CCommDbTest064_01() - { - // store the name of this test case - iTestStepName = _L("step_064_01"); - } - -// destructor -CCommDbTest064_01::~CCommDbTest064_01() - { - } - - -TInt CCommDbTest064_01::executeStepL() - { - TInt ret=KErrGeneral; - - //set up a generic record with a binary field - INFO_PRINTF1(_L("Creating a user defined table")); - - CMDBSession *cmdbSession = CMDBSession::NewL(KCDVersion1_1); - - CleanupStack::PushL(cmdbSession); - - CMDBGenericRecord* testRecord = static_cast(CCDRecordBase::RecordFactoryL(KCDNewTableRequest)); - CleanupStack::PushL(testRecord); - testRecord->InitializeL(KCDTypeNameTestTable(), TestGenRecordInfoBinary); - - testRecord->StoreL(*cmdbSession); - CleanupStack::PopAndDestroy(testRecord); - CleanupStack::PopAndDestroy(cmdbSession); - - - //now use commdbshim api to read and write to the binary field - CCommsDatabase* theDb; - CCommsDbTableView* theView; - TUint32 recordId; - - //CDBLEAVE( iTheView->PutRecordChanges(), KErrNone ); - theDb = CCommsDatabase::NewL(); - theView = theDb->OpenTableLC( KCDTypeNameTestTable ); - CleanupStack::Pop(); - - TBuf8 value(KTestBinary); - CDBLEAVE(theView->InsertRecord(recordId), KErrNone ); - theView->WriteTextL(TPtrC(KCDTypeNameBinaryFieldTest), value ); - CDBLEAVE(theView->PutRecordChanges(), KErrNone ); - CDBLEAVE(theView->GotoFirstRecord(), KErrNone ); - - TBuf8 value2; - theView->ReadTextL( TPtrC(KCDTypeNameBinaryFieldTest), value2 ); - - if( value2.Compare( value ) == 0) - { - ret = KErrNone; - } - - delete theView; - delete theDb; - - return ret; - } - - -TVerdict CCommDbTest064_01::doTestStepL( ) - { - Log(_L("Step 064.01 called ")); - - - if ( executeStepL() == KErrNone ) - iTestStepResult = EPass; - else - iTestStepResult = EFail; - - - return iTestStepResult; - } - -