phonebookengines_old/contactsmodel/tsrc/t_viewevents.cpp
changeset 40 b46a585f6909
equal deleted inserted replaced
37:fd64c38c277d 40:b46a585f6909
       
     1 // Copyright (c) 2000-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 //
       
    15 
       
    16 #include <e32std.h>
       
    17 #include <e32test.h>
       
    18 #include <cntdb.h>
       
    19 #include <cntitem.h>
       
    20 #include <cntfldst.h>
       
    21 #include "t_utils2.h"
       
    22 #include "t_viewevents.h"
       
    23 
       
    24 //
       
    25 // Constants.
       
    26 //
       
    27 _LIT8(KSortPlugin, "application.vnd.symbian.com/contacts-reverse-sort"); //SimpleSortPlugin DLL Unique name
       
    28 
       
    29 _LIT(KTestName,"t_viewevents");
       
    30 _LIT(KLogFileName,"t_viewevents.log");
       
    31 
       
    32 _LIT(KDbFileName,"c:t_viewevents.cdb");
       
    33 
       
    34 _LIT(KRemoteViewName,"RemoteView");
       
    35 _LIT(KGroupOneName,"GroupOne");
       
    36 _LIT(KGroupTwoName,"GroupTwo");
       
    37 
       
    38 const TInt KContactIdToNotAssignToGroup2 = 5;
       
    39 
       
    40 LOCAL_D RTest test(KTestName);
       
    41 
       
    42 
       
    43 //
       
    44 // CTestConductor.
       
    45 //
       
    46 
       
    47 CTestConductor* CTestConductor::NewL()
       
    48 	{
       
    49 	CTestConductor* self=new(ELeave) CTestConductor();
       
    50 	CleanupStack::PushL(self);
       
    51 	self->ConstructL();
       
    52 	self->RunTestsL();
       
    53 	CleanupStack::Pop();
       
    54 	return self;
       
    55 	}
       
    56 
       
    57 CTestConductor::~CTestConductor()
       
    58 	{
       
    59 	delete iLog;
       
    60 	delete iDb;
       
    61 	delete iRandomGenerator;
       
    62     TRAP_IGNORE(CContactDatabase::DeleteDatabaseL(KDbFileName));
       
    63 	iFs.Close();
       
    64 	}
       
    65 
       
    66 CTestConductor::CTestConductor() 
       
    67 	{
       
    68 	}
       
    69 
       
    70 void CTestConductor::ConstructL()
       
    71 	{
       
    72 	User::LeaveIfError(iFs.Connect());
       
    73 	iLog=CLog::NewL(test,KLogFileName);
       
    74 	iDb=CContactDatabase::ReplaceL(KDbFileName);
       
    75 	iRandomGenerator=CRandomContactGenerator::NewL();
       
    76 	iRandomGenerator->SetDbL(*iDb);
       
    77 	AddContactsL();
       
    78 	}
       
    79 
       
    80 void CTestConductor::AddContactL(TInt aBitwiseFilterType)
       
    81 	{
       
    82 	test.Printf(_L("Adding Contact"));
       
    83 	iRandomGenerator->AddTypicalContactForFilterL(aBitwiseFilterType);
       
    84 	iTotalContacts++;
       
    85 	}
       
    86 
       
    87 void CTestConductor::AddContactsL()
       
    88 	{
       
    89 	iTotalContacts=0;
       
    90 	test.Printf(_L("Adding "));
       
    91 	TInt ii;
       
    92 	for (ii=0;ii<5;ii++)
       
    93 		{
       
    94 		TInt bit=0;
       
    95 		bit |= CContactDatabase::ESmsable;
       
    96 		iRandomGenerator->AddTypicalContactForFilterL(bit);
       
    97 		iTotalContacts++;
       
    98 		}
       
    99 
       
   100 
       
   101 	for (ii=0;ii<5;ii++)
       
   102 		{
       
   103 		TInt bit=0;
       
   104 		bit |= CContactDatabase::ELandLine;
       
   105 		iRandomGenerator->AddTypicalContactForFilterL(bit);
       
   106 		iTotalContacts++;
       
   107 		}
       
   108 
       
   109 	}
       
   110 
       
   111 void CTestConductor::RunTestsL()
       
   112 	{
       
   113 	CViewTester* tester=CViewTester::NewL(*iLog,*iDb,this);
       
   114 	CleanupStack::PushL(tester);
       
   115 	CActiveScheduler::Start();
       
   116 	CleanupStack::PopAndDestroy(); // tester.
       
   117 	}
       
   118 
       
   119 void CTestConductor::SetTestError(TInt aTestError)
       
   120 	{
       
   121 	// error from tester
       
   122 	iTestError = aTestError;
       
   123 	}
       
   124 
       
   125 //
       
   126 // CViewTester.
       
   127 //
       
   128 
       
   129 CViewTester* CViewTester::NewL(CLog& aLog,CContactDatabase& aDb,CTestConductor* aTestConductor)
       
   130 	{
       
   131 	CViewTester* self=new(ELeave) CViewTester(aLog,aDb,aTestConductor);
       
   132 	CleanupStack::PushL(self);
       
   133 	self->ConstructL();
       
   134 	CleanupStack::Pop();
       
   135 	return self;
       
   136 	}
       
   137 
       
   138 
       
   139 
       
   140 CViewTester::CViewTester(CLog& aLog,CContactDatabase& aDb,CTestConductor* aTestConductor)
       
   141 	: CActive(EPriorityStandard),iLog(aLog),iDb(aDb),iTestConductor(aTestConductor)
       
   142 	{
       
   143 	CActiveScheduler::Add(this);
       
   144 	}
       
   145 
       
   146 CViewTester::~CViewTester()
       
   147 	{
       
   148 	DestructRemoteView();
       
   149 	DestructFilterView();
       
   150 	DestructGroupView();
       
   151 	DestructGroupView2();
       
   152 	delete iGroup;
       
   153 	iGroup = NULL;
       
   154     delete iGroup2;
       
   155     iGroup2 = NULL;	
       
   156 	iViewSortOrder.Close();
       
   157 	iLocalViewResults.Close();
       
   158 	iReceivedResults.Close();
       
   159 	}
       
   160 
       
   161 void CViewTester::ConstructL()
       
   162 	{
       
   163 	iViewSortOrder.AppendL(KUidContactFieldGivenName);
       
   164 	iViewSortOrder.AppendL(KUidContactFieldFamilyName);
       
   165 	iViewSortOrder.AppendL(KUidContactFieldCompanyName);
       
   166 	iGroup = static_cast<CContactGroup*>(iDb.CreateContactGroupL(KGroupOneName));
       
   167 	AssignAllContactsToGroupL();
       
   168     iGroup2 = static_cast<CContactGroup*>(iDb.CreateContactGroupL(KGroupTwoName));
       
   169    	AssignContactsToGroup2L();
       
   170 
       
   171 	iTestState = EStartingTests;
       
   172 	NextTest();
       
   173 	}
       
   174 
       
   175 
       
   176 void CViewTester::NextTest()
       
   177 	{
       
   178 	iTestState = static_cast<TTest>( static_cast<TInt>(iTestState) + 1 );
       
   179 	TRequestStatus *pS=&iStatus;
       
   180 	User::RequestComplete(pS,KErrNone);
       
   181 	SetActive();
       
   182 	}
       
   183 
       
   184 
       
   185 void CViewTester::CompareRecordedResultWithExpected()
       
   186 	{
       
   187 	TInt counter;
       
   188 	TInt max;
       
   189 	TContactViewEvent::TEventType expected;
       
   190 	TContactViewEvent::TEventType actual;
       
   191 
       
   192 	test( iLocalViewResults.Count() == iReceivedResults.Count() );
       
   193 	max = iLocalViewResults.Count();
       
   194 
       
   195 	for (counter = 0; counter < max; counter++)
       
   196 		{
       
   197 		expected = static_cast<TContactViewEvent::TEventType>(iLocalViewResults[counter]);
       
   198 		actual = static_cast<TContactViewEvent::TEventType>(iReceivedResults[counter]);
       
   199 		test( expected == actual );
       
   200 		}
       
   201 
       
   202 	iReceivedResults.Reset();
       
   203 	}
       
   204 
       
   205 
       
   206 
       
   207 
       
   208 void CViewTester::RunL()
       
   209 	{
       
   210 	switch (iTestState)
       
   211 		{
       
   212 		//
       
   213 		// Remote View
       
   214 		//
       
   215 		case EConstructRemoteView:
       
   216 			iLog.LogLine ( _L("=== Creating remote view"));
       
   217 			ConstructRemoteViewL();
       
   218 			break;
       
   219 		case ERemoteViewSortOrderChange:
       
   220 			iLog.LogLine ( _L("=== Changing sort order and recording application messages"));
       
   221 			RemoteViewSortOrderChangeL();
       
   222 			break;
       
   223 
       
   224 		//
       
   225 		// Filter View
       
   226 		//
       
   227 		case EConstructFilterView:
       
   228 			iLog.LogLine ( _L("=== Creating Filter View"));
       
   229 			ConstructFilterViewL();
       
   230 			break;
       
   231 		case EFilterViewSortOrderChange:
       
   232 			iLog.LogLine ( _L("=== Changing sort order and processing application messages"));
       
   233 			FilterViewSortOrderChangeL();
       
   234 			break;
       
   235 
       
   236 		//
       
   237 		// Group View
       
   238 		//
       
   239 		case EConstructGroupView:
       
   240 			iLog.LogLine ( _L("=== Creating Group View"));
       
   241 			ConstructGroupViewL();
       
   242 			break;
       
   243 		case EGroupViewSortOrderChange:
       
   244 			iLog.LogLine ( _L("=== Changing sort order and processing application messages"));
       
   245 			GroupViewSortOrderChangeL();
       
   246 			break;
       
   247 
       
   248         //
       
   249         // Group2 View
       
   250         //
       
   251         case EConstructGroupView2:
       
   252             iLog.LogLine(_L("=== Creating Group2 View"));
       
   253             ConstructGroupView2L();
       
   254             break;
       
   255         case EGroupView2DeleteContactEvent:
       
   256             iLog.LogLine(_L("=== Deleting the only contact in group 2"));
       
   257             GroupView2DeleteOnlyContactL();
       
   258             break;
       
   259 
       
   260         //
       
   261         // Remote View
       
   262         //
       
   263 		case ERemoteViewPlugin2:
       
   264 		case ERemoteViewPlugin:
       
   265 			iLog.LogLine ( _L("=== Creating remote view plugin"));
       
   266 			ConstructRemoteViewL(KSortPlugin);
       
   267 			break;
       
   268 			
       
   269 		//
       
   270 		// End Tests
       
   271 		//
       
   272 		case EEndTest:
       
   273 
       
   274 			iLog.LogLine(_L("==== Finished Tests"));
       
   275 			CActiveScheduler::Stop();
       
   276 			break;
       
   277 
       
   278 		default:
       
   279 			ASSERT(EFalse);
       
   280 			break;
       
   281 		}
       
   282 	}
       
   283 
       
   284 TInt CViewTester::RunError(TInt aError)
       
   285 	{
       
   286 	// propagate error
       
   287 	iTestConductor->SetTestError(aError);
       
   288 
       
   289 	switch (iTestState)
       
   290 		{
       
   291 		case EConstructRemoteView: test.Printf(_L("Test failed at step ConstructRemoteView (%i), with error %i"), iTestState, aError); break;
       
   292 		case ERemoteViewSortOrderChange: test.Printf(_L("Test failed at step RemoteViewSortOrderChange (%i), with error %i"), iTestState, aError); break;
       
   293 		case EConstructFilterView: test.Printf(_L("Test failed at step ConstructFilterView (%i), with error %i"), iTestState, aError); break;
       
   294 		case EFilterViewSortOrderChange: test.Printf(_L("Test failed at step FilterViewSortOrderChange (%i), with error %i"), iTestState, aError); break;
       
   295 		case EConstructGroupView: test.Printf(_L("Test failed at step ConstructGroupView (%i), with error %i"), iTestState, aError); break;
       
   296 		case EGroupViewSortOrderChange: test.Printf(_L("Test failed at step GroupViewSortOrderChange (%i), with error %i"), iTestState, aError); break;
       
   297         case EConstructGroupView2: test.Printf(_L("Test failed at step ConstructGroupView2 (%i), with error %i"), iTestState, aError); break;
       
   298         case EGroupView2DeleteContactEvent: test.Printf(_L("Test failed at step EGroupView2DeleteContactEvent (%i), with error %i"), iTestState, aError); break;
       
   299 		case ERemoteViewPlugin2: test.Printf(_L("Test failed at step RemoteViewPlugin2 (%i), with error %i"), iTestState, aError); break;
       
   300 		case ERemoteViewPlugin: test.Printf(_L("Test failed at step RemoteViewPlugin (%i), with error %i"), iTestState, aError); break;
       
   301 		case EEndTest: test.Printf(_L("Test failed at step EndTest (%i), with error %i"), iTestState, aError); break;
       
   302 
       
   303 		default: test.Printf(_L("Test failed at step %i, with error %i"), iTestState, aError); break;
       
   304 		}
       
   305 
       
   306 	CActiveScheduler::Stop();
       
   307 	return KErrNone;
       
   308 	}
       
   309 
       
   310 
       
   311 void CViewTester::HandleContactViewEvent(const CContactViewBase& aView,const TContactViewEvent& aEvent)
       
   312 	{
       
   313 	static TInt NumChanged = 0;
       
   314 	switch (iTestState)
       
   315 		{
       
   316 		//
       
   317 		// Remote View
       
   318 		//
       
   319 		case EConstructRemoteView:
       
   320 			if ( (&aView == iRemoteView) && (aEvent.iEventType == TContactViewEvent::EReady) )
       
   321 				{
       
   322 				NextTest();
       
   323 				}
       
   324 			break;
       
   325 
       
   326 		case ERemoteViewSortOrderChange:
       
   327 			if ( &aView == iRemoteView )
       
   328 				{
       
   329 				iLocalViewResults.Append( aEvent.iEventType );
       
   330 				if ( aEvent.iEventType == TContactViewEvent::ESortOrderChanged )
       
   331 					{
       
   332 					NextTest();
       
   333 					}
       
   334 				}
       
   335 			break;
       
   336 
       
   337 		//
       
   338 		// Filter View
       
   339 		//
       
   340 		case EConstructFilterView:
       
   341 			if ( (&aView == iFilteredView) && (aEvent.iEventType == TContactViewEvent::EReady) )
       
   342 				{
       
   343 				NextTest();
       
   344 				}
       
   345 			break;
       
   346 
       
   347 		case EFilterViewSortOrderChange:
       
   348 			if ( &aView == iFilteredView )
       
   349 				{
       
   350 				iReceivedResults.Append( aEvent.iEventType );
       
   351 				if ( aEvent.iEventType == TContactViewEvent::ESortOrderChanged )
       
   352 					{
       
   353 					CompareRecordedResultWithExpected();
       
   354 					NextTest();
       
   355 					}
       
   356 				}
       
   357 			break;
       
   358 
       
   359 		//
       
   360 		// Group View
       
   361 		//
       
   362 		case EConstructGroupView:
       
   363 			if ( (&aView == iGroupView) && (aEvent.iEventType == TContactViewEvent::EReady) )
       
   364 				{
       
   365 				NumChanged = 0;
       
   366 				NextTest();
       
   367 				}
       
   368 			break;
       
   369 
       
   370 		case EGroupViewSortOrderChange:
       
   371 			if ( aEvent.iEventType == TContactViewEvent::ESortOrderChanged)
       
   372 				{
       
   373 				++NumChanged;
       
   374 				}
       
   375 			if ( &aView == iGroupView )
       
   376 				{
       
   377 				iReceivedResults.Append( aEvent.iEventType );
       
   378 				}
       
   379 			if ( NumChanged == 3 )
       
   380 				{
       
   381 				CompareRecordedResultWithExpected();
       
   382 				NextTest();
       
   383 				}
       
   384 			break;
       
   385 
       
   386         //
       
   387         // Group2 View
       
   388         //
       
   389         case EConstructGroupView2:
       
   390             if ((&aView == iGroupView2) && (aEvent.iEventType == TContactViewEvent::EReady))
       
   391                 {
       
   392                 NextTest();
       
   393                 }
       
   394             break;
       
   395        
       
   396         case EGroupView2DeleteContactEvent:
       
   397             if ((&aView == iGroupView2))
       
   398                 {
       
   399                 // When a contact is deleted, we expect a EGroupChanged event
       
   400                 // followed by a EItemRemoved. The iInt in the EItemRemoved
       
   401                 // should be the index of the contact in the group view and
       
   402                 // not its index in the underlying view.
       
   403                 switch (aEvent.iEventType)
       
   404                     {
       
   405                     case TContactViewEvent::EGroupChanged:
       
   406                         break;
       
   407                     case TContactViewEvent::EItemRemoved:
       
   408                         {
       
   409                         // Check that the index in the event is the index of
       
   410                         // the contact in the group view and NOT the index
       
   411                         // of the contact in the global database. There is
       
   412                         // only one item in the group, so its index is 0.
       
   413                         test(aEvent.iInt == iContactToDeleteMapping.iMapping);
       
   414                         test(aEvent.iContactId == iContactToDeleteMapping.iId);
       
   415                         NextTest();                       
       
   416                         }
       
   417                         break;
       
   418                     default:
       
   419                         test(EFalse);
       
   420                     }
       
   421                 }
       
   422             break;
       
   423 
       
   424         //
       
   425         // Remote View Plugin
       
   426         //
       
   427 		case ERemoteViewPlugin:
       
   428 			if ( aEvent.iEventType == TContactViewEvent::EReady)
       
   429 				{
       
   430 				NextTest();
       
   431 				}
       
   432 			break;
       
   433 			
       
   434 		case ERemoteViewPlugin2:
       
   435 			if (aEvent.iEventType == TContactViewEvent::EReady)
       
   436 				{
       
   437 				/* test to make sure both these two view2 use the same remote view
       
   438 					We can't *really* test this without a lot of painful effort. So we test what we can:
       
   439 					that the two plugins are identical. 
       
   440 					To really confirm this, check the logs to ensure that two example sort
       
   441 					plugins were created.
       
   442 					
       
   443 					There should be two instantiated on the client side and one on the server side.
       
   444 					Thus a total of three.
       
   445 				*/
       
   446 				TUid firstID = iRemoteView2->GetViewSortPluginImplUid();
       
   447 				TUid secondID = iRemoteView3->GetViewSortPluginImplUid();
       
   448 				test(firstID == secondID); // make sure both use the same plugin.
       
   449 
       
   450 
       
   451 				CArrayFix<TContactItemId >* ids(NULL);
       
   452 				CArrayFix<TContactItemId >* ids2(NULL);
       
   453 				TRAPD(err, 
       
   454 					ids = OrderOfContactsLC(*iRemoteView2);
       
   455 					ids2 = OrderOfContactsLC(*iRemoteView3);
       
   456 					// Must pop these here because they're on this trap's cleanup stack.
       
   457 					// Don't need to re-push them as nothing below can leave.
       
   458 					CleanupStack::Pop(2, ids); // and ids2
       
   459 					)
       
   460 				test(err == KErrNone);
       
   461 				
       
   462 				TInt size = ids->Count();
       
   463 				test(ids2->Count() == size);
       
   464 				for (TInt i =0; i < size; ++i) 
       
   465 					{
       
   466 					test(ids->At(i) == ids2->At(i));
       
   467 					}
       
   468 
       
   469 				// cleanup id arrays -- don't need Reset() as only holding TClasses
       
   470 				delete ids;
       
   471 				delete ids2;
       
   472 	
       
   473 				NextTest();
       
   474 
       
   475 				}
       
   476 			break;
       
   477 
       
   478 		//
       
   479 		// End Tests
       
   480 		//
       
   481 		case EEndTest:
       
   482 		default:
       
   483 			test(EFalse);
       
   484 			break;
       
   485 		}
       
   486 	}
       
   487 
       
   488 void CViewTester::AssignAllContactsToGroupL()
       
   489 	{
       
   490 	TInt counter = 0;
       
   491 	for ( counter = 0; counter < 10; counter++)
       
   492 		{
       
   493 		iDb.AddContactToGroupL(counter, iGroup->Id());
       
   494 		}
       
   495 	}
       
   496 
       
   497 void CViewTester::AssignContactsToGroup2L()
       
   498     {
       
   499     TInt counter = 0;
       
   500     for ( counter = 0; counter < 10; counter++)
       
   501         {
       
   502         if (counter != KContactIdToNotAssignToGroup2)
       
   503             {
       
   504             iDb.AddContactToGroupL(counter, iGroup2->Id());
       
   505             }
       
   506         }
       
   507     }
       
   508 
       
   509 void CViewTester::ConstructFilterViewL()
       
   510 	{
       
   511 	iFilteredView = CContactFilteredView::NewL(*this, iDb, *iRemoteView, EContactsOnly);
       
   512 	}
       
   513 
       
   514 void CViewTester::FilterViewSortOrderChangeL()
       
   515 	{
       
   516 	iRemoteView->ChangeSortOrderL(iViewSortOrder);
       
   517 	}
       
   518 
       
   519 void CViewTester::DestructFilterView()
       
   520 	{
       
   521 	if (iFilteredView) iFilteredView->Close( *this );
       
   522 	// filtered view should delete it's self when it runs out of observers
       
   523 	iFilteredView = NULL;
       
   524 	}
       
   525 
       
   526 void CViewTester::ConstructRemoteViewL(const TDesC8& aSortPluginName)
       
   527 	{
       
   528 	if(aSortPluginName.Length() == 0)
       
   529 		{
       
   530 		iRemoteView = CContactNamedRemoteView::NewL(*this, KRemoteViewName, iDb, iViewSortOrder, EContactsOnly);
       
   531 		}
       
   532 	else 
       
   533 		{
       
   534 		if(iRemoteView2) 
       
   535 			iRemoteView3 = CContactRemoteView::NewL(*this, iDb, iViewSortOrder, EContactsOnly, aSortPluginName);
       
   536 		else
       
   537 			iRemoteView2 = CContactRemoteView::NewL(*this, iDb, iViewSortOrder, EContactsOnly, aSortPluginName);
       
   538 		}
       
   539 	}
       
   540 
       
   541 CContactRemoteView* CViewTester::ExtracttRemoteViewLC()
       
   542 	{
       
   543 	CContactRemoteView* remoteView = iRemoteView2;
       
   544 	iRemoteView2 = NULL;
       
   545 	CleanupStack::PushL(remoteView);
       
   546 	return remoteView;
       
   547 	}
       
   548 
       
   549 void CViewTester::RemoteViewSortOrderChangeL()
       
   550 	{
       
   551 	iRemoteView->ChangeSortOrderL(iViewSortOrder);
       
   552 	}
       
   553 
       
   554 void CViewTester::DestructRemoteView()
       
   555 	{
       
   556 	if (iRemoteView) iRemoteView->Close( *this );
       
   557 	// remote view should delete it's self when it runs out of observers
       
   558 	iRemoteView = NULL;
       
   559 	if (iRemoteView2) iRemoteView2->Close( *this );
       
   560 	// remote view should delete it's self when it runs out of observers
       
   561 	iRemoteView2 = NULL;
       
   562 	if (iRemoteView3) iRemoteView3->Close( *this );
       
   563 	// remote view should delete it's self when it runs out of observers
       
   564 	iRemoteView3 = NULL;
       
   565 
       
   566 	}
       
   567 
       
   568 void CViewTester::ConstructGroupViewL()
       
   569 	{
       
   570 	iGroupView = CContactGroupView::NewL(iDb,*iRemoteView,*this,iGroup->Id(),CContactGroupView::EShowContactsInGroup);
       
   571 	}
       
   572 
       
   573 void CViewTester::GroupViewSortOrderChangeL()
       
   574 	{
       
   575 	iRemoteView->ChangeSortOrderL(iViewSortOrder);
       
   576 	}
       
   577 
       
   578 void CViewTester::DestructGroupView()
       
   579 	{
       
   580 	if(iGroupView) iGroupView->Close(*this);
       
   581 	// group view should delete it's self when it runs out of observers
       
   582 	iGroupView = NULL;
       
   583 	}
       
   584 
       
   585 void CViewTester::ConstructGroupView2L()
       
   586     {
       
   587     iGroupView2 = CContactGroupView::NewL(iDb,*iRemoteView,*this,iGroup2->Id(),CContactGroupView::EShowContactsNotInGroup);
       
   588     }
       
   589    
       
   590 void CViewTester::GroupView2DeleteOnlyContactL()
       
   591     {
       
   592     // Set up the mapping between the contact Id that
       
   593     // will be deleted and its index in the group view.
       
   594     iContactToDeleteMapping.iId = KContactIdToNotAssignToGroup2;
       
   595     iContactToDeleteMapping.iMapping = iGroupView2->FindL(KContactIdToNotAssignToGroup2);
       
   596    
       
   597     iDb.DeleteContactL(KContactIdToNotAssignToGroup2);
       
   598     }
       
   599    
       
   600 void CViewTester::DestructGroupView2()
       
   601     {
       
   602     if(iGroupView2) iGroupView2->Close(*this);
       
   603     // group view should delete it's self when it runs out of observers
       
   604     iGroupView2 = NULL;
       
   605     }
       
   606 
       
   607 CArrayFix<TContactItemId >* CViewTester::OrderOfContactsLC(const CContactViewBase& aView)
       
   608 	{ // aView must be ready
       
   609 	CArrayFix<TContactItemId >* ids=new(ELeave) CArrayFixFlat<TContactItemId >(4);
       
   610 	CleanupStack::PushL(ids);
       
   611 
       
   612 	TInt size = aView.CountL();
       
   613 	for(TInt i=0;i<size;i++)
       
   614 		{
       
   615 		ids->AppendL(aView.AtL(i));
       
   616 		}
       
   617 	return ids;
       
   618 	}
       
   619 
       
   620 
       
   621 void CViewTester::DoCancel()
       
   622 	{
       
   623 	}
       
   624 
       
   625 //
       
   626 // Main.
       
   627 //
       
   628 
       
   629 /**
       
   630 
       
   631 @SYMTestCaseID     PIM-T-VIEWEVENTS-0001
       
   632 
       
   633 */
       
   634 
       
   635 GLDEF_C TInt E32Main()
       
   636 	{
       
   637 	__UHEAP_MARK;
       
   638 	CActiveScheduler* scheduler=new CActiveScheduler;
       
   639 	test.Start(_L("@SYMTESTCaseID:PIM-T-VIEWEVENTS-0001 Testing ViewEvents"));
       
   640 
       
   641 	if (scheduler)
       
   642 		{
       
   643 		CActiveScheduler::Install(scheduler);
       
   644 		CTrapCleanup* cleanup=CTrapCleanup::New();
       
   645 		if (cleanup)
       
   646 			{
       
   647 			CTestConductor* testConductor=NULL;
       
   648 			TRAP_IGNORE(testConductor = CTestConductor::NewL());
       
   649 			delete testConductor;
       
   650 			delete cleanup;
       
   651 			}
       
   652 		delete scheduler;
       
   653 		}
       
   654 	test.End();
       
   655 	test.Close();
       
   656 	__UHEAP_MARKEND;
       
   657 	return KErrNone;
       
   658     }