phonebookengines/contactsmodel/tsrc/Integration/PerfFuncSuite/src/ConcurrentNotifierStep.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This step performs operations that generate notifications
       
    15 // It sends messages to the concurrently running listner step / thread
       
    16 // informing it what notifications it should be listening for, when it
       
    17 // should be listening when it should stop listening, also it waits for
       
    18 // messages from all the listeners infroming it that all mesasges have
       
    19 // been received.
       
    20 // Sending Messages:
       
    21 // Set shared string to contain the number of notifications to expect. (10)
       
    22 // Append shared string with valued of event in notification. KSharedEvents (1 2 3 4)
       
    23 // Append shared string with value of contact id in notification. KSharedContact. (1 2 3 4)
       
    24 // KSharedContact and KSharedEvents are synchronized so that at index X lies the contact and
       
    25 // event value for notification X+1.
       
    26 // Append shared string (KSharedNextTest) with single character. Signifies new
       
    27 // test case has started. (AAAA)
       
    28 // Receiving messages:
       
    29 // Read shared string length signifying the number of listner threads
       
    30 // that have finished from this test case. If this number equals number of
       
    31 // listener threads, stop this test case and start next test case. (AAAAAA)
       
    32 // 
       
    33 //
       
    34 
       
    35 /**
       
    36  @file
       
    37  @publishedAll
       
    38  @released
       
    39 */
       
    40 
       
    41 #include "ConcurrentNotifierStep.h"
       
    42 #include "PerformanceFunctionalityDefs.h"
       
    43 #include "CCntEventQueue.h"
       
    44 
       
    45 _LIT(KRun1,"Update");
       
    46 _LIT(KRun2,"Commit");
       
    47 _LIT(KRun3,"Add");
       
    48 _LIT(KRun4,"Delete");
       
    49 _LIT(KRun5,"CloseOpenTables");
       
    50 _LIT(KRun7,"OwncardAddDelete");
       
    51 _LIT(KRun9,"Speeddial");
       
    52 _LIT(KRun10,"TransactionCommit");
       
    53 _LIT(KRun11,"TransactionRevert");
       
    54 _LIT(KRun12,"CUDTransactionCommit");
       
    55 _LIT(KRun13,"CUDTransactionRevert");
       
    56 _LIT(KRun14,"EmptyTransactionCommit");
       
    57 _LIT(KRun15,"EmptyTransactionRevert");
       
    58 _LIT(KRun16,"UnknownChange");
       
    59 
       
    60 _LIT(KTest1, "Update notification test");
       
    61 _LIT(KTest2, "Commit notification test");
       
    62 _LIT(KTest3, "Add notification test");
       
    63 _LIT(KTest4, "Delete notification test");
       
    64 _LIT(KTest5, "Open tables notification test");
       
    65 _LIT(KTest6, "Close tables notification test");
       
    66 _LIT(KTest7, "Own Card notification test");
       
    67 _LIT(KTest14, "Change Own Card notification test");
       
    68 _LIT(KTest9, "Own Card Deletion notification test");
       
    69 _LIT(KTest8, "Speed dial notification test");
       
    70 _LIT(KTest15, "Delete Speed dial Card notification test");
       
    71 _LIT(KTest16, "Remove Speed dial Card notification test");
       
    72 _LIT(KTest10, "Single commit transaction notification test");
       
    73 _LIT(KTest102, "Single commit revert transaction notification test");
       
    74 _LIT(KTest11, "Multiple Cud transaction notification test");
       
    75 _LIT(KTest112, "Multiple Cud revert transaction notification test");
       
    76 _LIT(KTest12, "Empty transaction notification test");
       
    77 _LIT(KTest122, "Empty revert transaction notification test");
       
    78 _LIT(KTest13, "unknown changes notification test");
       
    79 
       
    80 _LIT(KClients,"Clients");
       
    81 _LIT(KNotifier,"Notifier");
       
    82 _LIT(KSperator," ");
       
    83 _LIT(KSingleCharacter,"A");
       
    84 
       
    85 const TInt KTimeout = 5000000;//5 seconds timeout
       
    86 
       
    87 //start initlizer step
       
    88 
       
    89 CConcurrentInitializerStep::CConcurrentInitializerStep() : CPerformanceFunctionalityBase(KConcurrentContacts)
       
    90 	{
       
    91 	iUnclean = ETrue;
       
    92 	SetTestStepName(KConcurrentInitilizerStep);
       
    93 	}
       
    94 
       
    95 TVerdict CConcurrentInitializerStep::doTestStepL()
       
    96 	{
       
    97 	__UHEAP_MARK;
       
    98 	_LIT(KStartTest,"CConcurrentInitializerStep::doTestStepL()");
       
    99 	INFO_PRINTF1(KStartTest);  //Block start
       
   100 
       
   101 	InitializeL();
       
   102 	iIterate->Reset();
       
   103 	TInt j = 0;
       
   104 	for(; j < iContacts; ++j)
       
   105 		{
       
   106 		OpenL(iIterate->NextL());
       
   107 		TInt fieldId=iFields->Find(KUidContactFieldPhoneNumber);
       
   108 		SetFieldL(fieldId,GetFieldL(KStringFields, KField, 1));// if this is not set, speeddial cant be set
       
   109 		CommitL(EFalse);
       
   110 		}
       
   111 	iIterate->Reset();
       
   112 	Cleanup();
       
   113 	__UHEAP_MARKEND;
       
   114 
       
   115 	return TestStepResult();
       
   116 	}
       
   117 //end initlizer step
       
   118 
       
   119 
       
   120 CConcurrentNotifierStep::CConcurrentNotifierStep() :
       
   121 					CPerformanceFunctionalityBase(KConcurrentContacts)
       
   122 	{
       
   123 	iConcurrent = ETrue;
       
   124 	SetTestStepName(KConcurrentNotifierStep);
       
   125 	}
       
   126 
       
   127 void CConcurrentNotifierStep::CConcurrentNotifierActive::RunL()
       
   128 	{
       
   129 	const TInt many = iStep->iTests->Count();
       
   130 	if( iStep->iNextTest >= many )
       
   131 		{
       
   132 		if( many > 1 )
       
   133 			{
       
   134 			iStep->SetSharedTextL(KSharedContact,KNullDesC, EFalse);
       
   135 			iStep->SetSharedTextL(KSharedEvents,KNullDesC, EFalse);
       
   136 			iStep->SetSharedTextL(KSharedNextTest, KNullDesC, EFalse);
       
   137 			}
       
   138 		CActiveScheduler::Stop();
       
   139 		iStep->iNextTest = 0;
       
   140 		}
       
   141 	else
       
   142 		{
       
   143 		if( iStep->iWaiting )
       
   144 			{
       
   145 			iStep->ProcessWaitL();
       
   146 			}
       
   147 		else
       
   148 			{
       
   149 			RArray< void (CConcurrentNotifierStep::*)() > &Tests = *( iStep->iTests );
       
   150 			//select test to run
       
   151 			void (CConcurrentNotifierStep::*TestFunction)() = Tests[ iStep->iNextTest ];
       
   152 			//execute test
       
   153 			( iStep->*TestFunction )();
       
   154 			}
       
   155 		Activate();
       
   156 		}
       
   157 	}
       
   158 
       
   159 CConcurrentNotifierStep::CConcurrentNotifierActive::CConcurrentNotifierActive(CConcurrentNotifierStep *aStep)
       
   160 								:	CActive( EPriorityStandard ),
       
   161 									iStep ( aStep )
       
   162 	{
       
   163 	}
       
   164 
       
   165 void CConcurrentNotifierStep::CConcurrentNotifierActive::DoCancel()
       
   166 	{
       
   167 	//nothing to cleanup
       
   168 	}
       
   169 
       
   170 TInt CConcurrentNotifierStep::CConcurrentNotifierActive::RunError(TInt aError)
       
   171 	{
       
   172 	_LIT(KActiveError,"CConcurrentNotifierStep:: Error in doTest runL: %d");
       
   173 	iStep->ERR_PRINTF2( KActiveError , aError );
       
   174 	return aError;
       
   175 	}
       
   176 
       
   177 void CConcurrentNotifierStep::CConcurrentNotifierActive::Activate()
       
   178 	{
       
   179 	if(!IsActive())
       
   180 		{
       
   181 		TRequestStatus *pS=&iStatus;
       
   182 		User::RequestComplete(pS,KErrNone);
       
   183 		SetActive();
       
   184 		}
       
   185 	}
       
   186 
       
   187 CConcurrentNotifierStep::~CConcurrentNotifierStep()
       
   188 	{
       
   189 	if( iTests )
       
   190 		{
       
   191 		iTests->Close();
       
   192 		CLEAR(iTests);
       
   193 		}
       
   194 	CLEAR(iMyActive);
       
   195 	}
       
   196 
       
   197 void CConcurrentNotifierStep::PreTestL()
       
   198 	{
       
   199 	_LIT(KPretestPrint,"I am in CConcurrentNotifierStep PreTestL()");
       
   200 	INFO_PRINTF1(KPretestPrint);
       
   201 	GetIntFromConfig( KNotifier, KClients, iManyListeners );
       
   202 	iMyActive = new (ELeave) CConcurrentNotifierStep::CConcurrentNotifierActive( this );
       
   203 	iTests = new(ELeave) RArray< void (CConcurrentNotifierStep::*)() >();
       
   204 
       
   205 	ClearSharedL();
       
   206 	SetSharedTextL(KSharedNextTest, KNullDesC, EFalse);
       
   207 
       
   208 	const TDesC &run = ConfigSection();
       
   209 
       
   210 	if( run == KRun1 )
       
   211 		{
       
   212 		iTests->AppendL( &CConcurrentNotifierStep::UpdateTestL );
       
   213 		}
       
   214 	else if( run == KRun2 )
       
   215 		{
       
   216 		iTests->AppendL( &CConcurrentNotifierStep::CommitTestL );
       
   217 		}
       
   218 	else if( run == KRun3 )
       
   219 		{
       
   220 		iTests->AppendL( &CConcurrentNotifierStep::AddTestL );
       
   221 		}
       
   222 	else if( run == KRun4 )
       
   223 		{
       
   224 		iTests->AppendL( &CConcurrentNotifierStep::DeleteTestL );
       
   225 		}
       
   226 	else if( run == KRun5 )
       
   227 		{
       
   228 		iTests->AppendL( &CConcurrentNotifierStep::CloseTablesTestL );
       
   229 		iTests->AppendL( &CConcurrentNotifierStep::OpenTablesTestL );
       
   230 		}
       
   231 	else if( run == KRun7 )
       
   232 		{
       
   233 		iTests->AppendL( &CConcurrentNotifierStep::OwnCardTestL );
       
   234 		iTests->AppendL( &CConcurrentNotifierStep::ChangeOwnCardTestL );
       
   235 		iTests->AppendL( &CConcurrentNotifierStep::OwnCardDeleteTestL );
       
   236 		}
       
   237 	else if( run == KRun9 )
       
   238 		{
       
   239 		iTests->AppendL( &CConcurrentNotifierStep::SpeedDialTestL );
       
   240 		iTests->AppendL( &CConcurrentNotifierStep::RemoveSpeedDialTestL );
       
   241 		iTests->AppendL( &CConcurrentNotifierStep::DeleteSpeedDialTestL );
       
   242 		}
       
   243 	else if( run == KRun10 )
       
   244 		{
       
   245 		iTests->AppendL( &CConcurrentNotifierStep::SingleCommitTransactionTestL );
       
   246 		}
       
   247 	else if( run == KRun11 )
       
   248 		{
       
   249 		iRevert = ETrue;
       
   250 		iTests->AppendL( &CConcurrentNotifierStep::SingleCommitTransactionTestL );
       
   251 		}
       
   252 	else if( run == KRun12 )
       
   253 		{
       
   254 		iTests->AppendL( &CConcurrentNotifierStep::MultipleChangeTransactionTestL );
       
   255 		}
       
   256 	else if( run == KRun13 )
       
   257 		{
       
   258 		RProcess().SetPriority(EPriorityBackground);
       
   259 		iRevert = ETrue;
       
   260 		iTests->AppendL( &CConcurrentNotifierStep::MultipleChangeTransactionTestL );
       
   261 		RProcess().SetPriority(EPriorityForeground);
       
   262 		}
       
   263 	else if( run == KRun14 )
       
   264 		{
       
   265 		iTests->AppendL( &CConcurrentNotifierStep::EmptyTransactionTestL );
       
   266 		}
       
   267 	else if( run == KRun15 )
       
   268 		{
       
   269 		RProcess().SetPriority(EPriorityBackground);
       
   270 		iRevert = ETrue;
       
   271 		iTests->AppendL( &CConcurrentNotifierStep::EmptyTransactionTestL );
       
   272 		RProcess().SetPriority(EPriorityForeground);
       
   273 		}
       
   274 	else if( run == KRun16 )
       
   275 		{
       
   276 		iTests->AppendL( &CConcurrentNotifierStep::UnkownChangeTestL );
       
   277 		}
       
   278 	else
       
   279 		{
       
   280 		MissingTestPanic();
       
   281 		}
       
   282 
       
   283 	}
       
   284 
       
   285 TVerdict CConcurrentNotifierStep::doTestStepL()
       
   286 	{
       
   287 	__UHEAP_MARK;
       
   288 	InitializeL();
       
   289 	_LIT(KDoStepPrint,"CTransactionsStep::doTestStepL()");
       
   290 	INFO_PRINTF1(KDoStepPrint);  //Block start
       
   291 	iIterate->Reset();
       
   292 
       
   293 	SetSharedTextL(KSharedEvents,KNullDesC, EFalse);
       
   294 	CActiveScheduler::Add(iMyActive);
       
   295 	iMyActive->Activate();
       
   296 	CActiveScheduler::Start();
       
   297 
       
   298 	Cleanup();
       
   299 	__UHEAP_MARKEND;
       
   300 
       
   301 	return TestStepResult();
       
   302 	}
       
   303 
       
   304 TVerdict CConcurrentNotifierStep::doTestStepPostambleL()
       
   305 	{
       
   306 	_LIT(KPostamblePrint,"I am in CConcurrentNotifierStep doTestStepPostambleL()");
       
   307 	INFO_PRINTF1(KPostamblePrint);
       
   308 	ClearSharedL();
       
   309 	SetSharedTextL(KSharedNextTest, KNullDesC, EFalse);
       
   310 	return CPerformanceFunctionalityBase::doTestStepPostambleL();
       
   311 	}
       
   312 
       
   313 
       
   314 /**
       
   315 tell listener to expect aEvent type notification
       
   316 increase message count
       
   317 */
       
   318 void CConcurrentNotifierStep::AddEventL(const TInt aEvent)
       
   319 	{
       
   320 	if( !iRevert )
       
   321 		{
       
   322 		ShareIntL(KSharedEvents, aEvent, ETrue, KSperator);
       
   323 		++iMessageCount;//either here or in addcontact
       
   324 		}
       
   325 	}
       
   326 
       
   327 /**
       
   328 tell listener to expect notification for aCid contact
       
   329 don't
       
   330 */
       
   331 void CConcurrentNotifierStep::AddContactL(const TInt aCid)
       
   332 	{
       
   333 	if( !iRevert )
       
   334 		{
       
   335 		ShareIntL(KSharedContact, aCid, ETrue, KSperator);
       
   336 		}
       
   337 	}
       
   338 /**
       
   339 tell listener to expect iMessageCount many messages / notifications
       
   340 sets the shared string to contain the value iMessageCount
       
   341 */
       
   342 void CConcurrentNotifierStep::SetMessageCountL()
       
   343 	{
       
   344 	ShareIntL(KSharedMessageCount, iMessageCount);
       
   345 	iMessageCount = 0;
       
   346 	}
       
   347 
       
   348 /**
       
   349 each listener appends a charcter to shared memory KSharedClients
       
   350 once it has received all notifications from this thread,
       
   351 this returns length of string
       
   352 */
       
   353 TInt CConcurrentNotifierStep::ReceivedCountL()
       
   354 	{
       
   355 	return SharedCountL(KSharedClients);
       
   356 	}
       
   357 
       
   358 /**
       
   359 Sets the value of all shared memmories to Null
       
   360 used at beginning/end of test case
       
   361 */
       
   362 void CConcurrentNotifierStep::ClearSharedL()
       
   363 	{
       
   364 	SetSharedTextL(KSharedEvents, KNullDesC, EFalse);
       
   365 	SetSharedTextL(KSharedContact, KNullDesC, EFalse);
       
   366 	SetSharedTextL(KSharedClients, KNullDesC, EFalse);
       
   367 	SetSharedTextL(KSharedMessageCount, KNullDesC, EFalse);
       
   368 	}
       
   369 
       
   370 /**
       
   371 if in revert mode rollback transaction, otherwise commit,
       
   372 tell listner to expect an notifications that may be generated
       
   373 */
       
   374 void CConcurrentNotifierStep::EndTransactionL( )
       
   375 	{
       
   376 	if(iRevert)
       
   377 		{
       
   378 		iRevert = EFalse;
       
   379 		iContactsDatabase->DatabaseRollback();
       
   380 		AddEventL( EContactDbObserverEventRollback );
       
   381 		AddContactL( KNullContactId );
       
   382 		CleanupStack::Pop();
       
   383 		TBool damaged = iContactsDatabase->IsDamaged();
       
   384 
       
   385 		#ifdef _DEBUG
       
   386 			#ifndef __SYMBIAN_CNTMODEL_USE_SQLITE__
       
   387 		//It maybe necessary to explicitly damage the database more than once
       
   388 		//for it to be registered as damaged
       
   389 		while( !iContactsDatabase->IsDamaged() )
       
   390 			{
       
   391 			//will give consistent behaviour on debug builds
       
   392 			iContactsDatabase->DamageDatabaseL(0x666);
       
   393 			}
       
   394 
       
   395 		if( !damaged )
       
   396 			{
       
   397 			AddEventL( EContactDbObserverEventRollback );
       
   398 			AddContactL( KNullContactId );
       
   399 			}
       
   400 			#endif
       
   401 		#endif
       
   402 
       
   403 		if( iContactsDatabase->IsDamaged() )
       
   404 			{
       
   405 			iContactsDatabase->RecoverL();
       
   406 			AddEventL( EContactDbObserverEventRecover );
       
   407 			AddContactL( 0 );
       
   408 			if( !damaged )
       
   409 				{
       
   410 				AddEventL( EContactDbObserverEventTablesClosed );
       
   411 				AddContactL( 0 );
       
   412 				}
       
   413 			AddEventL( EContactDbObserverEventTablesOpened );
       
   414 			AddContactL( 0 );
       
   415 			}
       
   416 		iRevert = ETrue;
       
   417 		}
       
   418 	else
       
   419 		{
       
   420 		iContactsDatabase->DatabaseCommitLP(EFalse);
       
   421 		}
       
   422 	iRevert = !iRevert;
       
   423 	}
       
   424 /**
       
   425 Used by all tests to wait for listener to recive notification and send confirmation back.
       
   426 timesout if no confirmation received
       
   427 */
       
   428 void CConcurrentNotifierStep::ProcessWaitL()
       
   429 	{
       
   430 	iEnd.UniversalTime();
       
   431 	if(ReceivedCountL() == iManyListeners)
       
   432 		{
       
   433 		if( iTests->Count() > 1 )
       
   434 			{
       
   435 			ClearSharedL();
       
   436 			}
       
   437 		iWaiting = EFalse;
       
   438 		++iNextTest;
       
   439 		}
       
   440 	else if( iEnd.MicroSecondsFrom( iStart ).Int64() > KTimeout ) //test has timed out
       
   441 		{
       
   442 		_LIT(KTimedOut,"Notifier test %d has timed out");
       
   443 		ERR_PRINTF2(KTimedOut, ++iNextTest);
       
   444 
       
   445 		if( iTests->Count() > 1 )
       
   446 			{
       
   447 			ClearSharedL();
       
   448 			}
       
   449 		iWaiting = EFalse;
       
   450 		TESTPRINT( EFalse );
       
   451 		iNextTest = iTests->Count();
       
   452 		}
       
   453 	//else test is not complete and has not timed out... continue waiting
       
   454 	}
       
   455 
       
   456 void CConcurrentNotifierStep::UpdateTestL()
       
   457 	{
       
   458 	INFO_PRINTF1(KTest1);
       
   459 	SetSharedTextL(KSharedNextTest,KSingleCharacter , ETrue);
       
   460 	iWaiting = ETrue;
       
   461 	TContactItemId cid = iIterate->NextL();
       
   462 	ReadL( cid );
       
   463 	iContactsDatabase->UpdateContactLC( cid, iContactItem);
       
   464 	CleanupStack::PopAndDestroy();
       
   465 	CloseL( ETrue );
       
   466 	AddEventL(EContactDbObserverEventContactChanged);
       
   467 	AddContactL( cid );
       
   468 	SetMessageCountL();
       
   469 	iStart.UniversalTime();
       
   470 	}
       
   471 
       
   472 void CConcurrentNotifierStep::CommitTestL()
       
   473 	{
       
   474 	INFO_PRINTF1(KTest2);
       
   475 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   476 	iWaiting = ETrue;
       
   477 	TContactItemId cid = iIterate->NextL();
       
   478 	OpenL( cid );
       
   479 	CommitL( EFalse );
       
   480 	AddEventL(EContactDbObserverEventContactChanged);
       
   481 	AddContactL( cid );
       
   482 	SetMessageCountL();
       
   483 	iStart.UniversalTime();
       
   484 	}
       
   485 
       
   486 void CConcurrentNotifierStep::AddTestL()
       
   487 	{
       
   488 	INFO_PRINTF1(KTest3);
       
   489 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   490 	iWaiting = ETrue;
       
   491 	CContactCard* contact = CContactCard::NewLC(iTemplate);
       
   492 	TContactItemId cid = iContactsDatabase->AddNewContactL(*contact);
       
   493 	iIterate->AddL( cid );
       
   494 	CleanupStack::PopAndDestroy(contact);
       
   495 	AddEventL(EContactDbObserverEventContactAdded);
       
   496 	AddContactL( cid );
       
   497 	SetMessageCountL();
       
   498 	iStart.UniversalTime();
       
   499 	}
       
   500 
       
   501 void CConcurrentNotifierStep::DeleteTestL()
       
   502 	{
       
   503 	INFO_PRINTF1(KTest4);
       
   504 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   505 	iWaiting = ETrue;
       
   506 	TContactItemId cid = iIterate->NextL();
       
   507 	DeleteContactL( cid, EFalse );
       
   508 	AddEventL(EContactDbObserverEventContactDeleted);
       
   509 	AddContactL( cid );
       
   510 	SetMessageCountL();
       
   511 	iStart.UniversalTime();
       
   512 	}
       
   513 
       
   514 void CConcurrentNotifierStep::OpenTablesTestL()
       
   515 	{
       
   516 	INFO_PRINTF1(KTest5);
       
   517 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   518 	iWaiting = ETrue;
       
   519 	iMyActive->Activate();
       
   520 	iContactsDatabase->OpenTablesL();
       
   521 	AddEventL( EContactDbObserverEventTablesOpened );
       
   522 	AddContactL( 0 );
       
   523 	SetMessageCountL();
       
   524 	iStart.UniversalTime();
       
   525 	}
       
   526 
       
   527 void CConcurrentNotifierStep::CloseTablesTestL()
       
   528 	{
       
   529 	INFO_PRINTF1(KTest6);
       
   530 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   531 	iWaiting = ETrue;
       
   532 	iMyActive->Activate();
       
   533 	iContactsDatabase->CloseTables();
       
   534 	AddEventL( EContactDbObserverEventTablesClosed );
       
   535 	AddContactL( 0 );
       
   536 	SetMessageCountL();
       
   537 	iStart.UniversalTime();
       
   538 	}
       
   539 
       
   540 void CConcurrentNotifierStep::OwnCardTestL()
       
   541 	{
       
   542 	INFO_PRINTF1(KTest7);
       
   543 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   544 	iWaiting = ETrue;
       
   545 	iMyActive->Activate();
       
   546 	CContactItem *item = iContactsDatabase->CreateOwnCardLC();
       
   547 	iIterate->AddL( item->Id() );
       
   548 	AddEventL( EContactDbObserverEventContactAdded );
       
   549 	AddContactL( item->Id() );
       
   550 	AddEventL( EContactDbObserverEventOwnCardChanged );
       
   551 	AddContactL( item->Id() );
       
   552 	CleanupStack::PopAndDestroy( item );
       
   553 	SetMessageCountL();
       
   554 	iStart.UniversalTime();
       
   555 	}
       
   556 
       
   557 void CConcurrentNotifierStep::ChangeOwnCardTestL()
       
   558 	{
       
   559 	INFO_PRINTF1(KTest14);
       
   560 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   561 	iWaiting = ETrue;
       
   562 	iMyActive->Activate();
       
   563 	TContactItemId cid = iIterate->NextL();
       
   564 	OpenL( cid );
       
   565 	iContactsDatabase->SetOwnCardL(*iContactItem);
       
   566 	CloseL( ETrue );
       
   567 	AddEventL( EContactDbObserverEventOwnCardChanged );
       
   568 	AddContactL( cid );
       
   569 	SetMessageCountL();
       
   570 	iStart.UniversalTime();
       
   571 	}
       
   572 
       
   573 void CConcurrentNotifierStep::OwnCardDeleteTestL()
       
   574 	{
       
   575 	INFO_PRINTF1(KTest9);
       
   576 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   577 	iWaiting = ETrue;
       
   578 	iMyActive->Activate();
       
   579 	TContactItemId cid = iContactsDatabase->OwnCardId();
       
   580 	ReadL( cid );
       
   581 	CloseL( EFalse );
       
   582 	DeleteContactL( cid, EFalse );
       
   583 	AddEventL( EContactDbObserverEventOwnCardDeleted );
       
   584 	AddContactL( cid);
       
   585 	SetMessageCountL();
       
   586 	iStart.UniversalTime();
       
   587 	}
       
   588 
       
   589 void CConcurrentNotifierStep::SpeedDialTestL()
       
   590 	{
       
   591 	INFO_PRINTF1(KTest8);
       
   592 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   593 	iWaiting = ETrue;
       
   594 	iMyActive->Activate();
       
   595 	TContactItemId cid = iIterate->PreviousL();//start at last contact, so that other tests are not corrupted
       
   596 	OpenL( cid );
       
   597 	TInt fieldId=iFields->Find(KUidContactFieldPhoneNumber);
       
   598 	iSpeedPosition = 1;
       
   599 	iContactsDatabase->SetFieldAsSpeedDialL(*iContactItem, fieldId, iSpeedPosition);
       
   600 	CloseL( EFalse );
       
   601 	OpenL( cid );
       
   602 	iSpeedPosition2 = 2;
       
   603 	iContactsDatabase->SetFieldAsSpeedDialL(*iContactItem, fieldId, iSpeedPosition2);
       
   604 	CloseL( EFalse );
       
   605 	AddEventL( EContactDbObserverEventSpeedDialsChanged );
       
   606 	AddContactL( cid );
       
   607 	AddEventL( EContactDbObserverEventSpeedDialsChanged );
       
   608 	AddContactL( cid );
       
   609 	AddEventL( EContactDbObserverEventSpeedDialsChanged );
       
   610 	AddContactL( cid );
       
   611 	SetMessageCountL();
       
   612 	iStart.UniversalTime();
       
   613 	}
       
   614 
       
   615 void CConcurrentNotifierStep::RemoveSpeedDialTestL()
       
   616 	{
       
   617 	INFO_PRINTF1(KTest16);
       
   618 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   619 	iWaiting = ETrue;
       
   620 	iMyActive->Activate();
       
   621 	TBuf<200> ptr;
       
   622 	TContactItemId cid = iContactsDatabase->GetSpeedDialFieldL(iSpeedPosition2, ptr);
       
   623 	iContactsDatabase->RemoveSpeedDialFieldL(cid, iSpeedPosition2);
       
   624 
       
   625 	AddEventL( EContactDbObserverEventSpeedDialsChanged );
       
   626 	AddContactL( cid );
       
   627 	SetMessageCountL();
       
   628 	iStart.UniversalTime();
       
   629 	}
       
   630 
       
   631 void CConcurrentNotifierStep::DeleteSpeedDialTestL()
       
   632 	{
       
   633 	INFO_PRINTF1(KTest15);
       
   634 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   635 	iWaiting = ETrue;
       
   636 	iMyActive->Activate();
       
   637 	TBuf<200> ptr;
       
   638 	TContactItemId cid = iContactsDatabase->GetSpeedDialFieldL(iSpeedPosition, ptr);
       
   639 	DeleteContactL( cid, EFalse );
       
   640 	AddEventL( EContactDbObserverEventSpeedDialsChanged );
       
   641 	AddContactL( cid );
       
   642 	AddEventL( EContactDbObserverEventContactDeleted );
       
   643 	AddContactL( cid);
       
   644 	SetMessageCountL();
       
   645 	iStart.UniversalTime();
       
   646 	}
       
   647 
       
   648 
       
   649 void CConcurrentNotifierStep::SingleCommitTransactionTestL()
       
   650 	{
       
   651 	if( iRevert )
       
   652 		{
       
   653 		INFO_PRINTF1(KTest102);
       
   654 		}
       
   655 	else
       
   656 		{
       
   657 		INFO_PRINTF1(KTest10);
       
   658 		}
       
   659 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   660 	iWaiting = ETrue;
       
   661 	TContactItemId cid = iIterate->NextL();
       
   662 
       
   663 	iContactsDatabase->DatabaseBeginLC(EFalse);
       
   664 	OpenL( cid );
       
   665 	CommitL( ETrue );
       
   666 	AddEventL(EContactDbObserverEventContactChanged);
       
   667 	AddContactL( cid );
       
   668 	EndTransactionL();
       
   669 	SetMessageCountL();
       
   670 
       
   671 	iStart.UniversalTime();
       
   672 	}
       
   673 
       
   674 void CConcurrentNotifierStep::MultipleChangeTransactionTestL()
       
   675 	{
       
   676 	if( iRevert )
       
   677 		{
       
   678 		INFO_PRINTF1(KTest112);
       
   679 		}
       
   680 	else
       
   681 		{
       
   682 		INFO_PRINTF1(KTest11);
       
   683 		}
       
   684 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   685 	iWaiting = ETrue;
       
   686 	TContactItemId cid = iIterate->NextL();
       
   687 
       
   688 	iContactsDatabase->DatabaseBeginLC(EFalse);
       
   689 	OpenL( cid );
       
   690 	CommitL( ETrue );
       
   691 	AddEventL(EContactDbObserverEventContactChanged);
       
   692 	AddContactL( cid );
       
   693 
       
   694 	cid = iIterate->NextL();
       
   695 	ReadL( cid );
       
   696 	iContactsDatabase->UpdateContactLC( cid, iContactItem);
       
   697 	CleanupStack::PopAndDestroy();
       
   698 	CloseL( ETrue );
       
   699 	AddEventL(EContactDbObserverEventContactChanged);
       
   700 	AddContactL( cid );
       
   701 
       
   702 	CContactCard* contact = CContactCard::NewLC(iTemplate);
       
   703 	cid = iContactsDatabase->doAddNewContactL(*contact, EFalse, ETrue);
       
   704 	if(!iRevert)
       
   705 		{
       
   706 		iIterate->AddL( cid );
       
   707 		}
       
   708 	CleanupStack::PopAndDestroy(contact);
       
   709 	AddEventL(EContactDbObserverEventContactAdded);
       
   710 	AddContactL( cid );
       
   711 
       
   712 	cid = iIterate->NextL();
       
   713 	DeleteContactL( cid, ETrue );
       
   714 	AddEventL(EContactDbObserverEventContactDeleted);
       
   715 	AddContactL( cid );
       
   716 
       
   717 	EndTransactionL();
       
   718 	SetMessageCountL();
       
   719 
       
   720 	iStart.UniversalTime();
       
   721 	}
       
   722 
       
   723 void CConcurrentNotifierStep::EmptyTransactionTestL()
       
   724 	{
       
   725 	if( iRevert )
       
   726 		{
       
   727 		INFO_PRINTF1(KTest122);
       
   728 		}
       
   729 	else
       
   730 		{
       
   731 		INFO_PRINTF1(KTest12);
       
   732 		}
       
   733 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   734 	iWaiting = ETrue;
       
   735 	iContactsDatabase->DatabaseBeginLC(EFalse);
       
   736 	AddEventL(KNullEvent);
       
   737 	AddContactL( KNullEvent );
       
   738 	EndTransactionL();
       
   739 	SetMessageCountL();
       
   740 
       
   741 	iStart.UniversalTime();
       
   742 	}
       
   743 
       
   744 void CConcurrentNotifierStep::UnkownChangeTestL()
       
   745 	{
       
   746 	INFO_PRINTF1(KTest13);
       
   747 	SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue);
       
   748 	iWaiting = ETrue;
       
   749 	iMyActive->Activate();
       
   750 	TContactItemId cid = iIterate->NextL();
       
   751 	TInt i = 0;
       
   752 	iContactsDatabase->DatabaseBeginLC(EFalse);
       
   753 	for( ; i < KMaxNumberOfEventsInEventQueue + 1; ++i )
       
   754 		{
       
   755 		OpenL( cid );
       
   756 		CommitL( EFalse );
       
   757 		}
       
   758 	AddEventL( EContactDbObserverEventUnknownChanges );
       
   759 	AddContactL( -1 );
       
   760 	EndTransactionL();
       
   761 	SetMessageCountL();
       
   762 	iStart.UniversalTime();
       
   763 	}
       
   764 
       
   765 
       
   766