landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTP28.cpp
branchRCL_3
changeset 44 2b4ea9893b66
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *   ?description_line
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //  INCLUDES
       
    21 #include "FT_CPosTp28.h"
       
    22 #include "FT_LandmarkConstants.h"
       
    23 
       
    24 // CONSTANTS
       
    25 const TInt KMaxQueueSize = 5;
       
    26 _LIT(KTp28TestDb, "Tp28Test.ldb");
       
    27 _LIT(KTp28LmFullDefaultDbPath, "c:\\private\\100012a5\\DBS_101FE978_TP28TEST.LDB");
       
    28 
       
    29 // ---------------------------------------------------------
       
    30 // CPosTp28::CloseTest
       
    31 //
       
    32 // (other items were commented in a header).
       
    33 // ---------------------------------------------------------
       
    34 //
       
    35 void CPosTp28::CloseTest()
       
    36     {
       
    37 	delete iDatabase;
       
    38 	iDatabase = NULL;
       
    39     delete iCategoryManager;
       
    40     iCategoryManager=NULL;
       
    41     delete iActiveLmEvent;
       
    42     iActiveLmEvent = NULL;
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // CPosTp28::StartL
       
    47 //
       
    48 // (other items were commented in a header).
       
    49 // ---------------------------------------------------------
       
    50 //
       
    51 void CPosTp28::StartL()
       
    52     {
       
    53 	// copy the test db to the private database path
       
    54 	
       
    55     _LIT(KTestPath, "c:\\system\\test\\testdata\\");
       
    56 
       
    57     CFileMan* fileMan = CFileMan::NewL(iFileSession);
       
    58     CleanupStack::PushL(fileMan);
       
    59 
       
    60     TBuf<150> srcPath;
       
    61 
       
    62     srcPath.Append(KTestPath);
       
    63     srcPath.Append(KTp28TestDb);
       
    64 
       
    65     TInt err = fileMan->Copy(srcPath, KTp28LmFullDefaultDbPath,
       
    66             CFileMan::EOverWrite);
       
    67     if (err != KErrNone)
       
    68         iLog->Log(_L("Error when copying file"));
       
    69 
       
    70     CleanupStack::PopAndDestroy(fileMan);
       
    71     
       
    72     CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL();
       
    73     CleanupStack::PushL(manager);
       
    74 
       
    75     // This db must exist
       
    76     manager->SetDefaultDatabaseUriL(KTp28TestDb);
       
    77     CleanupStack::PopAndDestroy(manager);
       
    78 
       
    79     iDatabase = CPosLandmarkDatabase::OpenL(KTp28TestDb);
       
    80     if (iDatabase->IsInitializingNeeded())
       
    81         {
       
    82         TRAPD( err, ExecuteAndDeleteLD( iDatabase->InitializeL() ) );
       
    83         AssertTrueSecL(err == KErrNone, _L("Init db failed"));
       
    84         }
       
    85 
       
    86 
       
    87 
       
    88     iActiveLmEvent = CActiveLmEvent::NewL(iLog);
       
    89 	
       
    90     LandmarkEventTest();
       
    91     
       
    92     delete iActiveLmEvent;
       
    93     iActiveLmEvent = NULL;
       
    94     
       
    95     delete iDatabase;
       
    96     iDatabase = NULL;
       
    97     
       
    98     iDatabase = CPosLandmarkDatabase::OpenL(KTp28TestDb);   
       
    99     if (iDatabase->IsInitializingNeeded())
       
   100        {
       
   101        ExecuteAndDeleteLD(iDatabase->InitializeL());
       
   102        }
       
   103 
       
   104     iCategoryManager = CPosLmCategoryManager::NewL(*iDatabase); 
       
   105     
       
   106     iActiveLmEvent = CActiveLmEvent::NewL(iLog);
       
   107 
       
   108     LandmarkEventQueueTest();
       
   109 
       
   110     if (iActiveLmEvent->iGlobalErr != KErrNone)
       
   111         {
       
   112         
       
   113         iLog->Log(_L("Errors found in TP28"));
       
   114        	User::Leave(-1);
       
   115             
       
   116         }
       
   117     }
       
   118 
       
   119 // ---------------------------------------------------------
       
   120 // CPosTp28::LandmarkEventTest
       
   121 //
       
   122 // (other items were commented in a header).
       
   123 // ---------------------------------------------------------
       
   124 //
       
   125 void CPosTp28::LandmarkEventTest()
       
   126     {
       
   127    
       
   128     iActiveLmEvent->Start();
       
   129     
       
   130     /////////////////////////////////////////////
       
   131 	// Add three landmarks #1 #2 #3
       
   132 	/////////////////////////////////////////////
       
   133 	CPosLandmark* landmark = CPosLandmark::NewLC();
       
   134 	landmark->SetLandmarkNameL(_L("Zu Hause"));
       
   135 	CPosLandmark* landmark2 = CPosLandmark::NewLC();
       
   136 	landmark->SetLandmarkNameL(_L("Zu Hause jetzt"));
       
   137 	CPosLandmark* landmark3 = CPosLandmark::NewLC();
       
   138 	landmark->SetLandmarkNameL(_L("Nicht Zu Hause"));
       
   139 
       
   140     iActiveLmEvent->iLandmarkId = iDatabase->AddLandmarkL(*landmark);
       
   141 	iActiveLmEvent->iLandmarkId2 = iDatabase->AddLandmarkL(*landmark2);
       
   142 	iActiveLmEvent->iLandmarkId3 = iDatabase->AddLandmarkL(*landmark3);
       
   143 	
       
   144 	CleanupStack::PopAndDestroy(landmark3);
       
   145 	CleanupStack::PopAndDestroy(landmark2);
       
   146 	
       
   147 	/////////////////////////////////////////////
       
   148 	// Update landmark #4
       
   149 	/////////////////////////////////////////////
       
   150 	landmark->SetLandmarkNameL(_L("Nicht zu Hause"));
       
   151 	iDatabase->UpdateLandmarkL(*landmark);
       
   152 
       
   153 	/////////////////////////////////////////////
       
   154 	// Remove landmark #5
       
   155 	/////////////////////////////////////////////
       
   156 	iDatabase->RemoveLandmarkL(iActiveLmEvent->iLandmarkId);
       
   157 	
       
   158     CActiveScheduler::Start();
       
   159 
       
   160 	/////////////////////////////////////////////
       
   161 	// Add removed landmark again #6
       
   162 	/////////////////////////////////////////////
       
   163 	iActiveLmEvent->iLandmarkId4 = iDatabase->AddLandmarkL(*landmark);
       
   164 	CleanupStack::PopAndDestroy(landmark);
       
   165 
       
   166     CActiveScheduler::Start();
       
   167 	/////////////////////////////////////////////
       
   168 	// Remove a set of landmarks sync  #7
       
   169 	/////////////////////////////////////////////
       
   170 	RArray<TPosLmItemId> array;
       
   171     CleanupClosePushL(array);    
       
   172     User::LeaveIfError(array.Append(iActiveLmEvent->iLandmarkId));
       
   173 	User::LeaveIfError(array.Append(iActiveLmEvent->iLandmarkId2));
       
   174 	User::LeaveIfError(array.Append(iActiveLmEvent->iLandmarkId3));
       
   175     ExecuteAndDeleteLD(iDatabase->RemoveLandmarksL(array));
       
   176     
       
   177 	//array.Reset();
       
   178 	
       
   179 	CleanupStack::PopAndDestroy(&array); 
       
   180     
       
   181     CActiveScheduler::Start();
       
   182 	/////////////////////////////////////////////
       
   183 	// Add new category #8
       
   184 	/////////////////////////////////////////////
       
   185 	CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); 
       
   186     CleanupStack::PushL(categoryManager);
       
   187     
       
   188     CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC();
       
   189     category->SetCategoryNameL(_L("My Category"));
       
   190     
       
   191     iActiveLmEvent->iCategoryId = categoryManager->AddCategoryL(*category); 
       
   192 	
       
   193     AssertTrueSecL(iActiveLmEvent->iCategoryId == category->CategoryId(), _L("CATEGORY ERROR"));
       
   194     
       
   195 	/////////////////////////////////////////////
       
   196 	// Update category #9
       
   197 	/////////////////////////////////////////////
       
   198 	categoryManager->UpdateCategoryL(*category);
       
   199 
       
   200 	/////////////////////////////////////////////
       
   201 	// Delete a non-existing category #10
       
   202 	/////////////////////////////////////////////
       
   203 	iActiveLmEvent->iNonExistingCategoryId = 998;
       
   204 	ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(iActiveLmEvent->iNonExistingCategoryId));
       
   205 	
       
   206     /////////////////////////////////////////////
       
   207 	// Delete a category that exists in several landmarks #11
       
   208 	/////////////////////////////////////////////
       
   209 	ExecuteAndDeleteLD(categoryManager->RemoveCategoryL(iActiveLmEvent->iDeleteCategoryId));
       
   210 	
       
   211     CActiveScheduler::Start();
       
   212 	/////////////////////////////////////////////
       
   213 	// Delete several categories
       
   214 	/////////////////////////////////////////////
       
   215 	CPosLmItemIterator* iter = categoryManager->CategoryIteratorL();
       
   216     CleanupStack::PushL(iter);
       
   217 	const TInt startIndex=1;
       
   218     const TInt numOfItems=5;
       
   219     RArray<TPosLmItemId> ids;
       
   220     CleanupClosePushL(ids);
       
   221     iter->GetItemIdsL(ids, startIndex, numOfItems);    
       
   222 	ExecuteAndDeleteLD(categoryManager->RemoveCategoriesL(ids));
       
   223 	
       
   224 	CleanupStack::PopAndDestroy(2, iter); //ids
       
   225     
       
   226     CActiveScheduler::Start();
       
   227 	/////////////////////////////////////////////
       
   228 	// Add new category to several landmarks
       
   229 	/////////////////////////////////////////////
       
   230 	CPosLandmarkCategory* newCategory = CPosLandmarkCategory::NewLC();
       
   231     newCategory->SetCategoryNameL(_L("My New Category"));
       
   232     iActiveLmEvent->iCategoryId2= categoryManager->AddCategoryL(*newCategory); 
       
   233 	CleanupStack::PopAndDestroy(newCategory);
       
   234 	
       
   235 	iter = iDatabase->LandmarkIteratorL();
       
   236 	CleanupStack::PushL(iter);
       
   237 	const TInt addStartIndex=5;
       
   238     const TInt addNumOfItems=7;
       
   239     CleanupClosePushL(ids);
       
   240     iter->GetItemIdsL(ids, addStartIndex, addNumOfItems);   
       
   241 
       
   242 	ExecuteAndDeleteLD(categoryManager->AddCategoryToLandmarksL(iActiveLmEvent->iCategoryId2, ids));
       
   243     
       
   244     CActiveScheduler::Start();
       
   245     /////////////////////////////////////////////
       
   246 	// Delete a category in several landmarks
       
   247 	/////////////////////////////////////////////
       
   248 	ExecuteAndDeleteLD(categoryManager->RemoveCategoryFromLandmarksL(iActiveLmEvent->iCategoryId2, ids));
       
   249 
       
   250 	CleanupStack::PopAndDestroy(4, categoryManager); // iter, ids, category
       
   251 
       
   252      CActiveScheduler::Start();
       
   253 	/////////////////////////////////////////////
       
   254 	// Remove all landmarks
       
   255 	/////////////////////////////////////////////
       
   256 	ExecuteAndDeleteLD(iDatabase->RemoveAllLandmarksL());
       
   257 
       
   258 	CActiveScheduler::Start(); // For notifier
       
   259 	
       
   260     }
       
   261 
       
   262 // ---------------------------------------------------------
       
   263 // CPosTp28::LandmarkEventQueueTest
       
   264 //
       
   265 // (other items were commented in a header).
       
   266 // ---------------------------------------------------------
       
   267 //
       
   268 void CPosTp28::LandmarkEventQueueTest()
       
   269     {
       
   270     
       
   271     TInt i=0;
       
   272     iActiveLmEvent->iQueueTest = ETrue;
       
   273     iActiveLmEvent->Start();
       
   274 
       
   275     /////////////////////////////////////////////
       
   276 	// Add one landmark #1
       
   277     //////////////////////////////////////////////
       
   278   
       
   279     CPosLandmark* landmark = CPosLandmark::NewLC();
       
   280     landmark->SetLandmarkNameL(_L("TP28 event queue"));  
       
   281     iActiveLmEvent->iLandmarkId = iDatabase->AddLandmarkL(*landmark);
       
   282     CleanupStack::PopAndDestroy(landmark);
       
   283     CActiveScheduler::Start();
       
   284 
       
   285     /////////////////////////////////////////////
       
   286 	// Add 6 landmarks #2
       
   287     /////////////////////////////////////////////
       
   288     _LIT(KLmName, "LmTP28");
       
   289     for (i=0; i <= KMaxQueueSize; i++)
       
   290         {
       
   291         CPosLandmark* landmark = CPosLandmark::NewLC();
       
   292         landmark->SetLandmarkNameL(KLmName);  
       
   293         iDatabase->AddLandmarkL(*landmark);
       
   294         CleanupStack::PopAndDestroy(landmark); 
       
   295         }
       
   296     
       
   297     iActiveLmEvent->Start();
       
   298     CActiveScheduler::Start();
       
   299  
       
   300     /////////////////////////////////////////////
       
   301 	// Updates landmark 6 times #3
       
   302     /////////////////////////////////////////////
       
   303     for (i=0; i <= KMaxQueueSize; i++)
       
   304         {
       
   305         CPosLandmark* landmark = iDatabase->ReadLandmarkLC(iActiveLmEvent->iLandmarkId);   
       
   306         iDatabase->UpdateLandmarkL(*landmark);
       
   307         CleanupStack::PopAndDestroy(landmark);
       
   308         }
       
   309     
       
   310     iActiveLmEvent->Start();
       
   311     CActiveScheduler::Start();
       
   312     
       
   313     /////////////////////////////////////////////
       
   314 	// Add 3 landmarks and 3 categories #4, #5 #6 #7 
       
   315     /////////////////////////////////////////////
       
   316     
       
   317     for (i=0; i < 3; i++)
       
   318         {
       
   319         CPosLandmark* landmark = CPosLandmark::NewLC();
       
   320         landmark->SetLandmarkNameL(KLmName);  
       
   321         iDatabase->AddLandmarkL(*landmark);
       
   322         CleanupStack::PopAndDestroy(landmark); 
       
   323         }
       
   324     
       
   325     _LIT(KCategoryName, "TP28 Category %d");
       
   326     for (i =0; i < 3; i++)
       
   327         {
       
   328         TBuf<100> name;
       
   329         name.Format(KCategoryName, i);
       
   330         CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC();
       
   331         category->SetCategoryNameL(name);
       
   332         if (i == 0)
       
   333             {
       
   334             iActiveLmEvent->iCategoryId = iCategoryManager->AddCategoryL(*category); 
       
   335             }
       
   336         else
       
   337             {
       
   338             iCategoryManager->AddCategoryL(*category); 
       
   339             }
       
   340         CleanupStack::PopAndDestroy(category); 
       
   341         }
       
   342     
       
   343    
       
   344     iActiveLmEvent->Start();
       
   345     CActiveScheduler::Start();
       
   346   
       
   347     }
       
   348 
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // CActiveLmEvent::NewL
       
   352 //
       
   353 //(other items were commented in a header).
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 CActiveLmEvent* CActiveLmEvent::NewL(CStifLogger* aLog)
       
   357     {
       
   358     CActiveLmEvent* self = new(ELeave) CActiveLmEvent(aLog);
       
   359     CleanupStack::PushL(self);
       
   360     self->ConstructL();
       
   361     CleanupStack::Pop();
       
   362     return self;
       
   363     }
       
   364 
       
   365 // -----------------------------------------------------------------------------
       
   366 // CActiveLmEvent::ConstructL
       
   367 //
       
   368 //(other items were commented in a header).
       
   369 // -----------------------------------------------------------------------------
       
   370 //
       
   371 void CActiveLmEvent::ConstructL()
       
   372     {
       
   373     iDatabase = CPosLandmarkDatabase::OpenL();
       
   374     }
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // CActiveLmEvent::CActiveLmEvent
       
   378 // C++ default constructor can NOT contain any code, that
       
   379 // might leave.
       
   380 // -----------------------------------------------------------------------------
       
   381 //
       
   382 
       
   383 CActiveLmEvent::CActiveLmEvent(CStifLogger* aLog) : 
       
   384     CActive(EPriorityNormal),
       
   385     iLog(aLog)
       
   386     {   
       
   387     CActiveScheduler::Add(this);
       
   388     }
       
   389 
       
   390 // Destructor
       
   391 CActiveLmEvent::~CActiveLmEvent()
       
   392     {
       
   393     Cancel();
       
   394     delete iDatabase;
       
   395     iDatabase = NULL;
       
   396     }
       
   397 
       
   398 // ---------------------------------------------------------
       
   399 // CActiveLmEvent::StartL
       
   400 //
       
   401 // (other items were commented in a header).
       
   402 // ---------------------------------------------------------
       
   403 //
       
   404 void CActiveLmEvent::Start()                          
       
   405     {
       
   406     iDatabase->NotifyDatabaseEvent(iEvent, iStatus); 
       
   407  
       
   408     SetActive();
       
   409     }   
       
   410 
       
   411 // ---------------------------------------------------------
       
   412 // CActiveLmEvent::RunL
       
   413 //
       
   414 // (other items were commented in a header).
       
   415 // ---------------------------------------------------------
       
   416 //
       
   417 void CActiveLmEvent::RunL()
       
   418     {  
       
   419     
       
   420     if (iQueueTest)
       
   421         {
       
   422         VerifyMergedEvent();
       
   423         }
       
   424     else
       
   425         {
       
   426         VerifyEvent();
       
   427         }
       
   428 
       
   429     if (!iQueueTest)
       
   430         {
       
   431         iDatabase->NotifyDatabaseEvent(iEvent, iStatus); 
       
   432         SetActive();
       
   433         }
       
   434     }
       
   435 
       
   436 // ---------------------------------------------------------
       
   437 // CActiveLmOperation::DoCancel
       
   438 //
       
   439 // (other items were commented in a header).
       
   440 // ---------------------------------------------------------
       
   441 //
       
   442 void CActiveLmEvent::DoCancel()
       
   443     {
       
   444     iDatabase->CancelNotifyDatabaseEvent();
       
   445     }
       
   446 
       
   447 // ---------------------------------------------------------
       
   448 // CActiveLmEvent::VerifyEvent
       
   449 //
       
   450 // (other items were commented in a header).
       
   451 // ---------------------------------------------------------
       
   452 //
       
   453 void CActiveLmEvent::VerifyEvent()
       
   454     {
       
   455    
       
   456     iEventNumber++;
       
   457 	switch (iEventNumber)
       
   458 		{
       
   459 					// Added three landmarks
       
   460 		case 1:		AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, iLandmarkId, iEvent.iLandmarkItemId); 
       
   461 					break;
       
   462 		case 2:		AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, iLandmarkId2, iEvent.iLandmarkItemId); 
       
   463 					break;
       
   464 		case 3:		AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, iLandmarkId3, iEvent.iLandmarkItemId); 
       
   465 					break;
       
   466 					// Updated landmark
       
   467 		case 4:		AssertCorrectEvent(EPosLmEventLandmarkUpdated, iEvent.iEventType, iLandmarkId, iEvent.iLandmarkItemId); 
       
   468 					break;
       
   469 					// Deleted landmark
       
   470 		case 5:		AssertCorrectEvent(EPosLmEventLandmarkDeleted, iEvent.iEventType, iLandmarkId, iEvent.iLandmarkItemId); 
       
   471 				    CActiveScheduler::Stop();
       
   472                     break;
       
   473 					// Added removed landmark again
       
   474 		case 6:		AssertCorrectEvent(EPosLmEventLandmarkCreated, iEvent.iEventType, iLandmarkId4, iEvent.iLandmarkItemId); 
       
   475                     CActiveScheduler::Stop();
       
   476 					break;
       
   477 					// Deleted several landmarks
       
   478 		case 7:		AssertCorrectEvent(EPosLmEventLandmarkUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); 
       
   479 					CActiveScheduler::Stop();
       
   480                     break;
       
   481 					// Added new category
       
   482 		case 8:		AssertCorrectEvent(EPosLmEventCategoryCreated, iEvent.iEventType, iCategoryId, iEvent.iLandmarkItemId); 
       
   483 					break;
       
   484 					//Updated category
       
   485 		case 9:		AssertCorrectEvent(EPosLmEventCategoryUpdated, iEvent.iEventType, iCategoryId, iEvent.iLandmarkItemId); 
       
   486 					break;
       
   487 					// Deleted non existing category
       
   488 		case 10:	AssertCorrectEvent(EPosLmEventCategoryDeleted, iEvent.iEventType, iNonExistingCategoryId, iEvent.iLandmarkItemId); 
       
   489 					break;
       
   490 					// Deleted existing category
       
   491 		case 11:	AssertCorrectEvent(EPosLmEventCategoryDeleted, iEvent.iEventType, iDeleteCategoryId, iEvent.iLandmarkItemId); 
       
   492 					CActiveScheduler::Stop();
       
   493                     break;
       
   494 					// Deleted several categories
       
   495 		case 12:	AssertCorrectEvent(EPosLmEventCategoryUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); 
       
   496 					CActiveScheduler::Stop();
       
   497                     break;
       
   498 					// Added new category
       
   499 		case 13:	AssertCorrectEvent(EPosLmEventCategoryCreated, iEvent.iEventType, iCategoryId2, iEvent.iLandmarkItemId); 
       
   500 					break;
       
   501 					// Added created category to several landmarks
       
   502 		case 14:	AssertCorrectEvent(EPosLmEventLandmarkUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); 
       
   503 					CActiveScheduler::Stop();
       
   504                     break;
       
   505 					// Removed category from several landmarks
       
   506 		case 15:	AssertCorrectEvent(EPosLmEventLandmarkUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); 
       
   507 					CActiveScheduler::Stop();
       
   508                     break;
       
   509 					// Removed all landmarks
       
   510 		case 16:	AssertCorrectEvent(EPosLmEventLandmarkUnknownChanges, iEvent.iEventType, 0, iEvent.iLandmarkItemId); 
       
   511 					CActiveScheduler::Stop();				
       
   512 					break;
       
   513 		default: 
       
   514             iLog->Log(_L("Unexpected event received"));
       
   515             ++iGlobalErr;
       
   516             break;
       
   517         }
       
   518     	
       
   519     }
       
   520 
       
   521 //---------------------------------------------------------
       
   522 // CActiveLmEvent::VerifyMergedEvent
       
   523 //
       
   524 // (other items were commented in a header).
       
   525 // ---------------------------------------------------------
       
   526 //
       
   527 void CActiveLmEvent::VerifyMergedEvent()
       
   528     {
       
   529     ++iMergedEventNumber;    
       
   530     switch (iMergedEventNumber)
       
   531 		{
       
   532         case 1:
       
   533             AssertCorrectEvent(
       
   534                             EPosLmEventLandmarkCreated, 
       
   535                             iEvent.iEventType, 
       
   536                             iLandmarkId, 
       
   537                             iEvent.iLandmarkItemId);
       
   538             
       
   539             CActiveScheduler::Stop();
       
   540 			break;
       
   541 		case 2:
       
   542         case 3:
       
   543             AssertCorrectEvent(
       
   544                             EPosLmEventLandmarkUnknownChanges, 
       
   545                             iEvent.iEventType, 
       
   546                             0, 
       
   547                             iEvent.iLandmarkItemId); 
       
   548             
       
   549             CActiveScheduler::Stop();
       
   550 			break;
       
   551         case 4:
       
   552             AssertCorrectEvent(
       
   553                             EPosLmEventLandmarkUnknownChanges, 
       
   554                             iEvent.iEventType, 
       
   555                             0, 
       
   556                             iEvent.iLandmarkItemId); 
       
   557             Start();
       
   558             break;
       
   559         case 5:
       
   560         case 6:
       
   561         case 7:
       
   562             AssertCorrectEvent(EPosLmEventCategoryCreated,
       
   563                             iEvent.iEventType, 
       
   564                             iCategoryId++, 
       
   565                             iEvent.iLandmarkItemId);
       
   566            
       
   567             if (iMergedEventNumber == 7)   
       
   568                 {
       
   569                 CActiveScheduler::Stop();
       
   570                 }
       
   571             else
       
   572                 {
       
   573                 Start();
       
   574                 }
       
   575 			break;
       
   576         default: 
       
   577             _LIT(KError,"Unexpected event received, %d\r\n");
       
   578 		    TBuf<200> error;
       
   579 		    error.Format(KError, iEvent.iEventType);
       
   580 		    iLog->Log(error);
       
   581 		    iGlobalErr++;
       
   582             Start();
       
   583             break;
       
   584         }
       
   585     }
       
   586 
       
   587 // ---------------------------------------------------------
       
   588 // CActiveLmEvent::AssertCorrectEvent
       
   589 //
       
   590 // (other items were commented in a header).
       
   591 // ---------------------------------------------------------
       
   592 //
       
   593 void CActiveLmEvent::AssertCorrectEvent(
       
   594 	TPosLmEventType  aExpectedEventType,
       
   595 	TPosLmEventType  aEventType,
       
   596 	TPosLmItemId aExpectedLandMarkItemId,
       
   597 	TPosLmItemId aLandMarkItemId)
       
   598 	{
       
   599 	if (aExpectedEventType != aEventType)
       
   600 		{
       
   601 		_LIT(KError,"Unexpected eventtype. Excpected %d got %d\r\n");
       
   602 		TBuf<200> error;
       
   603 		error.Format(KError, aExpectedEventType, aEventType);
       
   604 		iLog->Log(error);
       
   605 		iGlobalErr++;
       
   606 		}
       
   607 	if (aExpectedLandMarkItemId != aLandMarkItemId)
       
   608 		{
       
   609 		_LIT(KError,"Unexpected item id. Excpected %d got %d\r\n");
       
   610 		TBuf<200> error;
       
   611 		error.Format(KError, aExpectedLandMarkItemId, aLandMarkItemId);
       
   612 		iLog->Log(error);
       
   613 		iGlobalErr++;
       
   614 		}
       
   615 
       
   616 	}
       
   617 
       
   618 
       
   619 // End of file
       
   620