Пример #1
0
/**
add agent field to contact b, set value of agent in b to id of contact a.
check that agent field is retrieved/stored correctly, check that access count is
not modified for either contact
*/	
void CAccessCountTests::AgentAccessCountTestL()
	{
	TContactItemId RetrievedAgentId = -1;
	TContactItemId PreviousContactId = iIterate->NextL();//contact a
	TContactItemId CurrentContactId = iIterate->NextL();//contact b
	
	//open current contact
	OpenL(CurrentContactId,*iViewAll);
	//add new agent field, set to previous contact id
	AddAgentFieldL(PreviousContactId);
	CommitL();
	
	//get agent id store for current contact
	RetrievedAgentId = GetAgentFieldL(CurrentContactId);
	
	//get access count of current contact
	ReadL(CurrentContactId, *iViewAll);
	const TInt KCurrentContactAccessCount = iContactItem->AccessCount();
	Close();
	
	//get access count of previous contact
	ReadL(PreviousContactId, *iViewAll);
	const TInt KPreviousContactAccessCount = iContactItem->AccessCount();
	Close();
	
	//check that retrieved agent id equals previous contact id
	INTCOMPARE( RetrievedAgentId , ==,  PreviousContactId, 0, 0 );
	//check that changing the agent field values doesnt not affect the access count
	//of involved contacts
	INTCOMPARE( KCurrentContactAccessCount , ==,  0, 0, 0 ); 
	INTCOMPARE( KPreviousContactAccessCount , ==,  0, 0, 0 );
	}
Пример #2
0
/**
open acid, increase access count to 1, attempt to delete contact, check that it has
not been deleted, set access count to 0, delete, and check that it has been deleted.
*/
void CAccessCountTests::AccessCountTestL(const TContactItemId aCid)
	{
	TInt err = KErrNone;
	static const TInt KAccessCount = 1;//increase access count of contact by 1, 
										
	TInt i = 0;
	
	OpenL(aCid,*iViewAll);
	SetContactFieldsL(*iContactItem);
	for(i = 0; i < KAccessCount; ++i )
		{
		iContactItem->IncAccessCount();
		}
	CommitL();
	
	ReadL(aCid, *iViewAll);
	const TInt KInitialAccessCount = iContactItem->AccessCount();//facount
	const TInt KInitialFieldCount = iFields->Count(); //fcount
	const TInt KInitialEmptyFields = CountEmpty(*iFields);//fhcount
	Close();
	
	INTCOMPARE(  KInitialEmptyFields , ==,  0 , 0, 0 );
	INTCOMPARE(  KInitialFieldCount , >,  0 , 0, 0 );
	
	for(i = 0; i < KAccessCount; ++i )
		{
		iContactsDatabase->DeleteContactL(aCid);
		}
		
	ReadL(aCid,*iViewAll);
	const TInt KModifiedAccessCount = iContactItem->AccessCount();//dacount
	const TInt KModifiedFieldCount 	= iFields->Count();//dcount
	const TInt KModifiedEmptyFields = CountEmpty(*iFields);//dHcount
	Close();
	
	/*
	check that deleting a contact doesnt modify its access count
	check that deleting a contact with access count > 1, 
	deletes all fields associated with contact but not the contact item itself
	*/
	INTCOMPARE(  KModifiedAccessCount , ==,  KInitialAccessCount , 0, 0 ); 
	INTCOMPARE(  KInitialFieldCount , ==,  KModifiedFieldCount , 0, 0 );
	INTCOMPARE(  KModifiedEmptyFields , ==,  KInitialFieldCount , 0, 0 ); 
	INTCOMPARE(  KModifiedFieldCount , ==,  KModifiedEmptyFields , 0, 0 );
	
	OpenL(aCid,*iViewAll);
	for(i = 0; i < KAccessCount; ++i )
		{
		iContactItem->DecAccessCount();
		}
	const TInt lAcount = iContactItem->AccessCount();
	CommitL();
	
	INTCOMPARE( lAcount , ==,  0, 0, 0 );
	
	TRAP( err, ReadL(aCid, *iViewAll) );
	Close();
	
	INTCOMPARE(  err , ==,  KErrNotFound , 0, 0 );
	}
Пример #3
0
void CTransactionsStep::CreateCommitTransactionTestL(const TBool aRevert)
	{
	iContacts = 0;
	CPerformanceFunctionalityBase::InitializeL();
	
	CContactItemFieldSet& templateFields = iTemplate->CardFields();
	TInt fieldsCount = templateFields.Count() - 1;
	
	iContactsDatabase->DatabaseBeginLC(EFalse);
	
	iContacts = 2;
	TInt k = 0;
	CContactCard* contact = CContactCard::NewLC(iTemplate);
	for(; k < iContacts; k++)
		{		
		iIterate->AddL( iContactsDatabase->doAddNewContactL(*contact,EFalse,ETrue) );
		}	
	CleanupStack::PopAndDestroy(contact);
	
	EndTransactionL(aRevert);
	
	if(aRevert)
		{
		iIterate->Reset();
		TInt err = KErrNone;
		TESTPRINT( iContactsDatabase->CountL() == 0 );
		
		for( k = 0; k < iContacts; ++k)
			{
			TRAP(err, ReadL( iIterate->NextL() ) );
			TESTPRINTI( KErrNotFound == err, k );
			CloseL( ETrue );
			}
		}
	else
		{
		iIterate->Reset();
		TESTPRINT( ( iContactsDatabase->CountL() == iContacts ) );
		
		for(k = 0; k < iContacts; ++k)
			{
			ReadL( iIterate->NextL() );
			TESTPRINTI( iFields->Count() == fieldsCount, k );
			TESTPRINTI( CheckAllFieldsL(KNullDesC), k );
			CloseL( ETrue );
			}
		}
	}	
Пример #4
0
void CJournalFile::ConstructL(const TDesC& aFileName)
	{
	DEBUG_PRINTF2(_L("CJournalFile::ConstructL() - aFileName %S"), &aFileName);							
	iJournalFileName = aFileName;
	
	TChar drive;
	User::LeaveIfError(iFs.DriveToChar(iDrive, drive));
	
	TBuf<2> driveSpec;
	driveSpec.Append(drive);
	driveSpec.Append(KDriveDelimiter);
	iTreeRoot = CIntegrityTreeNode::NewL(driveSpec);
	
	// read any existing entries from this journal
	TRAPD(err, ReadL());
	if(err != KErrNone)
		{
		DEBUG_PRINTF2(_L("CJournalFile::ConstructL() - CJournalFile::ReadL() has left with error %d"), err);							
		// if necessary create the path
		if(err == KErrPathNotFound)
			{
			User::LeaveIfError(iFs.MkDirAll(iJournalFileName));
			}
		else if (err != KErrNotFound)
			{
			DEBUG_PRINTF2(_L("CJournalFile::ConstructL() - Leaving with error %d"), err);							
			User::Leave(err);
			}
		}
	// now prepare for writing
	PrepareToWriteL();
	}
/**initilize called within __UHEAP_MARK/__UHEAP_MARKEND of doTestStepL,
so that all relevant memmory de/allocation is in scope*/
void CPerformanceFunctionalityBase::InitializeL()
	{
	CLEAR(iContactsDatabase);
	iIterate->Clear();
	if( iConcurrent )
    	{
    	iContactsDatabase = CContactDatabase::OpenL(); //open database created in earlier step
    	for(TInt k = 1; k<=iContacts; k++)
    		{
    		TRAPD( err, ReadL(k));
    		CloseL( ETrue );
    		if( KErrNone == err )
    			{
    			iIterate->AddL( k );
    			}
    		}
		if( NULL  == iTemplate )
			{
			iTemplate = static_cast< CContactTemplate* >(
			iContactsDatabase->ReadContactL( iContactsDatabase->TemplateId(), *iViewAll ) );
			}
    	}
    else
    	{
		iContactsDatabase = CContactDatabase::ReplaceL();//create  clean/fresh database for all tests
		if( NULL  == iTemplate )
			{
			iTemplate = static_cast< CContactTemplate* >(
			iContactsDatabase->ReadContactL( iContactsDatabase->TemplateId(), *iViewAll ) );
			}
		AddEmptyContactsL(iContacts, EFalse);
    	}
	}
Пример #6
0
void CTransactionsStep::NestedTransactionTestL()
	{
	TContactItemId cid = iIterate->NextL();
	
	iContactsDatabase->DatabaseBeginLC(EFalse);
	iContactsDatabase->DatabaseBeginLC(ETrue);
	OpenL(cid);
	SetFieldL(1, GetFieldL(KStringFields, KField, 1) );
	CommitL(ETrue);
	iContactsDatabase->DatabaseCommitLP(ETrue);
	OpenL(cid);
	SetFieldL(2, GetFieldL(KStringFields, KField, 2) );
	CommitL(ETrue);	
	EndTransactionL(ETrue);
	
	iIterate->Reset();
	TInt err = KErrNone;
	TInt k = 0;
	TESTPRINT( iContactsDatabase->CountL() == iContacts );
	
	for( k = 0; k < iContacts; ++k)
		{
		TRAP(err, ReadL( iIterate->NextL() ) );
		TESTPRINTI( KErrNone == err, k );
		TESTPRINTI( CheckAllFieldsL(KNullDesC), k );
		CloseL( ETrue );
		}	
	}
Пример #7
0
TInt CAccessCountTests::GetAccessCountL(const TContactItemId aCid)
	{
	ReadL( aCid, *iViewAll );
	TInt ret = iContactItem->AccessCount();
	Close();
	return ret;
	}
void CTReadWrite::RunL()
    {
    MakeCurrentL();

    switch(iTestType)
        {
        case EStressRead:
            {
            ReadL();
            break;
            }
        case EStressReadWriteSingleImage:
        case EStressReadWriteMultiImage:
            {
            ReadWriteImageL();
            break;
            }
        case EStressVGImage:
            {
            VgImageL();
            break;
            }
        case EStressPixmapSurface:
            {
            PixmapSurfaceL();
            break;
            }
        default:
            //Error
            User::Leave(KErrArgument);
            break;
        }
    }
Пример #9
0
void CTransactionsStep::UpdateCommitTransactionTestL(const TBool aRevert)
	{
	CPerformanceFunctionalityBase::InitializeL();
	
	const TContactItemId cid = iIterate->NextL();
	const TContactItemId cid2 = iIterate->NextL();
	
	iContactsDatabase->DatabaseBeginLC(EFalse);
	OpenL( cid );
	SetAllFieldsL( GetNextFieldL(KStringFields, KField, ETrue) );
	CommitL(ETrue);
	EndTransactionL(aRevert);

	iContactsDatabase->DatabaseBeginLC(EFalse);
	ReadL( cid2 );
	SetAllFieldsL( GetNextFieldL(KStringFields, KField, EFalse) );
	iContactsDatabase->UpdateContactLC(cid2, iContactItem);
	CleanupStack::PopAndDestroy();
	CloseL( ETrue );
	EndTransactionL(aRevert);
	
	if(aRevert)
		{
		iIterate->Reset();
		TInt i = 0;
		for(; i < iContacts; ++i)
			{
			ReadL( iIterate->NextL() );
			TESTPRINTI( CheckAllFieldsL(KNullDesC), i );
			CloseL( ETrue );
			}
		}
	else
		{
		ReadL( cid );
		TESTPRINT( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, ETrue) ) );
		CloseL( ETrue );
		
		ReadL( cid2 );
		TESTPRINT( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, EFalse) ) );
		CloseL( ETrue );
		}
	}
Пример #10
0
void CTransactionsStep::DeleteCommitTransactionTestL(const TBool aRevert)
	{
	iContacts = 10;
	CPerformanceFunctionalityBase::InitializeL();
	iContactsDatabase->DatabaseBeginLC(EFalse);
	
	TInt k = 0;
	for(; k < iContacts; k++)
		{		
		iContactsDatabase->doDeleteContactL(iIterate->NextL(), ETrue, ETrue);
		}
	
	EndTransactionL(aRevert);
	
	if(aRevert)
		{
		TESTPRINT( iContactsDatabase->CountL() == iContacts );
		iIterate->Reset();
		TInt err = KErrNone;
		for(k = 0; k < iContacts; ++k)
			{
			TRAP(err, ReadL( iIterate->NextL() ) );
			TESTPRINTI( KErrNone == err, k );
			TESTPRINTI( CheckAllFieldsL( KNullDesC ), k );
			CloseL( ETrue );
			}
		}
	else
		{
		TESTPRINT( iContactsDatabase->CountL() == 0 );
		
		iIterate->Reset();
		TInt err = KErrNone;
		for(k = 0; k < iContacts; ++k)
			{
			TRAP(err, ReadL( iIterate->NextL() ) );
			TESTPRINTI( KErrNotFound == err, k );
			CloseL( ETrue );
			}
		iIterate->Clear();
		}
	}
Пример #11
0
void CTransactionsStep::EmptyCommitTransactionTestL(const TBool aRevert)
	{
	CPerformanceFunctionalityBase::InitializeL();
	
	iContactsDatabase->DatabaseBeginLC(EFalse);
	EndTransactionL(aRevert);
	iContactsDatabase->DatabaseBeginLC(EFalse);
	ReadL( iIterate->NextL() );
	EndTransactionL(aRevert);
	CloseL( ETrue );
	
	iIterate->Reset();
	TInt i = 0;
	for(; i < iContacts; ++i)
		{
		ReadL( iIterate->NextL() );
		TESTPRINTI( CheckAllFieldsL(KNullDesC), i );
		CloseL( ETrue );
		}
			
	}
Пример #12
0
/** Interprets the data at the current buffer position as a TInt16 type and returns 
the value as a TInt.

The current position within the resource buffer is updated.

In general, a TInt16 corresponds to a WORD type in a resource STRUCT declaration.

Note that in Symbian OS, a TInt is at least as big as a TInt16.

@internalComponent
@pre iCurrentPtr != NULL.
@pre The same as MovePtrL(const TUint8* aPtr).
@return The TInt16 value taken from the resource buffer.
@post The same as MovePtrL(const TUint8* aPtr).
@leave The same as MovePtrL(const TUint8* aPtr).
@see MovePtrL(const TUint8* aPtr) */
TInt TResourceReaderImpl::ReadInt16L()
    {
	assert(iCurrentPtr != NULL);
    if (((TUint32)iCurrentPtr)%2)
        {
        TInt16 ret;
        ReadL(&ret,sizeof(ret));
        return(ret);
        }
    const TUint8* currentPtr=iCurrentPtr;
    MovePtrL(currentPtr+sizeof(TInt16));
    return(*(TInt16*)currentPtr);
    }
Пример #13
0
/** Interprets the data at the current buffer position as a TUint32 type and returns 
the value as a TUint.

The current position within the resource buffer is updated.

In general, a TUint32 corresponds to a LONG type in a resource STRUCT declaration.

Note that in Symbian OS a TUint is the same size as a TUint32.

@internalComponent
@pre iCurrentPtr != NULL.
@pre The same as MovePtrL(const TUint8* aPtr).
@return The TUint32 value taken from the resource buffer.
@post The same as MovePtrL(const TUint8* aPtr).
@leave The same as MovePtrL(const TUint8* aPtr).
@see MovePtrL(const TUint8* aPtr) */
TUint32 TResourceReaderImpl::ReadUint32L()
    {
	assert(iCurrentPtr != NULL);
    if (((TUint32)iCurrentPtr)%4)
        {
        TUint32 ret;
        ReadL(&ret,sizeof(ret));
        return(ret);
        }
    const TUint8* currentPtr=iCurrentPtr;
    MovePtrL(currentPtr+sizeof(TUint32));
    return(*(TUint32*)currentPtr);
    }
Пример #14
0
/*
test that contactitems can be delete successfull irregardless of the contents of their agent value
*/
void CAccessCountTests::ReverseAgentDeletionTestL(const TInt aNumContacts)
	{
	TContactItemId PreviousContactId = -1;
	TContactItemId CurrentContactId = iIterate->NextL();
	TInt i = 0;
	TInt err = KErrNone;
	
	for(; i < aNumContacts; ++i)
		{
		PreviousContactId = CurrentContactId;
		CurrentContactId = iIterate->NextL();
		//open contact item
		OpenL(CurrentContactId, *iViewAll);
		//add agent field and set to previous contact id
		AddAgentFieldL(PreviousContactId);
		CommitL();
		//print agent values useful for debugging
		INFO_PRINTF2(KAgentValue, GetAgentFieldL(CurrentContactId) );
		}

	//attempt to delete contacts starting from last contact to frist contact
	TBool DeleteSuccess = EFalse;
	for(i = aNumContacts ; i > 0 ; --i)
		{
		//attempt to delete contact
		iContactsDatabase->DeleteContactL(CurrentContactId);
		//remove contact id from iterator
		iIterate->RemoveL(CurrentContactId);
		//attempt to read deleted contact
		TRAP( err, ReadL(CurrentContactId, *iViewAll) );
		Close();
		//fail test if contact is still present
		DeleteSuccess = INTCOMPARE( err, ==, KErrNotFound, i, 0 );
		CurrentContactId = iIterate->PreviousL();
		if( ! DeleteSuccess )
			{
			break;
			}
		}
	//if test fails
	if( ! DeleteSuccess )
		{
		//remove rest of contacts from iterator
		for(; i > 0 ; --i)
			{
			iIterate->RemoveL(CurrentContactId);
			CurrentContactId = iIterate->PreviousL();
			}
		}
	}
Пример #15
0
int32 mba_rdbufW (uint32 mb, int32 bc, uint16 *buf)
{
int32 i, j, ba, mbc, pbc;
uint32 pa, dat;

if (mb >= MBA_NUM)                                      /* valid MBA? */
    return 0;
ba = mba_va[mb];                                        /* get virt addr */
mbc = (MBABC_WR + 1) - mba_bc[mb];                      /* get Mbus bc */
if (bc > mbc)                                           /* use smaller */
    bc = mbc;
for (i = 0; i < bc; i = i + pbc) {                      /* loop by pages */
    if (!mba_map_addr (ba + i, &pa, mb))                /* page inv? */
        break;
    if (!ADDR_IS_MEM (pa)) {                            /* NXM? */
        mba_upd_sr (MBASR_RTMO, 0, mb);
        break;
        }
    pbc = VA_PAGSIZE - VA_GETOFF (pa);                  /* left in page */
    if (pbc > (bc - i))                                 /* limit to rem xfr */
        pbc = bc - i;
    if (DEBUG_PRI (mba_dev[mb], MBA_DEB_XFR))
        fprintf (sim_deb, ">>MBA%d: read, pa = %X, bc = %X\n", mb, pa, pbc);
    if ((pa | pbc) & 1) {                               /* aligned word? */
        for (j = 0; j < pbc; pa++, j++) {               /* no, bytes */
            if ((i + j) & 1) {                          /* odd byte? */
                *buf = (*buf & BMASK) | (ReadB (pa) << 8);
                buf++;
                }
            else *buf = (*buf & ~BMASK) | ReadB (pa);
            }
        }
    else if ((pa | pbc) & 3) {                          /* aligned LW? */
        for (j = 0; j < pbc; pa = pa + 2, j = j + 2) {  /* no, words */
            *buf++ = ReadW (pa);                        /* get word */
            }
        }
    else {                                              /* yes, do by LW */
        for (j = 0; j < pbc; pa = pa + 4, j = j + 4) {
            dat = ReadL (pa);                           /* get lw */
            *buf++ = dat & WMASK;                       /* low 16b */
            *buf++ = (dat >> 16) & WMASK;               /* high 16b */
            }
        }
    }
mba_bc[mb] = (mba_bc[mb] + i) & MBABC_WR;
mba_va[mb] = (mba_va[mb] + i) & MBAVA_WR;
return i;
}
Пример #16
0
void CConcurrentNotifierStep::UpdateTestL()
	{
	INFO_PRINTF1(KTest1);
	SetSharedTextL(KSharedNextTest,KSingleCharacter , ETrue);
	iWaiting = ETrue;
	TContactItemId cid = iIterate->NextL();
	ReadL( cid );
	iContactsDatabase->UpdateContactLC( cid, iContactItem);
	CleanupStack::PopAndDestroy();
	CloseL( ETrue );
	AddEventL(EContactDbObserverEventContactChanged);
	AddContactL( cid );
	SetMessageCountL();
	iStart.UniversalTime();
	}
Пример #17
0
void CConcurrentNotifierStep::OwnCardDeleteTestL()
	{
	INFO_PRINTF1(KTest9);
	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
	iWaiting = ETrue;
	iMyActive->Activate();
	TContactItemId cid = iContactsDatabase->OwnCardId();
	ReadL( cid );
	CloseL( EFalse );
	DeleteContactL( cid, EFalse );
	AddEventL( EContactDbObserverEventOwnCardDeleted );
	AddContactL( cid);
	SetMessageCountL();
	iStart.UniversalTime();
	}
Пример #18
0
void CConcurrentNotifierStep::MultipleChangeTransactionTestL()
	{
	if( iRevert )
		{
		INFO_PRINTF1(KTest112);
		}
	else
		{
		INFO_PRINTF1(KTest11);
		}
	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
	iWaiting = ETrue;
	TContactItemId cid = iIterate->NextL();

	iContactsDatabase->DatabaseBeginLC(EFalse);
	OpenL( cid );
	CommitL( ETrue );
	AddEventL(EContactDbObserverEventContactChanged);
	AddContactL( cid );

	cid = iIterate->NextL();
	ReadL( cid );
	iContactsDatabase->UpdateContactLC( cid, iContactItem);
	CleanupStack::PopAndDestroy();
	CloseL( ETrue );
	AddEventL(EContactDbObserverEventContactChanged);
	AddContactL( cid );

	CContactCard* contact = CContactCard::NewLC(iTemplate);
	cid = iContactsDatabase->doAddNewContactL(*contact, EFalse, ETrue);
	if(!iRevert)
		{
		iIterate->AddL( cid );
		}
	CleanupStack::PopAndDestroy(contact);
	AddEventL(EContactDbObserverEventContactAdded);
	AddContactL( cid );

	cid = iIterate->NextL();
	DeleteContactL( cid, ETrue );
	AddEventL(EContactDbObserverEventContactDeleted);
	AddContactL( cid );

	EndTransactionL();
	SetMessageCountL();

	iStart.UniversalTime();
	}
Пример #19
0
void CCntItemMsgHandler::SetCurrentDbL(const RMessage2& aMessage)
	{
	CheckForManagerL();
	// Slot 0 in aMessage contains the new current database.
	TFileName newCurrentDb;
	ReadL(aMessage, KSlot0, newCurrentDb);
	// Is this database already open for this session? We make it a
	// pre-condition that you cannot set the current database to be one
	// that isn't already open by this client.  This prevents errors
	// whereby a client updates the current database, but then fails to
	// open it.
	if	(newCurrentDb.CompareF(iManager->CntFile()) == 0)
		{
		Server().Controller().SetCurrentDbL(newCurrentDb, iSessionId);				
		}
	aMessage.Complete(KErrNone);
	}
Пример #20
0
TContactItemId CAccessCountTests::GetAgentFieldL(const TContactItemId aCid)
	{
	ReadL(aCid, *iViewAll);
	const TInt count = iFields->Count();
	TContactItemId ret = KErrNotFound;
	TInt i = 0;
	for(; i < count; ++i)
		{
		if( (*iFields)[i].StorageType() == KStorageTypeContactItemId )
			{
			ret = (*iFields)[i].AgentStorage()->Value();
			break;
			}
		}
	Close();
	return ret;
	}
Пример #21
0
/**
Check that contents of all fields in view contact equal corresponding fields in contact item
*/
TBool CContactViewTest::CheckViewContactL(const CViewContact &aVContact)
	{
	TBool OverallCheckResult = EFalse;

	//retrieve contact item id of view contact
	TContactItemId cid = aVContact.Id();

	//open contact item
	ReadL(cid, *iViewAll);
	TInt length = aVContact.FieldCount();
	TInt i = 0;
	for(; i < length; ++i)
		{
		OverallCheckResult = EFalse;
		//find first field in contact item that equals uid (of view contact field) stored in sort order
		TInt pos = iFields->Find((*iSortOrder)[i]);
		TDesC *ContactField = NULL;

		if(pos < 0)
			{
			ContactField = const_cast<TDesC *>(&KNullDesC);
			}
		else
			{
			//converts contents of field - matching the view contact uid - to a string
			ContactField = FieldStringLC( (*iFields)[pos] );
			}
		//check that conents of contact item field equal conents of corresponing view contact field
		OverallCheckResult = STRINGCOMPARE( aVContact.Field(i), ==, *ContactField, i, 0 );

		if(pos > -1)
			{
			CleanupStack::PopAndDestroy( ContactField );
			}

		//if view contact field doesnt equal contact item field, fail test
		if( !OverallCheckResult )
			{
			break;//test failed
			}
		}
	Close();

	return OverallCheckResult;
	}
void CCntFileManagerMsgHandler::DefinitionsOfExistingViewsL(const RMessage2& aMessage)
	{
	TFileName fileName;
	ReadL(aMessage,KSlot0,fileName);
	if (fileName.Length() == 0)
		{
		Server().Controller().DefaultDatabaseL(fileName);
		}
	
	RPointerArray<CContactDefaultViewDefinition> viewDefs;
	CleanupResetAndDestroyPushL(viewDefs);		
	CCntDbManager* manager = Server().Controller().DbManagerL(fileName);
	if (manager)
		{
		manager->ViewManagerL().GetDefinitionsOfExistingViewsL(viewDefs);
		}
	
	// Compute the size of the buffer that is needed.
	CBufFlat* buffer = CBufFlat::NewL(32);
	CleanupStack::PushL(buffer);
	RBufWriteStream writeStream(*buffer);
	CleanupClosePushL(writeStream);
	
	const TInt32 count = viewDefs.Count();
	writeStream << count;
	for (TInt i = 0; i < count; i++)
		{
		writeStream << *viewDefs[i];
		}	

	// Check that the client-side write buffer is large enough.
	TInt length = buffer->Size();
	if(aMessage.GetDesMaxLength(1) >= length)
		{
		aMessage.WriteL(1, buffer->Ptr(0)); 
		aMessage.Complete(KErrNone);
		}
	else
		{
		aMessage.Complete(length);
		}	
	CleanupStack::PopAndDestroy(3, &viewDefs); // writeStream, buffer, viewDefs
	}
Пример #23
0
/**
checks that all blobs in aCid match aBuf
*/
TBool CRandomBlobStep::CheckAllBlobsL(const TContactItemId aCid, const HBufC8 &aBuf)
	{
	TBool SingleTestResult 	= EFalse;
	TBool OverallTestResult = EFalse;
	ReadL( aCid );
	TInt length = iFields->Count();
	for( TInt i = 0; i < length; ++i )
		{
		if( (*iFields)[i].StorageType() == KStorageTypeStore )
			{
			TDesC8 *thething = (*iFields)[i].StoreStorage()->Thing();
			TESTPRINTI( SingleTestResult = ( thething != NULL ), i );
			OverallTestResult = SingleTestResult;
			TESTPRINTI( SingleTestResult = ( (*iFields)[i].StoreStorage()->Thing()->Compare(aBuf) == 0 ), i );
			OverallTestResult = OverallTestResult && SingleTestResult;
			}
		}
	CloseL( EFalse );
	return OverallTestResult;
	}
Пример #24
0
void CTransactionsStep::MultipleCommitTestL(const TBool aTrans)
	{
	iContacts = 40;
	CPerformanceFunctionalityBase::InitializeL();
	if(aTrans)
		{
		iContactsDatabase->DatabaseBeginLC(EFalse);
		}
	MultipleCommitL(aTrans);
	if(aTrans)
		{
		EndTransactionL(EFalse);
		}
	TInt k = 0;
	iIterate->Reset();
	for(; k < iContacts; ++k)
		{
		ReadL( iIterate->NextL() );
		TESTPRINTI( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) ), k );
		CloseL( ETrue );
		}
	}
/**opens and read contct aCid using the default viewdefs. 
then it reads and minimally reads aCid using aView, it stores the number relevant fields after
each read/open, then checks that the values match the expected resluts as constrained by aZeroN/H,
aZeroN == all normal fields should be excluded, aZeroH == all hidden fields should be excluded*/
TBool CViewDefAllFieldsTest::FieldCountCompL(	const TContactItemId aCid,
										const CContactItemViewDef &aView, 
										const TBool aDefault, 
										const TBool aZeroN, 
										const TBool aZeroH)
	{
	TBool SingleCheck = EFalse;
	TBool OverallResult = ETrue;
	
	TInt counti = 0;
	TInt countr = 0;
	TInt countrv = 0;
	TInt countrAll = 0;
	TInt countrAllv = 0;
	TInt countrm = 0;
	
	TInt hcounti = 0;
	TInt hcountr = 0;
	TInt hcountrv = 0;
	TInt hcountrm = 0;
	
	OpenL(aCid,aView, ETrue);
	SetContactFieldsL(*iContactItem);
	counti = iFields->Count();
	hcounti = CountHiddenFields(*iFields);
	CommitL();
	
	ReadL(aCid,*iViewAll,EFalse);
	countrv = CountEmpty(*iFields);
	countrAllv = iFields->Count();
	hcountrv = CountHiddenFields(*iFields);
	Close();
	
	ReadL(aCid,aView,aDefault);
	countr = CountEmpty(*iFields);
	countrAll = iFields->Count();
	hcountr = CountHiddenFields(*iFields);
	Close();
	
	ReadMinimalL(aCid, aView, *iDefView, aDefault);
	countrm = iFields->Count();
	hcountrm = CountHiddenFields(*iFields);
	Close();
		
	SingleCheck = INTCOMPARE( countrAllv, ==, counti, 0, 0 );
	OverallResult = OverallResult && SingleCheck;
	
	SingleCheck = INTCOMPARE(hcounti , ==,  hcountrv, 0, 0 );
	OverallResult = OverallResult && SingleCheck;
	
	SingleCheck = INTCOMPARE(countrv , ==,  0, 0, 0 );
	OverallResult = OverallResult && SingleCheck;
	
	SingleCheck = INTCOMPARE( ( countrAll - countr) , ==,  countrm , 0, 0 ); 
	OverallResult = OverallResult && SingleCheck;
	
	
	if(aZeroN)
		{
		SingleCheck = INTCOMPARE( ( countr - hcountr ) , ==,  ( counti - hcounti ) , 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		SingleCheck = INTCOMPARE( ( countrm - hcountrm ) , ==,  0 , 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		}
	else
		{
void EPOC_InitOSKeymap(_THIS)
{
	int i;

	/* Initialize the key translation table */
	for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
		keymap[i] = SDLK_UNKNOWN;


	/* Numbers */
	for ( i = 0; i<32; ++i ){
		keymap[' ' + i] = (SDLKey)(SDLK_SPACE+i);
	}
	/* e.g. Alphabet keys */
	for ( i = 0; i<32; ++i ){
		keymap['A' + i] = (SDLKey)(SDLK_a+i);
	}

	keymap[EStdKeyBackspace]    = SDLK_BACKSPACE;
	keymap[EStdKeyTab]          = SDLK_TAB;
	keymap[EStdKeyEnter]        = SDLK_RETURN;
	keymap[EStdKeyEscape]       = SDLK_ESCAPE;
   	keymap[EStdKeySpace]        = SDLK_SPACE;
   	keymap[EStdKeyPause]        = SDLK_PAUSE;
   	keymap[EStdKeyHome]         = SDLK_HOME;
   	keymap[EStdKeyEnd]          = SDLK_END;
   	keymap[EStdKeyPageUp]       = SDLK_PAGEUP;
   	keymap[EStdKeyPageDown]     = SDLK_PAGEDOWN;
	keymap[EStdKeyDelete]       = SDLK_DELETE;
	keymap[EStdKeyUpArrow]      = SDLK_UP;
	keymap[EStdKeyDownArrow]    = SDLK_DOWN;
	keymap[EStdKeyLeftArrow]    = SDLK_LEFT;
	keymap[EStdKeyRightArrow]   = SDLK_RIGHT;
	keymap[EStdKeyCapsLock]     = SDLK_CAPSLOCK;
	keymap[EStdKeyLeftShift]    = SDLK_LSHIFT;
	keymap[EStdKeyRightShift]   = SDLK_RSHIFT;
	keymap[EStdKeyLeftAlt]      = SDLK_LALT;
	keymap[EStdKeyRightAlt]     = SDLK_RALT;
	keymap[EStdKeyLeftCtrl]     = SDLK_LCTRL;
	keymap[EStdKeyRightCtrl]    = SDLK_RCTRL;
	keymap[EStdKeyLeftFunc]     = SDLK_LMETA;
	keymap[EStdKeyRightFunc]    = SDLK_RMETA;
	keymap[EStdKeyInsert]       = SDLK_INSERT;
	keymap[EStdKeyComma]        = SDLK_COMMA;
	keymap[EStdKeyFullStop]     = SDLK_PERIOD;
	keymap[EStdKeyForwardSlash] = SDLK_SLASH;
	keymap[EStdKeyBackSlash]    = SDLK_BACKSLASH;
	keymap[EStdKeySemiColon]    = SDLK_SEMICOLON;
	keymap[EStdKeySingleQuote]  = SDLK_QUOTE;
	keymap[EStdKeyHash]         = SDLK_HASH;
	keymap[EStdKeySquareBracketLeft]    = SDLK_LEFTBRACKET;
	keymap[EStdKeySquareBracketRight]   = SDLK_RIGHTBRACKET;
	keymap[EStdKeyMinus]        = SDLK_MINUS;
	keymap[EStdKeyEquals]       = SDLK_EQUALS;

   	keymap[EStdKeyF1]          = SDLK_F1;  /* chr + q */
   	keymap[EStdKeyF2]          = SDLK_F2;  /* chr + w */
   	keymap[EStdKeyF3]          = SDLK_F3;  /* chr + e */
   	keymap[EStdKeyF4]          = SDLK_F4;  /* chr + r */
   	keymap[EStdKeyF5]          = SDLK_F5;  /* chr + t */
   	keymap[EStdKeyF6]          = SDLK_F6;  /* chr + y */
   	keymap[EStdKeyF7]          = SDLK_F7;  /* chr + i */
   	keymap[EStdKeyF8]          = SDLK_F8;  /* chr + o */

   	keymap[EStdKeyF9]          = SDLK_F9;  /* chr + a */
   	keymap[EStdKeyF10]         = SDLK_F10; /* chr + s */
   	keymap[EStdKeyF11]         = SDLK_F11; /* chr + d */
   	keymap[EStdKeyF12]         = SDLK_F12; /* chr + f */

	#ifndef SYMBIAN_CRYSTAL 
	//!!7650 additions
    #ifdef __WINS__
   	keymap[EStdKeyXXX]         = SDLK_RETURN;	/* "fire" key */
	#else
   	keymap[EStdKeyDevice3]     = SDLK_RETURN;	/* "fire" key */
	#endif
   	keymap[EStdKeyNkpAsterisk] = SDLK_ASTERISK; 
   	keymap[EStdKeyYes]         = SDLK_HOME;		/* "call" key */
   	keymap[EStdKeyNo]		   = SDLK_END;		/* "end call" key */
   	keymap[EStdKeyDevice0]     = SDLK_SPACE;	/* right menu key */
   	keymap[EStdKeyDevice1]     = SDLK_ESCAPE;	/* left menu key */
   	keymap[EStdKeyDevice2]     = SDLK_POWER;	/* power key */
	#endif

 #ifdef SYMBIAN_CRYSTAL 
    keymap[EStdKeyMenu]        = SDLK_ESCAPE;   // menu key
    keymap[EStdKeyDevice6]     = SDLK_LEFT;     // Rocker (joystick) left
    keymap[EStdKeyDevice7]     = SDLK_RIGHT;    // Rocker (joystick) right
    keymap[EStdKeyDevice8]     = SDLK_UP;       // Rocker (joystick) up
    keymap[EStdKeyDevice9]     = SDLK_DOWN;     // Rocker (joystick) down
    keymap[EStdKeyLeftFunc]     = SDLK_LALT;    //chr?
	keymap[EStdKeyRightFunc]    = SDLK_RALT;
    keymap[EStdKeyDeviceA]      = SDLK_RETURN;	/* "fire" key */
#endif

    ///////////////////////////////////////////////////////////

    RFs fs;
    if(KErrNone == fs.Connect())
        {
        RArray<TInt> array;
        TRAPD(err, ReadL(fs, array));
        if(err == KErrNone && array.Count() > 0)
            {
            
            SDLKey temp[MAX_SCANCODE];
            Mem::Copy(temp, keymap, MAX_SCANCODE * sizeof(SDLKey));

            for(TInt k = 0; k < array.Count(); k+= 2)
                {
                const TInt oldval = array[k]; 
                const TInt newval = array[k + 1]; 
                if(oldval >=  0 && oldval < MAX_SCANCODE && newval >=  0 && newval < MAX_SCANCODE)
                    {
                    keymap[oldval] = temp[newval];
                    }
                }
            }
        array.Close();
        }

    fs.Close();
    ///////////////////////////////////////////////////////////

    /* !!TODO
	EStdKeyNumLock=0x1b,
	EStdKeyScrollLock=0x1c,

	EStdKeyNkpForwardSlash=0x84,
	EStdKeyNkpAsterisk=0x85,
	EStdKeyNkpMinus=0x86,
	EStdKeyNkpPlus=0x87,
	EStdKeyNkpEnter=0x88,
	EStdKeyNkp1=0x89,
	EStdKeyNkp2=0x8a,
	EStdKeyNkp3=0x8b,
	EStdKeyNkp4=0x8c,
	EStdKeyNkp5=0x8d,
	EStdKeyNkp6=0x8e,
	EStdKeyNkp7=0x8f,
	EStdKeyNkp8=0x90,
	EStdKeyNkp9=0x91,
	EStdKeyNkp0=0x92,
	EStdKeyNkpFullStop=0x93,
    EStdKeyMenu=0x94,
    EStdKeyBacklightOn=0x95,
    EStdKeyBacklightOff=0x96,
    EStdKeyBacklightToggle=0x97,
    EStdKeyIncContrast=0x98,
    EStdKeyDecContrast=0x99,
    EStdKeySliderDown=0x9a,
    EStdKeySliderUp=0x9b,
    EStdKeyDictaphonePlay=0x9c,
    EStdKeyDictaphoneStop=0x9d,
    EStdKeyDictaphoneRecord=0x9e,
    EStdKeyHelp=0x9f,
    EStdKeyOff=0xa0,
    EStdKeyDial=0xa1,
    EStdKeyIncVolume=0xa2,
    EStdKeyDecVolume=0xa3,
    EStdKeyDevice0=0xa4,
    EStdKeyDevice1=0xa5,
    EStdKeyDevice2=0xa6,
    EStdKeyDevice3=0xa7,
    EStdKeyDevice4=0xa8,
    EStdKeyDevice5=0xa9,
    EStdKeyDevice6=0xaa,
    EStdKeyDevice7=0xab,
    EStdKeyDevice8=0xac,
    EStdKeyDevice9=0xad,
    EStdKeyDeviceA=0xae,
    EStdKeyDeviceB=0xaf,
    EStdKeyDeviceC=0xb0,
    EStdKeyDeviceD=0xb1,
    EStdKeyDeviceE=0xb2,
    EStdKeyDeviceF=0xb3,
    EStdKeyApplication0=0xb4,
    EStdKeyApplication1=0xb5,
    EStdKeyApplication2=0xb6,
    EStdKeyApplication3=0xb7,
    EStdKeyApplication4=0xb8,
    EStdKeyApplication5=0xb9,
    EStdKeyApplication6=0xba,
    EStdKeyApplication7=0xbb,
    EStdKeyApplication8=0xbc,
    EStdKeyApplication9=0xbd,
    EStdKeyApplicationA=0xbe,
    EStdKeyApplicationB=0xbf,
    EStdKeyApplicationC=0xc0,
    EStdKeyApplicationD=0xc1,
    EStdKeyApplicationE=0xc2,
    EStdKeyApplicationF=0xc3,
    EStdKeyYes=0xc4,
    EStdKeyNo=0xc5,
    EStdKeyIncBrightness=0xc6,
    EStdKeyDecBrightness=0xc7, 
    EStdKeyCaseOpen=0xc8,
    EStdKeyCaseClose=0xc9
    */

}
Пример #27
0
void CTransactionsStep::ManyUpdateCommitTransactionTestL( const TBool aRevert )
	{
	iContacts = 1000;
	CPerformanceFunctionalityBase::InitializeL();
	RCntList backuplist;
	backuplist.CopyL( *iIterate );
	iContactsDatabase->DatabaseBeginLC(EFalse);
	
	TInt added = 0;
	TInt deleted = 0;
	TInt updated = 0;
	TInt k = 0;
	for(; k < iContacts; k++)
		{
		switch( k % KNumCUDOperations )
			{
			case ( EOpen ):
				{
				OpenL( iIterate->NextL() );
				//if setting first contact read first field from stringfields section
				//otherwise read next field in list of fields stored in ini file secion
				SetAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) );
				CommitL(ETrue);
				++updated;
				}
			break;
			case ( EUpdate ):
				{
				TContactItemId cid = iIterate->NextL();
				ReadL( cid );
				//if setting first contact read first field from stringfields section
				//otherwise read next field in list of fields stored in ini file secion
				SetAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) );
				iContactsDatabase->UpdateContactLC(cid, iContactItem);
				CleanupStack::PopAndDestroy();
				CloseL( ETrue );
				++updated;
				}
			break;
			case ( EAddDelete ):
				{
				DeleteContactL( iIterate->NextL(), ETrue );
				//iterator position is shifted back, so that next nextL call is correct
				iIterate->PreviousL();
				++deleted;
				//Empty contact is appended to the database, 
				//Contact id is stored at the end of iterator list not at current iterator position
				AddEmptyContactsL( 1, ETrue );
				++added;
				}
			break;
			default:
				{
				_LIT(KInvalidTest, "Invalid Case");
				User::Panic(KInvalidTest, 555);
				}
			break;
			}
		}
	
	EndTransactionL(aRevert);
	TESTPRINT( iContactsDatabase->CountL() == iContacts );
	
	CContactItemFieldSet& templateFields = iTemplate->CardFields();
	TInt fieldsCount = templateFields.Count() - 1;
	
	if(aRevert)
		{
		//if transaction is reverted / rolledback, all contacts should be
		//unchanged, i.e. they should all contain empty fields only
		backuplist.Reset();
		TInt err = KErrNone;
		for(k = 0; k < iContacts; ++k)
			{
			TRAP(err, ReadL( backuplist.NextL() ) );
			TESTPRINTI( KErrNone == err, k );
			TESTPRINTI( CheckAllFieldsL( KNullDesC ), k );
			CloseL( ETrue );
			}
		}
	else
		{
		iIterate->Reset();
		//all updated contact should contain the appropriated updated field value
		for(k = 0; k < updated; ++k)
			{
			ReadL( iIterate->NextL() );
			TESTPRINTI(iFields->Count() == fieldsCount, k);
			//if reading first contact read first field from stringfields section
			//otherwise read next field in list of fields stored in ini file secion
			TESTPRINTI( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) ), k );
			CloseL( ETrue );
			}
			
		//all newly	added contacts, should contain empty fields only.
		for(k = 0; k < added; ++k)
			{
			ReadL( iIterate->NextL() );
			TESTPRINTI( iFields->Count() == fieldsCount, k);
			TESTPRINTI( CheckAllFieldsL( KNullDesC ), k);
			CloseL( ETrue );
			}
		}
	}
TBool CViewDefAnyFieldsTest::FieldCountCompL(	const TContactItemId &aCid,
												CContactItemViewDef &aView, 
												const TBool aExcludeN, 
												const TBool aExcludeH,
												const TBool aZeroH,
												const TBool aMultiple)
	{
	TBool SingleTestResult = EFalse;
	TBool OverallTestResult = EFalse;
	
	TInt countM = 0;
	TInt countR = 0;
	TInt fieldsIV = 0;
	TInt emptyfsM = 0;
	TInt emptyfsR = 0;
	TInt hcountM = 0;
	TInt hcountR = 0;
	TInt hfieldsIV = 0;
	
	TInt length = 0;
	
	length = iExistingUidsArray->Count();
	
	for(TInt i = 0, j = 0; i < length;)
		{
		OverallTestResult = EFalse;
		if( (*iExistingUidsArray)[i] == 0 )
			{
			++i;
			continue;
			}
		aView.AddL(TUid::Uid((*iExistingUidsArray)[i]));
		
		ReadL(aCid,*iViewAll,EFalse);
		FieldsInView(aView, fieldsIV, hfieldsIV);
		countR = iFields->Count();
		hcountR = CountHiddenFields(*iFields);
		emptyfsR = CountEmpty(*iFields);
		Close();
		
		ReadMinimalL(aCid, aView, *iDefView,EFalse);
		countM = iFields->Count();
		hcountM = CountHiddenFields(*iFields);
		emptyfsM = CountEmpty(*iFields);
		Close();
		
		SingleTestResult = INTCOMPARE( 0 , ==,  emptyfsM, i, 0 );
		OverallTestResult = SingleTestResult;
		
		SingleTestResult = INTCOMPARE( 0 , ==,  emptyfsR, i, 0 );
		OverallTestResult = OverallTestResult && SingleTestResult;
		
		SingleTestResult = INTCOMPARE( hcountR , >,  0 , i, 0 );
		OverallTestResult = OverallTestResult && SingleTestResult;
		
		
		if(aExcludeN)
			{
			SingleTestResult = INTCOMPARE( ( (countR - fieldsIV) - hcountR ) , ==,  (countM - hcountM) , i, 0 );
			OverallTestResult = OverallTestResult && SingleTestResult;
			}
		else
			{
			SingleTestResult = INTCOMPARE( fieldsIV  , ==,  (countM - hcountM) , i, 0 );
			OverallTestResult = OverallTestResult && SingleTestResult;
			}
		if(aExcludeH)
			{
			if( aZeroH)
				{
				SingleTestResult = INTCOMPARE( 0 , ==,  hcountM, i, 0 );
				OverallTestResult = OverallTestResult && SingleTestResult;	
				}
			else
				{
				SingleTestResult = INTCOMPARE( ( hcountR - hfieldsIV) , ==,  hcountM , i, 0 );
				OverallTestResult = OverallTestResult && SingleTestResult;
				}
			}