landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp147.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_CPosTp147.h"
       
    23 #include <e32math.h>
       
    24 #include <LbsPosition.h>
       
    25 
       
    26 #include <EPos_CPosLandmark.h>
       
    27 #include <EPos_CPosLandmarkCategory.h>
       
    28 #include <EPos_PosLandmarkSerialization.h>
       
    29 #include <EPos_PosLmCategorySerialization.h>
       
    30            
       
    31 // ================= MEMBER FUNCTIONS =======================
       
    32 
       
    33 
       
    34 // ---------------------------------------------------------
       
    35 // CPosTp147::StartL
       
    36 //
       
    37 // (other items were commented in a header).
       
    38 // ---------------------------------------------------------
       
    39 //
       
    40 void CPosTp147::StartL()
       
    41     {  
       
    42     
       
    43   		CheckSerializationMemoryL();
       
    44   		
       
    45 	}
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // CPosTp147::CreateDummyLandmarkLC
       
    49 //
       
    50 // ---------------------------------------------------------
       
    51 
       
    52 CPosLandmark* CPosTp147::CreateDummyLandmarkLC()
       
    53     {
       
    54     CPosLandmark* lm = CPosLandmark::NewLC();
       
    55 
       
    56     _LIT(KName, "Name");
       
    57     _LIT(KDesc, "Description");
       
    58     _LIT(KIcon, "IconFile");
       
    59     const TInt KIconIndex = 1, KIconMaskIndex = 2;
       
    60 
       
    61     const TPosLmItemId KCat[] = { 3, 4, 5 };
       
    62     const TInt KCats = sizeof KCat / sizeof(TPosLmItemId);
       
    63 
       
    64     _LIT(KField1Val, "field1");
       
    65     _LIT(KField2Val, "field11");
       
    66     const TPositionFieldId KField[] =
       
    67         {
       
    68         EPositionFieldComment,
       
    69         EPositionFieldCountry
       
    70         };
       
    71     const TInt KFields = sizeof KField / sizeof(TPositionFieldId);
       
    72     const TPtrC KFieldData[] =
       
    73         {
       
    74         KField1Val(), KField2Val()
       
    75         };
       
    76 
       
    77     const TReal32 KRadius = 0.12;
       
    78     const TReal32 KHacc = 0.23, KVacc = 0.34;
       
    79     const TReal KLat = 12, KLon = -23, KAlt = 34;
       
    80 
       
    81     lm->SetLandmarkNameL(KName);
       
    82     lm->SetLandmarkDescriptionL(KDesc);
       
    83     lm->SetIconL(KIcon, KIconIndex, KIconMaskIndex);
       
    84 
       
    85     const TLocality KLoc(TCoordinate(KLat,KLon,KAlt), KHacc, KVacc);
       
    86     lm->SetPositionL(KLoc);
       
    87     lm->SetCoverageRadius(KRadius);
       
    88 
       
    89     for (TInt c = 0; c < KCats; c++)
       
    90         {
       
    91         lm->AddCategoryL(KCat[c]);
       
    92         }
       
    93 
       
    94     for (TInt f = 0; f < KFields; f++)
       
    95         {
       
    96         lm->SetPositionFieldL(KField[f], KFieldData[f]);
       
    97         }
       
    98 
       
    99     return lm;
       
   100     }
       
   101  
       
   102 // ---------------------------------------------------------
       
   103 // CPosTp147::CreateDummyCategoryLC
       
   104 //
       
   105 // ---------------------------------------------------------
       
   106  
       
   107  
       
   108 CPosLandmarkCategory* CPosTp147::CreateDummyCategoryLC()
       
   109     {
       
   110     CPosLandmarkCategory* cat = CPosLandmarkCategory::NewLC();
       
   111 
       
   112     TInt KCatId = cat->CategoryId();
       
   113     _LIT(KName, "Name");
       
   114     _LIT(KIcon, "IconFile");
       
   115     const TInt KIconIndex = 1, KIconMaskIndex = 2;
       
   116     cat->SetCategoryNameL(KName);
       
   117     cat->SetIconL(KIcon, KIconIndex, KIconMaskIndex);
       
   118     return cat;
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------
       
   122 // CPosTp147::CheckSerializationMemoryL
       
   123 //
       
   124 // ---------------------------------------------------------
       
   125 
       
   126 void CPosTp147::CheckSerializationMemoryL()
       
   127     {
       
   128     CheckLmSerialization_MemoryL();
       
   129     CheckLmCatSerialization_MemoryL();
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------
       
   133 // CPosTp147::CheckLmSerialization_MemoryL
       
   134 //
       
   135 // ---------------------------------------------------------
       
   136 
       
   137 void CPosTp147::CheckLmSerialization_MemoryL()
       
   138     {
       
   139     DECLARE_ERROR_LOGGING;
       
   140 
       
   141     LOG("Packing and checking uheap");
       
   142 
       
   143     CPosLandmark* lm = CreateDummyLandmarkLC();
       
   144 
       
   145     __UHEAP_MARK;
       
   146     HBufC8* buf = PosLandmarkSerialization::PackL(*lm);
       
   147     delete buf;
       
   148     __UHEAP_MARKEND;
       
   149     
       
   150     LOG("Unpacking and checking uheap");
       
   151 
       
   152     buf = PosLandmarkSerialization::PackL(*lm);
       
   153     CleanupStack::PopAndDestroy(lm);
       
   154     CleanupStack::PushL(buf);
       
   155 
       
   156     __UHEAP_MARK;
       
   157     lm = PosLandmarkSerialization::UnpackL(*buf);
       
   158     delete lm;
       
   159     __UHEAP_MARKEND;
       
   160 
       
   161     LOG("Done");
       
   162     CleanupStack::PopAndDestroy(buf);
       
   163     }
       
   164 
       
   165 // ---------------------------------------------------------
       
   166 // CPosTp147::CheckLmCatSerialization_MemoryL
       
   167 //
       
   168 // ---------------------------------------------------------
       
   169 
       
   170 void CPosTp147::CheckLmCatSerialization_MemoryL()
       
   171     {
       
   172     DECLARE_ERROR_LOGGING;
       
   173 
       
   174     LOG("Packing and checking uheap");
       
   175 
       
   176     CPosLandmarkCategory* cat = CreateDummyCategoryLC();
       
   177 
       
   178     __UHEAP_MARK;
       
   179     HBufC8* buf = PosLmCategorySerialization::PackL(*cat);
       
   180     delete buf;
       
   181     __UHEAP_MARKEND;
       
   182     
       
   183     LOG("Unpacking and checking uheap");
       
   184 
       
   185     buf = PosLmCategorySerialization::PackL(*cat);
       
   186     CleanupStack::PopAndDestroy(cat);
       
   187     CleanupStack::PushL(buf);
       
   188 
       
   189     __UHEAP_MARK;
       
   190     cat = PosLmCategorySerialization::UnpackL(*buf);
       
   191     delete cat;
       
   192     __UHEAP_MARKEND;
       
   193 
       
   194     LOG("Done");
       
   195     CleanupStack::PopAndDestroy(buf);
       
   196     }
       
   197     
       
   198 
       
   199 
       
   200  
       
   201     
       
   202 //  End of File