lbs/lbsclient/src/ctlbsclientpostp227.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 
       
    19 //  INCLUDES
       
    20 #include "ctlbsclientpostp227.h"
       
    21 #include <EPos_CPosModules.h>
       
    22 #include <EPos_CPosModuleUpdate.h>
       
    23 #include <EPos_CPosModuleIdList.h>
       
    24 #include <LbsCommon.h>
       
    25 #include <LbsPositionInfo.h>
       
    26 
       
    27 
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // ================= MEMBER FUNCTIONS =======================
       
    32 
       
    33 // Constructor.
       
    34 CT_LbsClientPosTp227::CT_LbsClientPosTp227(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
       
    35     {  
       
    36     _LIT(KTestName, "TP227 - Settings API performance");
       
    37     SetTestStepName(KTestName); 
       
    38     }
       
    39 
       
    40 // Destructor
       
    41 CT_LbsClientPosTp227::~CT_LbsClientPosTp227() 
       
    42 	{
       
    43     
       
    44 	}
       
    45 
       
    46 // ---------------------------------------------------------
       
    47 // CT_LbsClientPosTp227::CloseTest
       
    48 //
       
    49 // (other items were commented in a header).
       
    50 // ---------------------------------------------------------
       
    51 //
       
    52 
       
    53 void CT_LbsClientPosTp227::CloseTest()
       
    54     {
       
    55     
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------
       
    59 // CT_LbsClientPosTp227::StartL
       
    60 //
       
    61 // (other items were commented in a header).
       
    62 // ---------------------------------------------------------
       
    63 //
       
    64 void CT_LbsClientPosTp227::StartL()
       
    65     {   
       
    66     TTime startTime;
       
    67     TTime stopTime;
       
    68         
       
    69     startTime.UniversalTime();
       
    70     
       
    71     CPosModules* db = CPosModules::OpenL();
       
    72     stopTime.UniversalTime();
       
    73     
       
    74     TInt duration =  stopTime.Int64() - startTime.Int64();
       
    75     
       
    76     if (duration > 500000)
       
    77 		{
       
    78     	_LIT(KDelayMsg, "Time taken to create CPosModules object was more than 0.5 second, it was %d microsecs.");
       
    79         TBuf<100> error;
       
    80         error.Format(KDelayMsg, duration);
       
    81         INFO_PRINTF1(error);    
       
    82 		}
       
    83     else
       
    84         {
       
    85         _LIT(KDelayMsg, "Time taken to create CPosModules object was %d microsecs.");
       
    86         TBuf<100> debug;
       
    87         debug.Format(KDelayMsg, duration);
       
    88         INFO_PRINTF1(debug);
       
    89         }
       
    90     
       
    91     CleanupStack::PushL(db);
       
    92           
       
    93     startTime.UniversalTime();
       
    94     CPosModuleIdList* prioList = db->ModuleIdListLC();
       
    95     
       
    96     stopTime.UniversalTime();
       
    97     duration =  stopTime.Int64() - startTime.Int64();
       
    98     
       
    99     if (duration > 20000)
       
   100 		{
       
   101     	_LIT(KDelayMsg, "Time taken to get list using ModuleIdListLC() was more than 0.02 second, it was %d microsecs.");
       
   102         TBuf<100> error;
       
   103         error.Format(KDelayMsg, duration);
       
   104         INFO_PRINTF1(error);
       
   105 		}
       
   106     else
       
   107         {
       
   108         _LIT(KDelayMsg, "Time taken to get list using ModuleIdListLC() was %d microsecs.");
       
   109         TBuf<100> debug;
       
   110         debug.Format(KDelayMsg, duration);
       
   111         INFO_PRINTF1(debug);
       
   112         }
       
   113 
       
   114     TPositionModuleInfo moduleInfo;
       
   115     TInt64 MaxDuration=0;
       
   116     
       
   117     for ( TInt count = 0 ; count < prioList->Count() ; count++)
       
   118         {                    
       
   119         startTime.UniversalTime();
       
   120         db->GetModuleInfoL((*prioList)[count], moduleInfo);
       
   121         stopTime.UniversalTime();
       
   122         duration =  stopTime.Int64() - startTime.Int64();
       
   123         
       
   124         if( duration>MaxDuration )
       
   125             MaxDuration=duration;           
       
   126         }
       
   127 
       
   128     if (MaxDuration > 10000)
       
   129 		{
       
   130     	_LIT(KDelayMsg, "Time taken for GetModuleInfoL() was more than 0.01 sec, it was %d microsecs.");
       
   131         TBuf<100> error;
       
   132         error.Format(KDelayMsg, duration);
       
   133         INFO_PRINTF1(error);
       
   134 		}
       
   135     else
       
   136         {
       
   137         _LIT(KDelayMsg, "Time taken for GetModuleInfoL() was %d microsecs.");
       
   138         TBuf<100> debug;
       
   139         debug.Format(KDelayMsg, duration);
       
   140         INFO_PRINTF1(debug);
       
   141         }
       
   142     
       
   143     CleanupStack::PopAndDestroy(prioList); // prioList
       
   144     
       
   145     TInt visiblestate=1;
       
   146     CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC(); // destroy!
       
   147     moduleUpdate->SetUpdateAvailability(ETrue);
       
   148     
       
   149     MaxDuration=0;
       
   150     for(TInt i=0;i<10;i++)
       
   151     {
       
   152 	    if(visiblestate)
       
   153 	    { 
       
   154 	    moduleUpdate->SetUpdateVisibility(EFalse);
       
   155 	    visiblestate=0;
       
   156 	    }
       
   157 	    else
       
   158 	    { 
       
   159 	    moduleUpdate->SetUpdateVisibility(ETrue);
       
   160 	    visiblestate=1;
       
   161 	    }
       
   162 	    
       
   163 	    db->UpdateModuleL(iUidTestPsy2, *moduleUpdate);
       
   164 	    
       
   165 	    startTime.UniversalTime();
       
   166 	    prioList = db->ModuleIdListLC();
       
   167 	    stopTime.UniversalTime();
       
   168 	    duration =  stopTime.Int64() - startTime.Int64();
       
   169 	    
       
   170 	    if( duration> MaxDuration)
       
   171 	    MaxDuration=duration;
       
   172 
       
   173 	    CleanupStack::PopAndDestroy(prioList);
       
   174     }
       
   175   
       
   176     if (MaxDuration > 50000)
       
   177 		{
       
   178     	_LIT(KDelayMsg, "Time taken was more than 0.05 second, it was %d microsecs.");
       
   179         TBuf<100> error;
       
   180         error.Format(KDelayMsg, duration);
       
   181         INFO_PRINTF1(error);
       
   182 		}
       
   183     else
       
   184         {
       
   185         _LIT(KDelayMsg, "Time taken was %d microsecs.");
       
   186         TBuf<100> debug;
       
   187         debug.Format(KDelayMsg, duration);
       
   188         INFO_PRINTF1(debug);
       
   189         }
       
   190         
       
   191        CleanupStack::PopAndDestroy(2); //moduleUpdate,db   
       
   192     }
       
   193     
       
   194 // ---------------------------------------------------------
       
   195 // CT_LbsClientPosTp227::AssertTrueSecL
       
   196 //
       
   197 // (other items were commented in a header).
       
   198 // ---------------------------------------------------------
       
   199 //
       
   200 void CT_LbsClientPosTp227::AssertTrueL(TBool aCondition, const TDesC& aErrorMsg)
       
   201     {
       
   202   	if (!aCondition)
       
   203 		{
       
   204 		TBuf<100> buf;
       
   205 		buf.Format(aErrorMsg);
       
   206 		LogErrorAndLeaveL(buf);
       
   207 		}
       
   208     }
       
   209 
       
   210