landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp132.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 
       
    22 #include "FT_CPosTp132.h"
       
    23 #include <EPos_CPosLandmarkDatabase.h>
       
    24 #include <EPos_CPosLandmarkSearch.h>
       
    25 #include <EPos_CPosLmTextCriteria.h>
       
    26 #include <EPos_CPosLMItemIterator.h>
       
    27 #include <EPos_CPosLmDisplayData.h>
       
    28 #include <EPos_CPosLmDisplayItem.h>
       
    29 #include <EPos_TPosLMSortPref.h>
       
    30 #include <EPos_CPosLmCatNameCriteria.h>
       
    31 
       
    32 #include <EPos_CPosLmMultiDbSearch.h>
       
    33 
       
    34 #include <e32std.h>
       
    35 
       
    36 // CONSTANTS
       
    37 //EPosLmServer
       
    38 _LIT(KPosLandmarksServerName, "*eposlmserver*");
       
    39 
       
    40 // ================= MEMBER FUNCTIONS =======================
       
    41 
       
    42 // ---------------------------------------------------------
       
    43 // CPosTp132::StartL
       
    44 //
       
    45 // (other items were commented in a header).
       
    46 // ---------------------------------------------------------
       
    47 //
       
    48 void CPosTp132::StartL()
       
    49     {
       
    50     MakeSurePanicDebugFileExistsL();
       
    51     
       
    52     iUseLogFromThreadIsDisabled = ETrue;
       
    53 
       
    54     RemoveDefaultDbL();
       
    55 	RemoveAllLmDatabasesL();
       
    56 	
       
    57 	iErrorsFound = KErrNone;
       
    58 	
       
    59 	// Use multiple db
       
    60 	_LIT(KDb20, "EPOSLM_020.LDB");
       
    61     _LIT(KDb40, "EPOSLM_040.LDB");
       
    62     _LIT(KDb60, "EPOSLM_060.LDB");
       
    63     _LIT(KDb80, "EPOSLM_080.LDB");
       
    64     _LIT(KDb105, "EPOSLM_105.LDB");
       
    65     
       
    66     // Copy to secure area
       
    67     
       
    68     CopyTestDbFileL(KDb20);
       
    69     CopyTestDbFileL(KDb40);
       
    70     CopyTestDbFileL(KDb60);
       
    71     CopyTestDbFileL(KDb80);
       
    72     CopyTestDbFileL(KDb105);
       
    73 	
       
    74     iDatabase = UseGeneratedDbFileL();
       
    75 
       
    76     if (iDatabase->IsInitializingNeeded())
       
    77        {
       
    78        ExecuteAndDeleteLD(iDatabase->InitializeL());
       
    79        }
       
    80 
       
    81     // <<<<<<<<<<<<<<Panic testing below>>>>>>>>>>>>>>>>>>>
       
    82     iLog->Log(_L(">>>>>>>Start Panic test<<<<<<<<<"));
       
    83    
       
    84     //	1 Try to get item from DisplayData::DisplayItem outside accepted interval
       
    85     // Should panic with EPosInvalidIndex
       
    86     iExpectedExitType = ExitPanic;
       
    87     iLog->Log(_L("Panic test 1"));
       
    88     iTestCase = 1;
       
    89     iExpectedErrorCode = EPosInvalidIndex;
       
    90     ResumeThreadAndVerifyExit();
       
    91     
       
    92 	//	2 Try to get item from DisplayData::DisplayItem outside accepted interval
       
    93     // Should panic with EPosInvalidIndex
       
    94     iExpectedExitType = ExitPanic;
       
    95     iLog->Log(_L("Panic test 2"));
       
    96     iTestCase = 2;
       
    97     iExpectedErrorCode = EPosInvalidIndex;
       
    98     ResumeThreadAndVerifyExit();
       
    99 
       
   100     // 3 Set displaydata during search, should panic with EPosSearchOperationInUse
       
   101     iExpectedExitType = ExitPanic;
       
   102     iLog->Log(_L("Panic test 3"));
       
   103     iTestCase = 3;
       
   104     iExpectedErrorCode = EPosSearchOperationInUse;
       
   105     ResumeThreadAndVerifyExit();
       
   106     
       
   107     // 4 Unset displaydata during search, should panic with EPosSearchOperationInUse
       
   108     iExpectedExitType = ExitPanic;
       
   109     iLog->Log(_L("Panic test 4"));
       
   110     iTestCase = 4;
       
   111     iExpectedErrorCode = EPosSearchOperationInUse;
       
   112     ResumeThreadAndVerifyExit();
       
   113     
       
   114     // 5 Unset displaydata during search, should panic with EPosSearchOperationInUse
       
   115     iExpectedExitType = ExitPanic;
       
   116     iLog->Log(_L("Panic test 5"));
       
   117     iTestCase = 5;
       
   118     iExpectedErrorCode = EPosSearchOperationInUse;
       
   119     ResumeThreadAndVerifyExit();
       
   120 
       
   121 	// Nothing seems to happen, no leave or no panic
       
   122     // 6 NULL check, try to set DisplayData as NULL
       
   123     iExpectedExitType = ExitNormal;
       
   124     iLog->Log(_L("Panic test 6"));
       
   125     iTestCase = 6;
       
   126     iExpectedErrorCode = KErrNone;
       
   127     ResumeThreadAndVerifyExit();
       
   128     
       
   129     // 7 Delete displaydata during search -> "may lead to unexpected errors"
       
   130     // For some reason it panics with Kern-Exec 3
       
   131     /* Excerpt from EPos_CPosLandmarkSearch.h
       
   132      * The client owns the display data object. If the client deletes it
       
   133      * during a search, this may lead to unexpected errors. The client must
       
   134      * call @ref UnsetDisplayData before it deletes the display data object.
       
   135      */
       
   136     iExpectedExitType = ExitPanic;
       
   137     iLog->Log(_L("Panic test 7"));
       
   138     iTestCase = 7;
       
   139     //iExpectedErrorCode = KErrNone;
       
   140     iExpectedErrorCode = 3; // Kern-Exec 3
       
   141     ResumeThreadAndVerifyExit();
       
   142     
       
   143     // Test multi db search below
       
   144     // 8) Set displaydata during search, should panic with EPosSearchOperationInUse
       
   145     iExpectedExitType = ExitPanic;
       
   146     iLog->Log(_L("Panic test 8"));
       
   147     iTestCase = 8;
       
   148     iExpectedErrorCode = EPosSearchOperationInUse;
       
   149     ResumeThreadAndVerifyExit();
       
   150     
       
   151     // 9)  Unset displaydata during search, should panic with EPosSearchOperationInUse
       
   152     iExpectedExitType = ExitPanic;
       
   153     iLog->Log(_L("Panic test 9"));
       
   154     iTestCase = 9;
       
   155     iExpectedErrorCode = EPosSearchOperationInUse;
       
   156     ResumeThreadAndVerifyExit();
       
   157     
       
   158     // 10) Unset displaydata during search, should panic with EPosSearchOperationInUse
       
   159     iExpectedExitType = ExitPanic;
       
   160     iLog->Log(_L("Panic test 10"));
       
   161     iTestCase = 10;
       
   162     iExpectedErrorCode = EPosSearchOperationInUse;
       
   163     ResumeThreadAndVerifyExit();
       
   164     
       
   165     // 11 Delete displaydata during search -> "may lead to unexpected errors"
       
   166     /* The client owns the display data object. If the client deletes it
       
   167     * during a search, this may lead to unexpected errors. The client must
       
   168     * call @ref UnsetDisplayData before it deletes the display data object.
       
   169     */
       
   170     // For some reason it panics with Kern-Exec 3
       
   171     iExpectedExitType = ExitPanic;
       
   172     iLog->Log(_L("Panic test 11"));
       
   173     iTestCase = 11;
       
   174     iExpectedErrorCode = 3; //3 Kern-Exec 3
       
   175     ResumeThreadAndVerifyExit();
       
   176     
       
   177     // 12) Use the CPosLmDisplayItem::Category() function on a Landmark item
       
   178     // Should panic with EPosInvalidItemType
       
   179     iExpectedExitType = ExitPanic;
       
   180     iLog->Log(_L("Panic test 12"));
       
   181     iTestCase = 12;
       
   182     iExpectedErrorCode = EPosInvalidItemType;
       
   183     ResumeThreadAndVerifyExit();
       
   184     
       
   185     // 13) Use the CPosLmDisplayItem::Landmark() function on a Category item
       
   186     // Should panic with EPosInvalidItemType
       
   187     iExpectedExitType = ExitPanic;
       
   188     iLog->Log(_L("Panic test 13"));
       
   189     iTestCase = 13;
       
   190     iExpectedErrorCode = EPosInvalidItemType;
       
   191     ResumeThreadAndVerifyExit();
       
   192     
       
   193     // 14) Set DisplayData to NULL and do multipledb search
       
   194     // Nothing seems to happen, everything is OK
       
   195     iExpectedExitType = ExitNormal;
       
   196     iLog->Log(_L("Panic test 14"));
       
   197     iTestCase = 14;
       
   198     iExpectedErrorCode = KErrNone;
       
   199     ResumeThreadAndVerifyExit();
       
   200     
       
   201     if (iErrorsFound != KErrNone) 
       
   202     {
       
   203         iLog->Log(_L("TP132 Failed"));
       
   204         User::Leave(-1);
       
   205     }
       
   206     iLog->Log(_L(">>>>>>>Panic test Done<<<<<<<<<"));
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------
       
   210 // CPosTp132::ResumeThreadAndVerifyExit
       
   211 //
       
   212 // (other items were commented in a header).
       
   213 // ---------------------------------------------------------
       
   214 //
       
   215 void CPosTp132::ResumeThreadAndVerifyExit()
       
   216     {
       
   217     iLog->Log(_L("ResumeThreadAndVerifyExit"));
       
   218     _LIT(KPanicErr, "Err: Method didn't Panic when expected"); 
       
   219     _LIT(KPanicCodeErr, "Err: Paniced with unexpected panic code");
       
   220     _LIT(KLeaveErr, "Err: Method didn't end correctly"); 
       
   221     _LIT(KLeaveCodeErr, "Err: Unexpected leave error");
       
   222 
       
   223     CreateThreadL();
       
   224     TRequestStatus status;
       
   225     iThread.Logon(status);
       
   226     iThread.Resume();
       
   227         
       
   228     User::WaitForRequest(status);
       
   229     
       
   230     // Used for debugging
       
   231     TBuf<100> buf;
       
   232     buf.Format(_L("ExitType %d Exit reason %d "), iThread.ExitType(), iThread.ExitReason());
       
   233     iLog->Log(buf);
       
   234     
       
   235     TExitCategoryName buf1;
       
   236     buf1=iThread.ExitCategory();
       
   237     iLog->Log(buf1);
       
   238 
       
   239     if (iExpectedExitType == ExitPanic)
       
   240         {
       
   241         
       
   242         if (iThread.ExitType() != EExitPanic)
       
   243         {iErrorsFound++;iLog->Log(KPanicErr);}
       
   244         
       
   245         if(iTestCase != 11)
       
   246         {
       
   247         if (iThread.ExitReason() != iExpectedErrorCode)
       
   248         {iErrorsFound++;iLog->Log(KPanicCodeErr);}	
       
   249         }
       
   250         
       
   251         }
       
   252     else if (iExpectedExitType == ExitLeave)
       
   253         {
       
   254         
       
   255         if (iThread.ExitType() != EExitKill)
       
   256         {iErrorsFound++;iLog->Log(KLeaveErr);}
       
   257         
       
   258         if (iThread.ExitReason() != iExpectedErrorCode)
       
   259         {iErrorsFound++;iLog->Log(KLeaveCodeErr);}
       
   260         }
       
   261 	else if (iExpectedExitType == ExitNormal)
       
   262         {
       
   263         
       
   264         if (iThread.ExitType() != KErrNone)
       
   265         {iErrorsFound++;iLog->Log(KLeaveErr);}
       
   266         
       
   267         if (iThread.ExitReason() != iExpectedErrorCode)
       
   268         {iErrorsFound++;iLog->Log(KLeaveCodeErr);}
       
   269         }        
       
   270         
       
   271     iThread.Close();
       
   272     
       
   273     TBool alive = ServerAlive(KPosLandmarksServerName);
       
   274     if (!alive)
       
   275         {
       
   276         iLog->Log(_L("Landmarks Server is not alive"));
       
   277         User::Leave(-1);
       
   278 
       
   279         }
       
   280     }
       
   281 
       
   282 // ---------------------------------------------------------
       
   283 // CPosTp132::CloseTest
       
   284 //
       
   285 // (other items were commented in a header).
       
   286 // ---------------------------------------------------------
       
   287 //
       
   288 void CPosTp132::CloseTest()
       
   289     {
       
   290     iLog->Log(_L("CloseTest"));
       
   291     iThread.Close();
       
   292 
       
   293     delete iDatabase;
       
   294     iDatabase = NULL;
       
   295 
       
   296     iLog->Log(_L("CloseTest Done"));
       
   297 	}
       
   298 	
       
   299 // ---------------------------------------------------------
       
   300 // CPosTp132::UnsetTest
       
   301 //
       
   302 // (other items were commented in a header).
       
   303 // ---------------------------------------------------------
       
   304 //	
       
   305 TInt CPosTp132::UnsetTest(TAny* aSelf)
       
   306 	{
       
   307 	CPosLandmarkSearch* aLmSearch = static_cast<CPosLandmarkSearch*>(aSelf);
       
   308 	aLmSearch->UnsetDisplayData();
       
   309 	return 0;
       
   310 	}
       
   311 	
       
   312 // ---------------------------------------------------------
       
   313 // CPosTp132::UnsetMultiSearch
       
   314 //
       
   315 // (other items were commented in a header).
       
   316 // ---------------------------------------------------------
       
   317 //	
       
   318 TInt CPosTp132::UnsetMultiSearch(TAny* aSelf)
       
   319 	{
       
   320 	CPosLmMultiDbSearch* aLmSearch = static_cast<CPosLmMultiDbSearch*>(aSelf);
       
   321 	aLmSearch->UnsetDisplayData();
       
   322 	return 0;
       
   323 	}
       
   324 		
       
   325 // ---------------------------------------------------------
       
   326 // CPosTp132::RunPanicTestL
       
   327 //
       
   328 // (other items were commented in a header).
       
   329 // ---------------------------------------------------------
       
   330 //
       
   331 void CPosTp132::RunPanicTestL(TAny* aData)
       
   332     {
       
   333     CPosTp132* self = reinterpret_cast<CPosTp132*>(aData);
       
   334 
       
   335 	CPosLandmarkDatabase* database = self->OpenDatabaseLC();
       
   336 	CPosLandmarkSearch* lmSearch = CPosLandmarkSearch::NewL(*database);
       
   337 	CleanupStack::PushL(lmSearch);
       
   338 	
       
   339     CDesCArray* dbUris = new (ELeave) CDesC16ArrayFlat(2);
       
   340 	CleanupStack::PushL(dbUris);
       
   341 
       
   342  	_LIT(KDb20, "c:EPOSLM_020.LDB");
       
   343 	_LIT(KDb40, "c:EPOSLM_040.LDB");
       
   344 	
       
   345 	dbUris->AppendL(KDb20);
       
   346 	dbUris->AppendL(KDb40);
       
   347 
       
   348      if (self->iTestCase == 1 || self->iTestCase == 2)
       
   349      	{
       
   350         TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending);  
       
   351     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();
       
   352     
       
   353     	// Set DisplayData
       
   354 		CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   355 		CleanupStack::PushL(displayData);
       
   356     	lmSearch->SetDisplayData(*displayData);
       
   357     	
       
   358     	textCriteria->SetTextL(_L("*"));
       
   359     	
       
   360 		CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse);
       
   361 		ExecuteAndDeleteLD(operation);
       
   362 		operation = NULL;
       
   363 
       
   364 		// Outside accepted interval, should Panic with EPosInvalidIndex		
       
   365 		if (self->iTestCase == 1)
       
   366 			{
       
   367         	CPosLmDisplayItem& item = displayData->DisplayItem(displayData->Count());
       
   368         	}
       
   369         else if (self->iTestCase == 2)
       
   370         	{
       
   371         	CPosLmDisplayItem& item = displayData->DisplayItem(-1);
       
   372         	}
       
   373         	
       
   374         	lmSearch->UnsetDisplayData();
       
   375         	CleanupStack::PopAndDestroy(displayData);
       
   376         	
       
   377         }
       
   378      else if (self->iTestCase == 3)
       
   379      	{
       
   380      	// Set displaydata during search, should panic with EPosSearchOperationInUse
       
   381      	TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending);  
       
   382     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();
       
   383     
       
   384     	// Set DisplayData    	
       
   385     	textCriteria->SetTextL(_L("*"));
       
   386     	
       
   387 		CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse);
       
   388 		
       
   389 		CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   390 		CleanupStack::PushL(displayData);
       
   391     	lmSearch->SetDisplayData(*displayData);
       
   392     	
       
   393     	ExecuteAndDeleteLD(operation);
       
   394 		operation = NULL;
       
   395     	
       
   396     	lmSearch->UnsetDisplayData();
       
   397         CleanupStack::PopAndDestroy(displayData);
       
   398         CleanupStack::PopAndDestroy(textCriteria);
       
   399         }
       
   400      else if (self->iTestCase == 4)
       
   401      	{
       
   402      	// Unset displaydata during search, should panic with EPosSearchOperationInUse
       
   403     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();
       
   404     
       
   405     	// Set DisplayData    	
       
   406     	textCriteria->SetTextL(_L("*"));
       
   407     	CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   408 		CleanupStack::PushL(displayData);
       
   409     	lmSearch->SetDisplayData(*displayData);
       
   410     	
       
   411 		CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse);
       
   412 		lmSearch->UnsetDisplayData();    	
       
   413     	ExecuteAndDeleteLD(operation);
       
   414 		operation = NULL;
       
   415     	
       
   416     	lmSearch->UnsetDisplayData();
       
   417         CleanupStack::PopAndDestroy(displayData);
       
   418         CleanupStack::PopAndDestroy(textCriteria);
       
   419 
       
   420      }
       
   421      else if (self->iTestCase == 5)
       
   422      	{
       
   423      	// Unset displaydata during search, should panic with EPosSearchOperationInUse
       
   424     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();
       
   425     
       
   426     	// Set DisplayData    	
       
   427     	textCriteria->SetTextL(_L("*"));
       
   428     	CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   429 		CleanupStack::PushL(displayData);
       
   430     	lmSearch->SetDisplayData(*displayData);
       
   431     	
       
   432 		CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse);
       
   433     	// Unset displaydata in callback method
       
   434     	TCallBack callback(UnsetTest, lmSearch);
       
   435     	CPeriodic* periodicTimer = CPeriodic::NewL(CActive::EPriorityHigh);
       
   436     	CleanupStack::PushL(periodicTimer);
       
   437     	periodicTimer->Start(1, 1, callback);
       
   438     
       
   439     	self->RunAsyncOperationLD(operation);
       
   440 		operation = NULL;
       
   441 		
       
   442 		CPosLmItemIterator* iter = lmSearch->MatchIteratorL();	
       
   443 		TInt size = iter->NumOfItemsL();
       
   444     	
       
   445     	CleanupStack::PopAndDestroy(periodicTimer);
       
   446     	lmSearch->UnsetDisplayData();
       
   447         CleanupStack::PopAndDestroy(displayData);
       
   448         CleanupStack::PopAndDestroy(textCriteria);
       
   449 
       
   450      }     
       
   451      else if (self->iTestCase == 6)
       
   452      	{
       
   453      	// NULL check
       
   454     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();
       
   455     
       
   456     	// Set DisplayData    	
       
   457     	textCriteria->SetTextL(_L("*"));
       
   458     	CPosLmDisplayData* displayData = NULL;
       
   459     	lmSearch->SetDisplayData(*displayData);
       
   460     	
       
   461 		CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse);
       
   462     	ExecuteAndDeleteLD(operation);
       
   463 		operation = NULL;
       
   464 
       
   465 		CPosLmItemIterator* iter = lmSearch->MatchIteratorL();	
       
   466 		TInt size = iter->NumOfItemsL();
       
   467 		
       
   468 		lmSearch->UnsetDisplayData();
       
   469 		CleanupStack::PopAndDestroy(textCriteria);
       
   470      }
       
   471      else if (self->iTestCase == 7)
       
   472      	{
       
   473      	// Delete displaydata during search, "may lead to unexpected errors"
       
   474     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();
       
   475     
       
   476     	// Set DisplayData    	
       
   477     	textCriteria->SetTextL(_L("*"));
       
   478     	CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   479 		CleanupStack::PushL(displayData);
       
   480     	lmSearch->SetDisplayData(*displayData);
       
   481 
       
   482 		CPosLmOperation* operation = lmSearch->StartLandmarkSearchL(*textCriteria, EFalse);
       
   483 		
       
   484 		// Delete display data here
       
   485         CleanupStack::PopAndDestroy(displayData);
       
   486     	ExecuteAndDeleteLD(operation);
       
   487 		operation = NULL;
       
   488 
       
   489         CleanupStack::PopAndDestroy(textCriteria);
       
   490      	}
       
   491      else if (self->iTestCase == 8)
       
   492      	{
       
   493      	// Set displaydata during search, should panic with EPosSearchOperationInUse
       
   494      	CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris);
       
   495     	CleanupStack::PushL(multiSearcher);
       
   496     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();	
       
   497     	textCriteria->SetTextL(_L("*"));
       
   498     	CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse);
       
   499     	CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   500 		CleanupStack::PushL(displayData);
       
   501     	multiSearcher->SetDisplayData(*displayData);
       
   502     	ExecuteAndDeleteLD(operation);
       
   503 		operation = NULL;
       
   504     	CleanupStack::PopAndDestroy(displayData);
       
   505     	CleanupStack::PopAndDestroy(multiSearcher);
       
   506     	
       
   507     	}
       
   508     else if (self->iTestCase == 9)
       
   509      	{
       
   510     	// Unset displaydata during search, should panic with EPosSearchOperationInUse
       
   511      	CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris);
       
   512     	CleanupStack::PushL(multiSearcher);
       
   513     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();	
       
   514     	textCriteria->SetTextL(_L("*"));
       
   515     	
       
   516     	CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   517 		CleanupStack::PushL(displayData);
       
   518     	multiSearcher->SetDisplayData(*displayData);
       
   519     	    	
       
   520     	CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse);
       
   521 		multiSearcher->UnsetDisplayData();    	
       
   522     	ExecuteAndDeleteLD(operation);
       
   523 		operation = NULL;
       
   524 		
       
   525 		multiSearcher->UnsetDisplayData();
       
   526     	CleanupStack::PopAndDestroy(displayData);		
       
   527     	CleanupStack::PopAndDestroy(multiSearcher);
       
   528     	}
       
   529 	else if (self->iTestCase == 10)
       
   530      	{    	
       
   531      	// Unset displaydata during search, should panic with EPosSearchOperationInUse
       
   532      	// Unset displaydata in callback method
       
   533      	CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris);
       
   534     	CleanupStack::PushL(multiSearcher);
       
   535     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();	
       
   536     	textCriteria->SetTextL(_L("*"));
       
   537     	
       
   538     	CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   539 		CleanupStack::PushL(displayData);
       
   540     	multiSearcher->SetDisplayData(*displayData);
       
   541     	    	
       
   542     	CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse);
       
   543     	
       
   544     	TCallBack callback(UnsetMultiSearch, lmSearch);
       
   545     	CPeriodic* periodicTimer = CPeriodic::NewL(CActive::EPriorityHigh);
       
   546     	CleanupStack::PushL(periodicTimer);
       
   547     	periodicTimer->Start(1, 1, callback);
       
   548     	self->RunAsyncOperationLD(operation);
       
   549 		operation = NULL;
       
   550 		
       
   551 		ExecuteAndDeleteLD(operation);
       
   552 		multiSearcher->UnsetDisplayData();
       
   553     	CleanupStack::PopAndDestroy(displayData);		
       
   554     	CleanupStack::PopAndDestroy(multiSearcher);
       
   555      	}
       
   556 	else if (self->iTestCase == 11)
       
   557      	{  
       
   558      	// Delete displaydata during search, "may lead to unexpected errors"
       
   559      	CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris);
       
   560     	CleanupStack::PushL(multiSearcher);
       
   561     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();	
       
   562     	textCriteria->SetTextL(_L("*"));
       
   563     	CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   564     	multiSearcher->SetDisplayData(*displayData);
       
   565     	
       
   566     	CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse);
       
   567     	// Delete displaydata here
       
   568     	delete displayData;
       
   569     	
       
   570     	ExecuteAndDeleteLD(operation);
       
   571 		operation = NULL;
       
   572 
       
   573     	CleanupStack::PopAndDestroy(multiSearcher);
       
   574     	}
       
   575 	else if (self->iTestCase == 12)
       
   576      	{  
       
   577 		// Use the CPosLmDisplayItem::Category() function on a Landmark item
       
   578     	// Should panic with EPosInvalidItemType
       
   579      	CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris);
       
   580     	CleanupStack::PushL(multiSearcher);
       
   581     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();	
       
   582     	textCriteria->SetTextL(_L("*"));
       
   583     	CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   584     	multiSearcher->SetDisplayData(*displayData);
       
   585     	
       
   586     	CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse);    	
       
   587     	ExecuteAndDeleteLD(operation);
       
   588 		
       
   589 		// Verify that something was found
       
   590 		if (displayData->Count() < 2) User::Leave(-900);
       
   591 		
       
   592 		CPosLmDisplayItem& item = displayData->DisplayItem(0);
       
   593 	    TInt lmId = item.Landmark().LandmarkId();
       
   594 	    
       
   595 	    if (item.DisplayItemType() != CPosLmDisplayItem::ELandmarkItem) User::Leave(-901);
       
   596 		
       
   597 		// This call should panic
       
   598 		item.Category();
       
   599 		
       
   600 		multiSearcher->UnsetDisplayData();
       
   601     	CleanupStack::PopAndDestroy(displayData);
       
   602     	CleanupStack::PopAndDestroy(textCriteria);
       
   603     	CleanupStack::PopAndDestroy(multiSearcher);
       
   604     	}
       
   605 	else if (self->iTestCase == 13)
       
   606      	{  
       
   607 		// Use the CPosLmDisplayItem::Landmark() function on a Category item
       
   608     	// Should panic with EPosInvalidItemType
       
   609      	CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris);
       
   610     	CleanupStack::PushL(multiSearcher);
       
   611     	CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC();
       
   612     	nameCriteria->SetSearchPatternL(_L("*"));
       
   613     	
       
   614     	CPosLmDisplayData* displayData = CPosLmDisplayData::NewL();
       
   615     	multiSearcher->SetDisplayData(*displayData);
       
   616     	
       
   617     	CPosLmOperation* operation = multiSearcher->StartCategorySearchL(*nameCriteria, CPosLmCategoryManager::ECategorySortOrderNone);
       
   618     	ExecuteAndDeleteLD(operation);
       
   619 		
       
   620 		// Verify that something was found
       
   621 		if (displayData->Count() < 2) User::Leave(-900);
       
   622 		
       
   623 		CPosLmDisplayItem& item = displayData->DisplayItem(0);
       
   624 	    TInt lmId = item.Landmark().LandmarkId();
       
   625 	    
       
   626 	    if (item.DisplayItemType() != CPosLmDisplayItem::ECategoryItem) User::Leave(-901);
       
   627 		
       
   628 		// This call should panic
       
   629 		item.Landmark();
       
   630 		
       
   631 		multiSearcher->UnsetDisplayData();
       
   632     	CleanupStack::PopAndDestroy(displayData);
       
   633     	CleanupStack::PopAndDestroy(nameCriteria);
       
   634     	CleanupStack::PopAndDestroy(multiSearcher);
       
   635     	}
       
   636     else if (self->iTestCase == 14)
       
   637      	{
       
   638     	// NULL check, set DisplayData to NULL
       
   639      	CPosLmMultiDbSearch* multiSearcher = CPosLmMultiDbSearch::NewL(*dbUris);
       
   640     	CleanupStack::PushL(multiSearcher);
       
   641     	CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC();	
       
   642     	textCriteria->SetTextL(_L("*"));
       
   643     	
       
   644     	CPosLmDisplayData* displayData = NULL;
       
   645     	multiSearcher->SetDisplayData(*displayData);
       
   646     	    	
       
   647     	CPosLmOperation* operation = multiSearcher->StartLandmarkSearchL(*textCriteria, EFalse);
       
   648     	ExecuteAndDeleteLD(operation);
       
   649 		
       
   650 		multiSearcher->UnsetDisplayData();
       
   651 		CleanupStack::PopAndDestroy(textCriteria);
       
   652     	CleanupStack::PopAndDestroy(multiSearcher);
       
   653     	}
       
   654     
       
   655     CleanupStack::PopAndDestroy(dbUris);
       
   656     CleanupStack::PopAndDestroy(lmSearch);
       
   657     CleanupStack::PopAndDestroy(database);
       
   658     }
       
   659 	
       
   660 // ---------------------------------------------------------
       
   661 // LOCAL_C ThreadFunction
       
   662 //
       
   663 // (other items were commented in a header).
       
   664 // ---------------------------------------------------------
       
   665 //
       
   666 LOCAL_C TInt ThreadFunction(TAny* aData)
       
   667     {
       
   668     CTrapCleanup* cleanup=CTrapCleanup::New(); 
       
   669 
       
   670     CActiveScheduler* actSch = new (ELeave) CActiveScheduler;
       
   671     CActiveScheduler::Install(actSch);
       
   672 
       
   673     TRAPD(err, CPosTp132::RunPanicTestL(aData));
       
   674     
       
   675     delete actSch;
       
   676     delete cleanup;
       
   677     return err;
       
   678     }
       
   679 
       
   680 // ---------------------------------------------------------
       
   681 // CPosTp132::CreateThreadL
       
   682 //
       
   683 // (other items were commented in a header).
       
   684 // ---------------------------------------------------------
       
   685 //
       
   686 void CPosTp132::CreateThreadL()
       
   687     {
       
   688     _LIT(KCreateThreadErr, "Create thread failed with %d");
       
   689 	TBuf<100> buf;
       
   690 	buf.Format(_L("Tp132 test thread %d"), iTestCase);
       
   691      TInt err=0;
       
   692      err = iThread.Create(buf, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, this);
       
   693      AssertTrueSecL(err == KErrNone, KCreateThreadErr, err);
       
   694     }
       
   695 
       
   696 //  End of File