locationtriggering/tsrc/lbtengine_test/LbtUnitTestModule/src/LbtUnitTestModuleBlocks.cpp
changeset 50 4c28d569e1fe
equal deleted inserted replaced
43:24e118dfbea1 50:4c28d569e1fe
       
     1 /*
       
     2 * Copyright (c) 2009 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: This file contains testclass implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // [INCLUDE FILES] - do not remove
       
    19 #include <e32svr.h>
       
    20 #include <StifParser.h>
       
    21 #include <StifTestInterface.h>
       
    22 #include <etelmm.h>
       
    23 #include <centralrepository.h>
       
    24 #include "LbtUnitTestModule.h"
       
    25 #include "lbtgeogsmcell.h"
       
    26 #include "lbtgeowcdmacell.h"
       
    27 #include "lbtsettingsmanager.h"
       
    28 #include "lbtdiskspacelistner.h"
       
    29 #include "lbttriggernode.h"
       
    30 #include "lbtcontextsourceplugincommon.h"
       
    31 #include "lbtcellinfo.h"
       
    32 #include "lbtoperation.h"
       
    33 #include "lbtlogger.h"
       
    34 
       
    35 
       
    36 static const TInt KArrayIndex = 5;
       
    37 const TInt KCRUidLocationTriggeringSettings(0x1028312F);
       
    38 
       
    39 const TBuf<236> testFileName(_L("C:\\data\\testdata.log"));
       
    40 
       
    41 TInt ThreadFunction( TAny* aParam );
       
    42 
       
    43 enum TCenRepKeys
       
    44     {
       
    45     ELbtMinimumTriggerArea = 0x00000007,
       
    46     ELbtTrackModeInterval = 0x00000008,
       
    47     ELbtLocRequestTimeOut = 0x00000009,
       
    48     ELbtMinHysteresisArea = 0x0000000A,
       
    49     ELbtDaysForCleanup = 0x0000000B,
       
    50     ELbtSleepTime  = 0x0000000C,
       
    51     ELbtMaxActiveTriggers = 0x0000000D,
       
    52     };
       
    53 
       
    54 // ============================ MEMBER FUNCTIONS ===============================
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CLbtUnitTestModule::Delete
       
    58 // Delete here all resources allocated and opened from test methods. 
       
    59 // Called from destructor. 
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CLbtUnitTestModule::Delete() 
       
    63     {
       
    64     // Lbt logger is created by the first LOG call, it is destroyed 
       
    65     // only during termination. This has to be explicitly destroyed.
       
    66     STOPLOGGING
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CLbtUnitTestModule::RunMethodL
       
    71 // Run specified method. Contains also table of test mothods and their names.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 TInt CLbtUnitTestModule::RunMethodL( 
       
    75     CStifItemParser& aItem ) 
       
    76     {
       
    77 
       
    78     static TStifFunctionInfo const KFunctions[] =
       
    79         {  
       
    80         // Copy this line for every implemented function.
       
    81         // First string is the function name used in TestScripter script file.
       
    82         // Second is the actual implementation member function. 
       
    83         ENTRY( "TestCLbtGeoGsmCellNewL", CLbtUnitTestModule::TestCLbtGeoGsmCellNewL ),
       
    84         ENTRY( "TestCLbtGeoGsmCellNewLC", CLbtUnitTestModule::TestCLbtGeoGsmCellNewLC ),
       
    85         ENTRY( "TestCLbtGeoGsmCellNew1L", CLbtUnitTestModule::TestCLbtGeoGsmCellNew1L ),
       
    86         ENTRY( "TestCLbtGeoGsmCellNew1LC", CLbtUnitTestModule::TestCLbtGeoGsmCellNew1LC ),
       
    87         ENTRY( "TestSetAndGetBsicL", CLbtUnitTestModule::TestSetAndGetBsicL ),
       
    88         ENTRY( "TestGsmCGISpecifiedDuringCreationL", CLbtUnitTestModule::TestGsmCGISpecifiedDuringCreationL ),
       
    89         ENTRY( "TestGsmCellInternalizeExternalizeL", CLbtUnitTestModule::TestGsmCellInternalizeExternalizeL ),
       
    90         ENTRY( "TestCLbtGeoWcdmaCellL", CLbtUnitTestModule::TestCLbtGeoWcdmaCellL ),
       
    91         ENTRY( "TestCLbtGeoWcdmaCellLC", CLbtUnitTestModule::TestCLbtGeoWcdmaCellLC ),
       
    92         ENTRY( "TestCLbtGeoWcdmaCell1L", CLbtUnitTestModule::TestCLbtGeoWcdmaCell1L ),
       
    93         ENTRY( "TestCLbtGeoWcdmaCell1LC", CLbtUnitTestModule::TestCLbtGeoWcdmaCell1LC ),
       
    94         ENTRY( "TestSetAndGetWcdmaInfoL", CLbtUnitTestModule::TestSetAndGetWcdmaInfoL ),
       
    95         ENTRY( "TestWcdmaCGISpecifiedDuringCreationL", CLbtUnitTestModule::TestWcdmaCGISpecifiedDuringCreationL ),
       
    96         ENTRY( "TestWcdmaCellInternalizeExternalizeL", CLbtUnitTestModule::TestWcdmaCellInternalizeExternalizeL ),
       
    97         ENTRY( "TestSetAndGetOptimisationLevelL", CLbtUnitTestModule::TestSetAndGetOptimisationLevelL ),
       
    98         ENTRY( "TestSetAndGetNppModuleIdL", CLbtUnitTestModule::TestSetAndGetNppModuleIdL ),
       
    99         ENTRY( "TestSetAndGetMinUpdateIntOnGpsFailureL", CLbtUnitTestModule::TestSetAndGetMinUpdateIntOnGpsFailureL ),
       
   100         ENTRY( "TestSetAndGetMaximumUserSpeedL", CLbtUnitTestModule::TestSetAndGetMaximumUserSpeedL ),
       
   101         ENTRY( "TestSetAndGetTrigMechStateL", CLbtUnitTestModule::TestSetAndGetTrigMechStateL ),
       
   102         ENTRY( "TestTriggerConfigParamsL", CLbtUnitTestModule::TestTriggerConfigParamsL ),
       
   103         ENTRY( "TestCLbtDiskSpaceListnerStartToListenL", CLbtUnitTestModule::TestCLbtDiskSpaceListnerStartToListenL ),
       
   104         ENTRY( "TestCLbtDiskSpaceListnerCancelL", CLbtUnitTestModule::TestCLbtDiskSpaceListnerCancelL ),
       
   105         ENTRY( "TestTriggerNodeMethodsL", CLbtUnitTestModule::TestTriggerNodeMethodsL ),
       
   106         ENTRY( "TestGsmCellInfoMethodsL", CLbtUnitTestModule::TestGsmCellInfoMethodsL ),
       
   107         ENTRY( "TestWcdmaCellInfoMethodsL", CLbtUnitTestModule::TestWcdmaCellInfoMethodsL ),
       
   108         ENTRY( "TestLbtOperationsMethodL", CLbtUnitTestModule::TestLbtOperationsMethodL )
       
   109         //ADD NEW ENTRY HERE
       
   110         // [test cases entries] - Do not remove
       
   111 
       
   112         };
       
   113 
       
   114     const TInt count = sizeof( KFunctions ) / 
       
   115                         sizeof( TStifFunctionInfo );
       
   116 
       
   117     return RunInternalL( KFunctions, count, aItem );
       
   118 
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CLbtUnitTestModule::TestCLbtGeoGsmCellNewL
       
   123 // (other items were commented in a header).
       
   124 // -----------------------------------------------------------------------------
       
   125 TInt CLbtUnitTestModule::TestCLbtGeoGsmCellNewL( CStifItemParser& /*aItem*/ )
       
   126     {
       
   127     CLbtGeoGsmCell* gsmCell = CLbtGeoGsmCell::NewL();
       
   128     delete gsmCell;
       
   129     return KErrNone;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CLbtUnitTestModule::TestCLbtGeoGsmCellNewLC
       
   134 // (other items were commented in a header).
       
   135 // -----------------------------------------------------------------------------
       
   136 TInt CLbtUnitTestModule::TestCLbtGeoGsmCellNewLC( CStifItemParser& /*aItem*/ )
       
   137     {
       
   138     CLbtGeoGsmCell* gsmCell = CLbtGeoGsmCell::NewLC();
       
   139     CleanupStack::PopAndDestroy( gsmCell );
       
   140     return KErrNone;
       
   141     }
       
   142 
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CLbtUnitTestModule::TestCLbtGeoGsmCellNew1L
       
   146 // (other items were commented in a header).
       
   147 // -----------------------------------------------------------------------------
       
   148 TInt CLbtUnitTestModule::TestCLbtGeoGsmCellNew1L( CStifItemParser& /*aItem*/ )
       
   149     {
       
   150     TBuf<4> Networkcountrycode = _L("1000");
       
   151     TBuf<8> Networkidentitycode = _L("10000000");
       
   152     TUint Locationareacode = 100;
       
   153     TUint CellId = 100;
       
   154     CLbtGeoGsmCell* gsmCell = CLbtGeoGsmCell::NewL( 
       
   155                                    RMobilePhone::ENetworkModeGsm,
       
   156                                    Networkcountrycode,
       
   157                                    Networkidentitycode,
       
   158                                    Locationareacode,
       
   159                                    CellId);
       
   160     delete gsmCell;
       
   161     return KErrNone;
       
   162     }
       
   163 
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CLbtUnitTestModule::TestCLbtGeoGsmCellNew1LC
       
   167 // (other items were commented in a header).
       
   168 // -----------------------------------------------------------------------------
       
   169 TInt CLbtUnitTestModule::TestCLbtGeoGsmCellNew1LC( CStifItemParser& /*aItem*/ )
       
   170     {
       
   171     TBuf<4> Networkcountrycode = _L("1000");
       
   172     TBuf<8> Networkidentitycode = _L("10000000");
       
   173     TUint Locationareacode = 100;
       
   174     TUint CellId = 100;
       
   175     CLbtGeoGsmCell* gsmCell = CLbtGeoGsmCell::NewLC( 
       
   176                                     RMobilePhone::ENetworkModeGsm,
       
   177                                     Networkcountrycode,
       
   178                                     Networkidentitycode,
       
   179                                     Locationareacode,
       
   180                                     CellId);
       
   181     CleanupStack::PopAndDestroy( gsmCell );
       
   182     return KErrNone;
       
   183     }
       
   184 
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CLbtUnitTestModule::TestSetAndGetBsicL
       
   188 // (other items were commented in a header).
       
   189 // -----------------------------------------------------------------------------
       
   190 TInt CLbtUnitTestModule::TestSetAndGetBsicL( CStifItemParser& /*aItem*/ )
       
   191     {
       
   192     CLbtGeoGsmCell* gsmCell = CLbtGeoGsmCell::NewLC();
       
   193     RArray<TInt> bsicArray;
       
   194     CleanupClosePushL( bsicArray );
       
   195     for( TInt i=0;i<KArrayIndex;i++ )
       
   196         {
       
   197         bsicArray.AppendL( i+1 );
       
   198         }
       
   199     gsmCell->SetBsic( bsicArray );
       
   200     
       
   201     RArray<TInt> retBsicArray = gsmCell->Bsic();
       
   202     for( TInt i=0;i<bsicArray.Count();i++ )
       
   203         {
       
   204         if( bsicArray[i] != retBsicArray[i] )
       
   205             {
       
   206             User::Leave( KErrArgument );
       
   207             }
       
   208         }
       
   209     CleanupStack::PopAndDestroy( 2 );
       
   210     return KErrNone;
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CLbtUnitTestModule::TestGsmCGISpecifiedDuringCreationL
       
   215 // (other items were commented in a header).
       
   216 // -----------------------------------------------------------------------------
       
   217 TInt CLbtUnitTestModule::TestGsmCGISpecifiedDuringCreationL( CStifItemParser& /*aItem*/ )
       
   218     {
       
   219     CLbtGeoGsmCell* gsmCell = CLbtGeoGsmCell::NewL();
       
   220     CleanupStack::PushL( gsmCell );
       
   221     TBool cgiSpecified = gsmCell->CGISpecifiedDuringCreation();
       
   222     if( cgiSpecified )
       
   223         {
       
   224         User::Leave( KErrArgument );
       
   225         }
       
   226     CleanupStack::PopAndDestroy( gsmCell );
       
   227     return KErrNone;
       
   228     }
       
   229 
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // CLbtUnitTestModule::TestGsmCellInternalizeExternalizeL
       
   233 // (other items were commented in a header).
       
   234 // -----------------------------------------------------------------------------
       
   235 TInt CLbtUnitTestModule::TestGsmCellInternalizeExternalizeL( CStifItemParser& /*aItem*/ )
       
   236     {
       
   237     TBuf<4> Networkcountrycode = _L("1000");
       
   238     TBuf<8> Networkidentitycode = _L("10000000");
       
   239     TUint Locationareacode = 100;
       
   240     TUint CellId = 100;
       
   241     
       
   242     CLbtGeoGsmCell* gsmCell = CLbtGeoGsmCell::NewL( 
       
   243                                     RMobilePhone::ENetworkModeGsm,
       
   244                                     Networkcountrycode,
       
   245                                     Networkidentitycode,
       
   246                                     Locationareacode,
       
   247                                     CellId);
       
   248     CleanupStack::PushL( gsmCell );
       
   249     
       
   250     CBufFlat* buffer= CBufFlat::NewL(256);
       
   251     CleanupStack::PushL( buffer );  
       
   252     
       
   253     // Externalize
       
   254     RBufWriteStream wr;
       
   255     CleanupClosePushL( wr );
       
   256     wr.Open(*buffer);
       
   257     gsmCell->ExternalizeL( wr );
       
   258     wr.CommitL();
       
   259     CleanupStack::PopAndDestroy( &wr );
       
   260     
       
   261     // Internalize
       
   262     
       
   263     RBufReadStream rd;
       
   264     rd.Open(*buffer);
       
   265     CleanupClosePushL(rd);
       
   266     
       
   267     CLbtGeoGsmCell* newGsmCell = CLbtGeoGsmCell::NewLC();
       
   268     newGsmCell->InternalizeL(rd);
       
   269     
       
   270     if( newGsmCell->NetworkType() != RMobilePhone::ENetworkModeGsm ||
       
   271         newGsmCell->NetworkCountryCode() != Networkcountrycode ||
       
   272         newGsmCell->NetworkIdentityCode() != Networkidentitycode ||
       
   273         newGsmCell->LocationAreaCode() != Locationareacode ||
       
   274         newGsmCell->CellId() != CellId )
       
   275         {
       
   276         User::Leave( KErrArgument );
       
   277         }
       
   278     CleanupStack::PopAndDestroy( 4 );
       
   279     return KErrNone;
       
   280     }
       
   281 
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // CLbtUnitTestModule::TestCLbtGeoWcdmaCellL
       
   285 // (other items were commented in a header).
       
   286 // -----------------------------------------------------------------------------
       
   287 TInt CLbtUnitTestModule::TestCLbtGeoWcdmaCellL( CStifItemParser& /*aItem*/ )
       
   288     {
       
   289     CLbtGeoWcdmaCell* wcdmaCell = CLbtGeoWcdmaCell::NewL();
       
   290     delete wcdmaCell;
       
   291     return KErrNone;
       
   292     }
       
   293 
       
   294 // -----------------------------------------------------------------------------
       
   295 // CLbtUnitTestModule::TestCLbtGeoWcdmaCellLC
       
   296 // (other items were commented in a header).
       
   297 // -----------------------------------------------------------------------------
       
   298 TInt CLbtUnitTestModule::TestCLbtGeoWcdmaCellLC( CStifItemParser& /*aItem*/ )
       
   299     {
       
   300     CLbtGeoWcdmaCell* wcdmaCell = CLbtGeoWcdmaCell::NewLC();
       
   301     CleanupStack::PopAndDestroy( wcdmaCell );
       
   302     return KErrNone;
       
   303     }
       
   304 
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // CLbtUnitTestModule::TestCLbtGeoWcdmaCell1L
       
   308 // (other items were commented in a header).
       
   309 // -----------------------------------------------------------------------------
       
   310 TInt CLbtUnitTestModule::TestCLbtGeoWcdmaCell1L( CStifItemParser& /*aItem*/ )
       
   311     {
       
   312     TBuf<4> Networkcountrycode = _L("1000");
       
   313     TBuf<8> Networkidentitycode = _L("10000000");
       
   314     TUint Locationareacode = 100;
       
   315     TUint CellId = 100;
       
   316     CLbtGeoWcdmaCell* wcdmaCell = CLbtGeoWcdmaCell::NewL( 
       
   317                                         RMobilePhone::ENetworkModeWcdma,
       
   318                                         Networkcountrycode,
       
   319                                         Networkidentitycode,
       
   320                                         Locationareacode,
       
   321                                         CellId);
       
   322     delete wcdmaCell;
       
   323     return KErrNone;
       
   324     }
       
   325 
       
   326 // -----------------------------------------------------------------------------
       
   327 // CLbtUnitTestModule::TestCLbtGeoWcdmaCell1LC
       
   328 // (other items were commented in a header).
       
   329 // -----------------------------------------------------------------------------
       
   330 TInt CLbtUnitTestModule::TestCLbtGeoWcdmaCell1LC( CStifItemParser& /*aItem*/ )
       
   331     {
       
   332     TBuf<4> Networkcountrycode = _L("1000");
       
   333     TBuf<8> Networkidentitycode = _L("10000000");
       
   334     TUint Locationareacode = 100;
       
   335     TUint CellId = 100;
       
   336     
       
   337     CLbtGeoWcdmaCell* wcdmaCell = CLbtGeoWcdmaCell::NewLC(
       
   338                                         RMobilePhone::ENetworkModeWcdma,
       
   339                                         Networkcountrycode,
       
   340                                         Networkidentitycode,
       
   341                                         Locationareacode,
       
   342                                         CellId );
       
   343     CleanupStack::PopAndDestroy( wcdmaCell );
       
   344     return KErrNone;
       
   345     }
       
   346 
       
   347 
       
   348 // -----------------------------------------------------------------------------
       
   349 // CLbtUnitTestModule::TestSetAndGetWcdmaInfoL
       
   350 // (other items were commented in a header).
       
   351 // -----------------------------------------------------------------------------
       
   352 TInt CLbtUnitTestModule::TestSetAndGetWcdmaInfoL( CStifItemParser& /*aItem*/ )
       
   353     {
       
   354     CLbtGeoWcdmaCell* wcdmaCell = CLbtGeoWcdmaCell::NewLC();
       
   355     
       
   356     TLbtWcdmaCellInfo wcdmaCellInfo;
       
   357     wcdmaCellInfo.iCell.iCarrierRssi = 10;
       
   358     wcdmaCellInfo.iCell.iEcNo = 20;
       
   359     wcdmaCellInfo.iCell.iPathLoss = 30;
       
   360     wcdmaCellInfo.iCell.iRscp = 40;
       
   361     wcdmaCell->SetWcdmaCellInfo( wcdmaCellInfo );
       
   362     
       
   363     TLbtWcdmaCellInfo retWcdmaCellInfo = wcdmaCell->WcdmaCellInfo();
       
   364     
       
   365     if( wcdmaCellInfo.iCell.iCarrierRssi != retWcdmaCellInfo.iCell.iCarrierRssi ||
       
   366         wcdmaCellInfo.iCell.iEcNo != retWcdmaCellInfo.iCell.iEcNo ||
       
   367         wcdmaCellInfo.iCell.iPathLoss != retWcdmaCellInfo.iCell.iPathLoss ||
       
   368         wcdmaCellInfo.iCell.iRscp != retWcdmaCellInfo.iCell.iRscp )
       
   369         {
       
   370         User::Leave( KErrArgument );
       
   371         }
       
   372     CleanupStack::PopAndDestroy( wcdmaCell );
       
   373     return KErrNone;
       
   374     }
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // CLbtUnitTestModule::TestWcdmaCGISpecifiedDuringCreationL
       
   378 // (other items were commented in a header).
       
   379 // -----------------------------------------------------------------------------
       
   380 TInt CLbtUnitTestModule::TestWcdmaCGISpecifiedDuringCreationL( CStifItemParser& /*aItem*/ )
       
   381     {
       
   382     CLbtGeoWcdmaCell* wcdmaCell = CLbtGeoWcdmaCell::NewL();
       
   383     CleanupStack::PushL( wcdmaCell );
       
   384     TBool cgiSpecified = wcdmaCell->CGISpecifiedDuringCreation();
       
   385     if( cgiSpecified )
       
   386         {
       
   387         User::Leave( KErrArgument );
       
   388         }
       
   389     CleanupStack::PopAndDestroy( wcdmaCell );
       
   390     return KErrNone;
       
   391     }
       
   392 
       
   393 
       
   394 // -----------------------------------------------------------------------------
       
   395 // CLbtUnitTestModule::TestWcdmaCellInternalizeExternalizeL
       
   396 // (other items were commented in a header).
       
   397 // -----------------------------------------------------------------------------
       
   398 TInt CLbtUnitTestModule::TestWcdmaCellInternalizeExternalizeL( CStifItemParser& /*aItem*/ )
       
   399     {
       
   400     TBuf<4> Networkcountrycode = _L("1000");
       
   401     TBuf<8> Networkidentitycode = _L("10000000");
       
   402     TUint Locationareacode = 100;
       
   403     TUint CellId = 100;
       
   404     
       
   405     CLbtGeoWcdmaCell* wcdmaCell = CLbtGeoWcdmaCell::NewL( 
       
   406                                     RMobilePhone::ENetworkModeWcdma,
       
   407                                     Networkcountrycode,
       
   408                                     Networkidentitycode,
       
   409                                     Locationareacode,
       
   410                                     CellId);
       
   411     CleanupStack::PushL( wcdmaCell );
       
   412     
       
   413     CBufFlat* buffer= CBufFlat::NewL(256);
       
   414     CleanupStack::PushL( buffer );  
       
   415     
       
   416     // Externalize
       
   417     RBufWriteStream wr;
       
   418     CleanupClosePushL( wr );
       
   419     wr.Open(*buffer);
       
   420     wcdmaCell->ExternalizeL( wr );
       
   421     wr.CommitL();
       
   422     CleanupStack::PopAndDestroy( &wr );
       
   423     
       
   424     // Internalize
       
   425     
       
   426     RBufReadStream rd;
       
   427     rd.Open(*buffer);
       
   428     CleanupClosePushL(rd);
       
   429     
       
   430     CLbtGeoWcdmaCell* newWcdmaCell = CLbtGeoWcdmaCell::NewLC();
       
   431     newWcdmaCell->InternalizeL(rd);
       
   432     
       
   433     if( newWcdmaCell->NetworkType() != RMobilePhone::ENetworkModeWcdma ||
       
   434         newWcdmaCell->NetworkCountryCode() != Networkcountrycode ||
       
   435         newWcdmaCell->NetworkIdentityCode() != Networkidentitycode ||
       
   436         newWcdmaCell->LocationAreaCode() != Locationareacode ||
       
   437         newWcdmaCell->CellId() != CellId )
       
   438         {
       
   439         User::Leave( KErrArgument );
       
   440         }
       
   441     CleanupStack::PopAndDestroy( 4 );
       
   442     return KErrNone;
       
   443     }
       
   444 
       
   445 // -----------------------------------------------------------------------------
       
   446 // CLbtUnitTestModule::TestSetAndGetOptimisationLevelL
       
   447 // (other items were commented in a header).
       
   448 // -----------------------------------------------------------------------------
       
   449 TInt CLbtUnitTestModule::TestSetAndGetOptimisationLevelL( CStifItemParser& /*aItem*/ )
       
   450     {
       
   451     CLbtSettingsManager* settingsManager = CLbtSettingsManager::NewL();
       
   452     CleanupStack::PushL( settingsManager );
       
   453     settingsManager->SetOptimizationLevel( 10 );
       
   454     if( settingsManager->GetOptimizationLevel() != 10 )
       
   455         {
       
   456         User::Leave( KErrArgument );
       
   457         }
       
   458     CleanupStack::PopAndDestroy( settingsManager );
       
   459     return KErrNone;    
       
   460     }
       
   461 
       
   462 // -----------------------------------------------------------------------------
       
   463 // CLbtUnitTestModule::TestSetAndGetModuleIdL
       
   464 // (other items were commented in a header).
       
   465 // -----------------------------------------------------------------------------
       
   466 TInt CLbtUnitTestModule::TestSetAndGetModuleIdL( CStifItemParser& /*aItem*/ )
       
   467     {
       
   468     CLbtSettingsManager* settingsManager = CLbtSettingsManager::NewL();
       
   469     CleanupStack::PushL( settingsManager );
       
   470     TUid moduleId = TUid::Uid( 270526860 );
       
   471     settingsManager->SetModuleId( moduleId );
       
   472     if( settingsManager->GetModuleId() != moduleId )
       
   473         {
       
   474         User::Leave( KErrArgument );
       
   475         }
       
   476     CleanupStack::PopAndDestroy( settingsManager );
       
   477     return KErrNone;    
       
   478     }
       
   479 
       
   480 
       
   481 // -----------------------------------------------------------------------------
       
   482 // CLbtUnitTestModule::TestSetAndGetNppModuleIdL
       
   483 // (other items were commented in a header).
       
   484 // -----------------------------------------------------------------------------
       
   485 TInt CLbtUnitTestModule::TestSetAndGetNppModuleIdL( CStifItemParser& /*aItem*/ )
       
   486     {
       
   487     CLbtSettingsManager* settingsManager = CLbtSettingsManager::NewL();
       
   488     CleanupStack::PushL( settingsManager );
       
   489     TUid moduleId = TUid::Uid( 16777216 );
       
   490     settingsManager->SetModuleId( moduleId );
       
   491     if( settingsManager->GetModuleId() != moduleId )
       
   492         {
       
   493         User::Leave( KErrArgument );
       
   494         }
       
   495     CleanupStack::PopAndDestroy( settingsManager );
       
   496     return KErrNone;    
       
   497     }
       
   498 
       
   499 // -----------------------------------------------------------------------------
       
   500 // CLbtUnitTestModule::TestSetAndGetMinUpdateIntOnGpsFailureL
       
   501 // (other items were commented in a header).
       
   502 // -----------------------------------------------------------------------------
       
   503 TInt CLbtUnitTestModule::TestSetAndGetMinUpdateIntOnGpsFailureL( CStifItemParser& /*aItem*/ )
       
   504     {
       
   505     CLbtSettingsManager* settingsManager = CLbtSettingsManager::NewL();
       
   506     CleanupStack::PushL( settingsManager );
       
   507     
       
   508     settingsManager->SetMinimumUpdateIntervalOnGpsFailure( 10000000 );
       
   509     if( settingsManager->GetMinimumUpdateIntervalOnGpsFailure() != 10000000 )
       
   510         {
       
   511         User::Leave( KErrArgument );
       
   512         }
       
   513     CleanupStack::PopAndDestroy( settingsManager );
       
   514     return KErrNone;    
       
   515     }
       
   516 
       
   517 
       
   518 // -----------------------------------------------------------------------------
       
   519 // CLbtUnitTestModule::TestSetAndGetMaximumUserSpeedL
       
   520 // (other items were commented in a header).
       
   521 // -----------------------------------------------------------------------------
       
   522 TInt CLbtUnitTestModule::TestSetAndGetMaximumUserSpeedL( CStifItemParser& /*aItem*/ )
       
   523     {
       
   524     CLbtSettingsManager* settingsManager = CLbtSettingsManager::NewL();
       
   525     CleanupStack::PushL( settingsManager );
       
   526     
       
   527     settingsManager->SetMaximumUserSpeed( 42 );
       
   528     if( settingsManager->GetMaximumUserSpeed() != 42 )
       
   529         {
       
   530         User::Leave( KErrArgument );
       
   531         }
       
   532     CleanupStack::PopAndDestroy( settingsManager );
       
   533     return KErrNone;    
       
   534     }
       
   535 
       
   536 // -----------------------------------------------------------------------------
       
   537 // CLbtUnitTestModule::TestSetAndGetTrigMechStateL
       
   538 // (other items were commented in a header).
       
   539 // -----------------------------------------------------------------------------
       
   540 TInt CLbtUnitTestModule::TestSetAndGetTrigMechStateL( CStifItemParser& /*aItem*/ )
       
   541     {
       
   542     CLbtSettingsManager* settingsManager = CLbtSettingsManager::NewL();
       
   543     CleanupStack::PushL( settingsManager );
       
   544     
       
   545     settingsManager->SetTriggeringMechanismState( ETriggeringMechanismOn );
       
   546     if( settingsManager->GetTriggeringMechanismState() != ETriggeringMechanismOn )
       
   547         {
       
   548         User::Leave( KErrArgument );
       
   549         }
       
   550     CleanupStack::PopAndDestroy( settingsManager );
       
   551     return KErrNone;    
       
   552     }
       
   553 
       
   554 
       
   555 // -----------------------------------------------------------------------------
       
   556 // CLbtUnitTestModule::TestTriggerConfigParamsL
       
   557 // (other items were commented in a header).
       
   558 // -----------------------------------------------------------------------------
       
   559 TInt CLbtUnitTestModule::TestTriggerConfigParamsL( CStifItemParser& /*aItem*/ )
       
   560     {
       
   561     // Read values from cenrep.
       
   562     
       
   563     CRepository* repository = CRepository::NewL(TUid::Uid(KCRUidLocationTriggeringSettings));
       
   564     CleanupStack::PushL( repository );
       
   565     // Get all the values and store it in RAM
       
   566     TInt minTriggerArea;
       
   567     repository->Get(ELbtMinimumTriggerArea, minTriggerArea);
       
   568     TInt trackModeInt;
       
   569     repository->Get(ELbtTrackModeInterval, trackModeInt);
       
   570     TInt locRequestTimeOut;
       
   571     repository->Get(ELbtLocRequestTimeOut, locRequestTimeOut);
       
   572     TInt minHysteresisArea;
       
   573     repository->Get(ELbtMinHysteresisArea, minHysteresisArea);
       
   574     TInt daysForCleanup;
       
   575     repository->Get(ELbtDaysForCleanup, daysForCleanup);
       
   576     TInt enabledValidTriggerCount;
       
   577     repository->Get(ELbtMaxActiveTriggers, enabledValidTriggerCount);
       
   578     CLbtSettingsManager* settingsManager = CLbtSettingsManager::NewL();
       
   579     CleanupStack::PushL( settingsManager );
       
   580     
       
   581     if( settingsManager->MinimumTriggeringArea() != minTriggerArea )
       
   582         {
       
   583         User::Leave( KErrArgument );
       
   584         }
       
   585     
       
   586     if( settingsManager->TrackingModeInterval() != trackModeInt )
       
   587         {
       
   588         User::Leave( KErrArgument );
       
   589         }
       
   590     
       
   591     if( settingsManager->GetLocationRequestTimeOut() != locRequestTimeOut )
       
   592         {
       
   593         User::Leave( KErrArgument );
       
   594         }
       
   595     
       
   596     if( settingsManager->MinimumHysteresisArea() != minHysteresisArea )
       
   597         {
       
   598         User::Leave( KErrArgument );
       
   599         }
       
   600     
       
   601     if( settingsManager->NumberOfDaysForCleanup() != daysForCleanup )
       
   602         {
       
   603         User::Leave( KErrArgument );
       
   604         }
       
   605     
       
   606     if( settingsManager->EnabledValidTriggerCount() != enabledValidTriggerCount )
       
   607         {
       
   608         User::Leave( KErrArgument );
       
   609         }
       
   610     CleanupStack::PopAndDestroy( 2 );
       
   611     return KErrNone;    
       
   612     }
       
   613 
       
   614 // -----------------------------------------------------------------------------
       
   615 // CLbtUnitTestModule::TestCLbtDiskSpaceListnerStartToListenL
       
   616 // (other items were commented in a header).
       
   617 // -----------------------------------------------------------------------------
       
   618 TInt CLbtUnitTestModule::TestCLbtDiskSpaceListnerStartToListenL( CStifItemParser& /*aItem*/ )
       
   619     {
       
   620     CLbtDiskSpaceListner* diskSpaceListner = CLbtDiskSpaceListner::NewL( *this );
       
   621     CleanupStack::PushL( diskSpaceListner );
       
   622     
       
   623     diskSpaceListner->StartToListen();
       
   624     
       
   625     RThread thread;
       
   626     TThreadFunction  funcPtr = ThreadFunction;
       
   627     thread.Create(_L("TestLbtThread"),funcPtr,KDefaultStackSize,NULL,NULL);
       
   628     thread.Resume();
       
   629     
       
   630     iWait->Start();
       
   631     thread.Kill( 0 );
       
   632     thread.Close();
       
   633     CleanupStack::PopAndDestroy( diskSpaceListner );
       
   634     return KErrNone;
       
   635     }
       
   636 
       
   637 
       
   638 // -----------------------------------------------------------------------------
       
   639 // CLbtUnitTestModule::TestCLbtDiskSpaceListnerCancelL
       
   640 // (other items were commented in a header).
       
   641 // -----------------------------------------------------------------------------
       
   642 TInt CLbtUnitTestModule::TestCLbtDiskSpaceListnerCancelL( CStifItemParser& /*aItem*/ )
       
   643     {
       
   644     CLbtDiskSpaceListner* diskSpaceListner = CLbtDiskSpaceListner::NewL( *this );
       
   645     CleanupStack::PushL( diskSpaceListner );
       
   646     
       
   647     diskSpaceListner->StartToListen();
       
   648     
       
   649     // Cancel is called in the destructor.
       
   650     CleanupStack::PopAndDestroy( diskSpaceListner );
       
   651     return KErrNone;
       
   652     }
       
   653 
       
   654 
       
   655 // -----------------------------------------------------------------------------
       
   656 // CLbtUnitTestModule::TestTriggerNodeMethodsL
       
   657 // (other items were commented in a header).
       
   658 // -----------------------------------------------------------------------------
       
   659 TInt CLbtUnitTestModule::TestTriggerNodeMethodsL( CStifItemParser& /*aItem*/ )
       
   660     {
       
   661     TTriggerNode triggerNode;
       
   662     
       
   663     HBufC* buffer = HBufC::NewLC( 10 );
       
   664     TPtr ptr =buffer->Des();
       
   665     TPtrC retPtr;
       
   666     TReal value;
       
   667     
       
   668     // Test set and get trigger name.
       
   669     ptr.Copy(_L("Test")); 
       
   670     triggerNode.SetTriggerNameL( ptr );
       
   671     triggerNode.GetTriggerName( retPtr );
       
   672     if( ptr != retPtr )
       
   673         {
       
   674         User::Leave( KErrArgument );
       
   675         }
       
   676     
       
   677     // Test set and get latitude.
       
   678     ptr.Copy(_L("12.7"));
       
   679     triggerNode.SetLatitudeL( ptr );
       
   680     triggerNode.GetLatitude( value );
       
   681     if( value != 12.7 )
       
   682         {
       
   683         User::Leave( KErrArgument );
       
   684         }
       
   685     
       
   686     // Test set and get longitude.
       
   687     ptr.Copy(_L("72.7"));
       
   688     triggerNode.SetLongitudeL( ptr );
       
   689     triggerNode.GetLongitude( value );
       
   690     if( value != 72.7 )
       
   691         {
       
   692         User::Leave( KErrArgument );
       
   693         }
       
   694     
       
   695     
       
   696     // Test set and get region.
       
   697     ptr.Copy(KRegionValue); 
       
   698     triggerNode.SetRegionL( ptr );
       
   699     triggerNode.GetRegion( retPtr );
       
   700     if( ptr != retPtr )
       
   701         {
       
   702         User::Leave( KErrArgument );
       
   703         }
       
   704     
       
   705     // Test set and get radius.
       
   706     ptr.Copy(_L("10"));
       
   707     triggerNode.SetRadiusL( ptr );
       
   708     triggerNode.GetRadius( value );
       
   709     if( value != KMinRadius )
       
   710         {
       
   711         User::Leave( KErrArgument );
       
   712         }
       
   713     
       
   714     
       
   715     // Test set and get direction.
       
   716     ptr.Copy(KNullDesC); 
       
   717     triggerNode.SetDirectionL( ptr );
       
   718     if( triggerNode.GetDirection() != CLbtTriggerConditionArea::EFireOnEnter )
       
   719         {
       
   720         User::Leave( KErrArgument );
       
   721         }
       
   722     
       
   723     // Test set and get context source.
       
   724     ptr.Copy(KDefaultContextSourceName); 
       
   725     triggerNode.SetContextSource( ptr );
       
   726     if( triggerNode.GetContextSource() != KDefaultContextSourceName )
       
   727         {
       
   728         User::Leave( KErrArgument );
       
   729         }
       
   730     
       
   731     // Test set and get current state.
       
   732     triggerNode.SetCurrentStateL( ptr );
       
   733     if( triggerNode.GetCurrentState() != CLbtTriggerEntry::EStateEnabled )
       
   734         {
       
   735         User::Leave( KErrArgument );
       
   736         }
       
   737     
       
   738     CleanupStack::PopAndDestroy( buffer );
       
   739     return KErrNone;
       
   740     }
       
   741 
       
   742 
       
   743 // -----------------------------------------------------------------------------
       
   744 // CLbtUnitTestModule::TestGsmCellInfoMethodsL
       
   745 // (other items were commented in a header).
       
   746 // -----------------------------------------------------------------------------
       
   747 TInt CLbtUnitTestModule::TestGsmCellInfoMethodsL( CStifItemParser& /*aItem*/ )
       
   748     {
       
   749     // Test GSM cell info methods.
       
   750     RMmCustomAPI::TMmCellInfo info;
       
   751     
       
   752     //Construct dummy cell info with GSM params.
       
   753     info.iMode = RMmCustomAPI::TMmCellInfo::EGSM;
       
   754     
       
   755     info.iGsmCellInfo.iTA = 10;
       
   756     
       
   757     CLbtCellInfo* cellInfo = CLbtCellInfo::NewL( info );
       
   758     CleanupStack::PushL( cellInfo );
       
   759     
       
   760     // Get the GSM NMR array. 
       
   761     RArray<TGsmNMR> gsmArray = cellInfo->GetNMR();
       
   762     if( gsmArray.Count() != 0 )
       
   763         {
       
   764         User::Leave( KErrArgument );
       
   765         }
       
   766     
       
   767     // Check the count of cell info.
       
   768     if( cellInfo->Count() != 0 )
       
   769         {
       
   770         User::Leave( KErrArgument );
       
   771         }
       
   772 
       
   773     // Read the TA from the cell info.
       
   774     if( cellInfo->GetTA() != 10 )
       
   775         {
       
   776         User::Leave( KErrArgument );
       
   777         }
       
   778     //Get the cell id count for GSM network. It is not 
       
   779     // supported for GSM. Hence it should return 0.
       
   780     if( cellInfo->CellChangeCount() != 0 )
       
   781         {
       
   782         User::Leave( KErrArgument );
       
   783         }
       
   784     
       
   785     // Attempt to find GSM cell info at 0th index should fail.
       
   786     TGsmNMR gsmNmr;
       
   787     TInt index = 0;
       
   788     if( cellInfo->Find( index, gsmNmr ) )
       
   789         {
       
   790         User::Leave( KErrArgument );
       
   791         }
       
   792     
       
   793     // Add same cell info again
       
   794     cellInfo->AddNMRData( info );
       
   795     
       
   796     // Start the iterator
       
   797     CLbtCellInfo::TCellInfoArrayIterator itr = cellInfo->Begin();
       
   798     
       
   799     if( itr.Next( gsmNmr ) )
       
   800         {
       
   801         User::Leave( KErrArgument );
       
   802         }
       
   803     itr.Reset();
       
   804     
       
   805     // Reset the info
       
   806     cellInfo->Reset();
       
   807     
       
   808     CleanupStack::PopAndDestroy( cellInfo );
       
   809     return KErrNone;
       
   810     }
       
   811 
       
   812 
       
   813 // -----------------------------------------------------------------------------
       
   814 // CLbtUnitTestModule::TestWcdmaCellInfoMethodsL
       
   815 // (other items were commented in a header).
       
   816 // -----------------------------------------------------------------------------
       
   817 TInt CLbtUnitTestModule::TestWcdmaCellInfoMethodsL( CStifItemParser& /*aItem*/ )
       
   818     {
       
   819     // Test WCDMA cell info methods.
       
   820     RMmCustomAPI::TMmCellInfo info;
       
   821     
       
   822     //Construct dummy cell info with WCDMA params.
       
   823     info.iMode = RMmCustomAPI::TMmCellInfo::EWCDMA;
       
   824     
       
   825     //Set scrambling code and cell id.
       
   826     info.iWcdmaCellInfo.iPrimaryScrambilingCode = 10;
       
   827     info.iWcdmaCellInfo.iNwkMeasureReport[0].iCellMeasuredResult[0].iCID = 100;
       
   828     
       
   829     CLbtCellInfo* cellInfo = CLbtCellInfo::NewL( info );
       
   830     CleanupStack::PushL( cellInfo );
       
   831     
       
   832     // Get the WCDMA NMR array. 
       
   833     RArray<TWcdmaNMR> wcdmaArray = cellInfo->GetWcdmaNMR();
       
   834     if( wcdmaArray.Count() == 0 )
       
   835         {
       
   836         User::Leave( KErrArgument );
       
   837         }
       
   838     
       
   839     // Check the count of cell info.
       
   840     if( cellInfo->Count() == 0 )
       
   841         {
       
   842         User::Leave( KErrArgument );
       
   843         }
       
   844 
       
   845     //Get the cell id count for WCDMA network. It is not 
       
   846     // supported for GSM. Hence it should return 0.
       
   847     if( cellInfo->CellChangeCount() == 0 )
       
   848         {
       
   849         User::Leave( KErrArgument );
       
   850         }
       
   851     
       
   852 
       
   853     // Add same cell info again
       
   854     cellInfo->AddNMRData( info );
       
   855     
       
   856     // Start the iterator
       
   857     CLbtCellInfo::TCellInfoArrayIterator itr = cellInfo->Begin();
       
   858     
       
   859     TWcdmaNMR wcdmaNmr;
       
   860     if( !itr.Next( wcdmaNmr ) )
       
   861         {
       
   862         User::Leave( KErrArgument );
       
   863         }
       
   864     itr.Reset();
       
   865     
       
   866     // Reset the info
       
   867     cellInfo->Reset();
       
   868     
       
   869     CleanupStack::PopAndDestroy( cellInfo );
       
   870     return KErrNone;
       
   871     }
       
   872 
       
   873 // -----------------------------------------------------------------------------
       
   874 // CLbtUnitTestModule::TestLbtOperationsMethodL
       
   875 // (other items were commented in a header).
       
   876 // -----------------------------------------------------------------------------
       
   877 TInt CLbtUnitTestModule::TestLbtOperationsMethodL( CStifItemParser& /*aItem*/ )
       
   878     {
       
   879     CLbtGeoAreaBase* areaBase = NULL;
       
   880     TRequestStatus status;
       
   881     
       
   882     CLBTOperation* lbtOperation = CLBTOperation::CreateGeoAreaForCurrentLocationL( 
       
   883                                     status,
       
   884                                     CLbtGeoAreaBase::ECellular,
       
   885                                     &areaBase );
       
   886     delete lbtOperation;
       
   887     delete areaBase;
       
   888     return KErrNone;
       
   889     }
       
   890 
       
   891 // -----------------------------------------------------------------------------
       
   892 // CLbtUnitTestModule::HandleDiskSpaceChange
       
   893 // (other items were commented in a header).
       
   894 // -----------------------------------------------------------------------------
       
   895 void CLbtUnitTestModule::HandleDiskSpaceChange()
       
   896     {
       
   897     iWait->AsyncStop();
       
   898     }
       
   899 
       
   900 
       
   901 // -----------------------------------------------------------------------------
       
   902 // ThreadFunction
       
   903 // (other items were commented in a header).
       
   904 // -----------------------------------------------------------------------------
       
   905 TInt ThreadFunction( TAny* /*aParam*/)
       
   906     {
       
   907     TInt error;
       
   908     RFs fs;
       
   909     fs.Connect();
       
   910     RFile file;
       
   911     error = file.Create( fs,testFileName,EFileWrite);
       
   912     if(error == KErrAlreadyExists )
       
   913         {
       
   914         fs.Delete( testFileName );
       
   915         }   
       
   916     file.Close();
       
   917     fs.Close();
       
   918     return KErrNone;
       
   919     }
       
   920 
       
   921 
       
   922 
       
   923 //  [End of File]