lbs/lbsclient/src/ctlbsclientpostp271.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2002-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 //  INCLUDES
       
    19 #include "ctlbsclientpostp271.h"
       
    20 
       
    21 #include <LbsSatellite.h>
       
    22 #include <EPos_CPosModules.h>
       
    23 #include <EPos_CPosModuleUpdate.h>
       
    24 #include <EPos_CPosModuleIdList.h>
       
    25 #include <e32std.h>
       
    26 
       
    27 // CONSTANTS                                
       
    28 
       
    29 const TInt KUpdateInterval  = 1000;
       
    30 const TInt KUpdateInterval2 = 2000;
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 
       
    34 
       
    35 // ---------------------------------------------------------
       
    36 // Constructor.
       
    37 // ---------------------------------------------------------
       
    38 CT_LbsClientPosTp271::CT_LbsClientPosTp271(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
       
    39 	{ 
       
    40 	_LIT(KTestName,"Tp271-Fallback in Default Proxy,Perodic Update");
       
    41 	SetTestStepName(KTestName); 
       
    42 	}
       
    43 
       
    44 // ---------------------------------------------------------
       
    45 // Destructor.
       
    46 // ---------------------------------------------------------
       
    47 CT_LbsClientPosTp271::~CT_LbsClientPosTp271()
       
    48 	{
       
    49 	}
       
    50 
       
    51 // ---------------------------------------------------------
       
    52 // CT_LbsClientPosTp271::StartL
       
    53 //
       
    54 // (other items were commented in a header).
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 void CT_LbsClientPosTp271::StartL()
       
    58     {   
       
    59     ConnectL();
       
    60 
       
    61     SetupProxyPSYsL();
       
    62     
       
    63     iModuleEvent.SetRequestedEvents(TPositionModuleStatusEvent::EEventAll);
       
    64 
       
    65     TInt err = OpenPositioner();
       
    66     _LIT(KOpenErr, "Error when opening positioner, %d");
       
    67     AssertTrueSecL(err == KErrNone, KOpenErr, err);
       
    68     
       
    69     _LIT(KServiceName, "TP271");
       
    70     iPositioner.SetRequestor(CRequestor::ERequestorService, CRequestor::EFormatApplication, KServiceName);
       
    71 
       
    72     TUint request = 20;    
       
    73     TPositionInfo posInfo;
       
    74     /////////////////////////////////////////////
       
    75 	// Request 1
       
    76 	/////////////////////////////////////////////    
       
    77     RequestL(posInfo, ++request, KEspectedErrorCodePSY2);
       
    78    
       
    79     // Used test PSYs reports ready when loaded, inactive when unloaded
       
    80     VerifyPsyLoadedL(iUidTestProxyPsy1);
       
    81     VerifyPsyLoadedL(iUidTestProxyPsy2);
       
    82 
       
    83     // Set periodic update
       
    84     TPositionUpdateOptions updateOptions;
       
    85 	updateOptions.SetUpdateInterval(TTimeIntervalMicroSeconds(KUpdateInterval));
       
    86 
       
    87 	err = iPositioner.SetUpdateOptions(updateOptions);
       
    88     _LIT(KUpdateErr, "Error when setting update interval,  %d");
       
    89 	AssertTrueL(err == KErrNone, KUpdateErr, err);    
       
    90     
       
    91     /////////////////////////////////////////////
       
    92 	// Request 2
       
    93 	/////////////////////////////////////////////
       
    94     RequestL(posInfo, ++request, KEspectedErrorCodePSY3);
       
    95    
       
    96     
       
    97     /////////////////////////////////////////////
       
    98 	// Request 3
       
    99 	/////////////////////////////////////////////
       
   100     RequestL(posInfo, ++request, KEspectedErrorCodePSY2);
       
   101 
       
   102     VerifyPsyStartedTrackingL(iUidTestProxyPsy1); // Verify that still loaded, latest reported event
       
   103     VerifyPsyStartedTrackingL(iUidTestProxyPsy2); // should still be the same
       
   104     VerifyPsyStartedTrackingL(iUidTestProxyPsy3); 
       
   105 
       
   106     /////////////////////////////////////////////
       
   107 	// Request 4
       
   108 	/////////////////////////////////////////////    
       
   109     updateOptions.SetUpdateInterval(TTimeIntervalMicroSeconds(KUpdateInterval2));
       
   110     err = iPositioner.SetUpdateOptions(updateOptions);
       
   111 	AssertTrueL(err == KErrNone, KUpdateErr, err);    
       
   112 
       
   113     RequestL(posInfo, ++request, KEspectedErrorCodePSY2);
       
   114     
       
   115     VerifyPsyStartedTrackingL(iUidTestProxyPsy1);
       
   116     VerifyPsyStartedTrackingL(iUidTestProxyPsy2);
       
   117    
       
   118     /////////////////////////////////////////////
       
   119 	// Request 5
       
   120 	/////////////////////////////////////////////
       
   121     updateOptions.SetUpdateInterval(TTimeIntervalMicroSeconds(0));
       
   122     err = iPositioner.SetUpdateOptions(updateOptions);
       
   123 	AssertTrueL(err == KErrNone, KUpdateErr, err);    
       
   124     
       
   125     VerifyPsyStoppedTrackingL(iUidTestProxyPsy1);
       
   126     VerifyPsyStoppedTrackingL(iUidTestProxyPsy2);
       
   127 
       
   128     RequestL(posInfo, ++request, KEspectedErrorCodePSY3);
       
   129  
       
   130     VerifyPsyStoppedTrackingL(iUidTestProxyPsy1); // Verifies that still loaded,
       
   131     VerifyPsyStoppedTrackingL(iUidTestProxyPsy2); // Verifies that still loaded,
       
   132 
       
   133     /////////////////////////////////////////////
       
   134 	// Request 6
       
   135 	/////////////////////////////////////////////
       
   136     updateOptions.SetUpdateInterval(TTimeIntervalMicroSeconds(KUpdateInterval));
       
   137 	err = iPositioner.SetUpdateOptions(updateOptions);
       
   138 	AssertTrueL(err == KErrNone, KUpdateErr, err);    
       
   139     
       
   140     RequestL(posInfo, ++request, KEspectedErrorCodePSY1);
       
   141             
       
   142     iPositioner.Close();
       
   143     
       
   144     VerifyPsyUnloadedL(iUidTestProxyPsy1);
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------
       
   148 // CT_LbsClientPosTp271::CloseTest
       
   149 //
       
   150 // (other items were commented in a header).
       
   151 // ---------------------------------------------------------
       
   152 //
       
   153 void CT_LbsClientPosTp271::CloseTest()
       
   154     {
       
   155     iPositioner.Close();
       
   156     iPosServer.Close();
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------
       
   160 // CT_LbsClientPosTp271::AssertTrueSecL
       
   161 //
       
   162 // (other items were commented in a header).
       
   163 // ---------------------------------------------------------
       
   164 //
       
   165 void CT_LbsClientPosTp271::AssertTrueSecL(TBool aCondition, const TDesC& aErrorMsg, TInt aErrorCode)
       
   166     {
       
   167   	if (!aCondition)
       
   168 		{
       
   169 		TBuf<100> buf;
       
   170 		buf.Format(aErrorMsg, aErrorCode);
       
   171 		LogErrorAndLeaveL(buf);
       
   172 		}
       
   173     }
       
   174    
       
   175 // ---------------------------------------------------------
       
   176 // CT_LbsClientPosTp271::SetupProxyPSYsL
       
   177 //
       
   178 // (other items were commented in a header).
       
   179 // ---------------------------------------------------------
       
   180 //
       
   181 void CT_LbsClientPosTp271::SetupProxyPSYsL()
       
   182     {
       
   183     CPosModules* db = CPosModules::OpenL();
       
   184     CleanupStack::PushL(db);
       
   185 
       
   186     CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
       
   187 
       
   188     moduleUpdate->SetUpdateAvailability(EFalse);
       
   189     
       
   190     CPosModuleIdList* prioList = db->ModuleIdListLC();
       
   191 
       
   192     // Disable all PSY:s except PSYs used by this TP271, TP270
       
   193     for (TInt i = 0 ; i < prioList->Count(); i++)
       
   194         {
       
   195         if ((*prioList)[i] != iUidTestProxyPsy1 &&
       
   196             (*prioList)[i] != iUidTestProxyPsy2 &&
       
   197             (*prioList)[i] != iUidTestProxyPsy3)
       
   198             {
       
   199             db->UpdateModuleL((*prioList)[i], *moduleUpdate);
       
   200             }
       
   201         }
       
   202     moduleUpdate->SetUpdateAvailability(ETrue);
       
   203     db->UpdateModuleL(iUidTestProxyPsy1, *moduleUpdate);
       
   204     db->UpdateModuleL(iUidTestProxyPsy2, *moduleUpdate);
       
   205     db->UpdateModuleL(iUidTestProxyPsy3, *moduleUpdate);
       
   206 
       
   207     db->SetModulePriorityL(iUidTestProxyPsy1, 0);
       
   208     db->SetModulePriorityL(iUidTestProxyPsy2, 1);
       
   209     db->SetModulePriorityL(iUidTestProxyPsy3, 2);
       
   210 
       
   211     CleanupStack::PopAndDestroy(prioList);
       
   212     CleanupStack::PopAndDestroy(moduleUpdate);
       
   213     CleanupStack::PopAndDestroy(db);
       
   214     } 
       
   215 
       
   216 // ---------------------------------------------------------
       
   217 // CT_LbsClientPosTp271::VerifyPsyStartedUnloadedL
       
   218 //
       
   219 // (other items were commented in a header).
       
   220 // ---------------------------------------------------------
       
   221 //
       
   222 void CT_LbsClientPosTp271::VerifyPsyStartedTrackingL(TPositionModuleId& aUid)                           
       
   223     {
       
   224     _LIT(KPSYStatus,"Verifies if correct PSY is loaded by getting its status");
       
   225     INFO_PRINTF1(KPSYStatus);
       
   226 
       
   227     _LIT(KDeviceStatusErr, "The PSY has not reported expected Device Status and is not notified about start tracking"); 
       
   228     
       
   229     TPositionModuleStatus moduleStatus;
       
   230     iPosServer.GetModuleStatus(moduleStatus, aUid); 
       
   231 
       
   232     AssertTrueL(TPositionModuleStatus::EDeviceInitialising == moduleStatus.DeviceStatus(), KDeviceStatusErr, KErrGeneral);
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------
       
   236 // CT_LbsClientPosTp271::VerifyPsyStoppedTrackingL
       
   237 //
       
   238 // (other items were commented in a header).
       
   239 // ---------------------------------------------------------
       
   240 //
       
   241 void CT_LbsClientPosTp271::VerifyPsyStoppedTrackingL(TPositionModuleId& /*aUid*/, TRequestStatus& aStatus)
       
   242     {
       
   243     _LIT(KPSYStatus,"Verifies that correct PSY has stopped tracking and is unloaded");
       
   244     INFO_PRINTF1(KPSYStatus);
       
   245     
       
   246     _LIT(KStoppedTrackingErr, "The PSY has not reported expected device status and has not stopped tracking"); 
       
   247     
       
   248     TPositionModuleStatus moduleStatus;
       
   249    
       
   250     User::WaitForRequest(aStatus); 
       
   251              
       
   252     iModuleEvent.GetModuleStatus(moduleStatus);
       
   253    
       
   254     AssertTrueL(TPositionModuleStatus::EDeviceStandBy == moduleStatus.DeviceStatus(), 
       
   255                 KStoppedTrackingErr, 
       
   256                 KErrGeneral);
       
   257 
       
   258    
       
   259     }
       
   260 // ---------------------------------------------------------
       
   261 // CT_LbsClientPosTp271::VerifyPsyStoppedTrackingL
       
   262 //
       
   263 // (other items were commented in a header).
       
   264 // ---------------------------------------------------------
       
   265 //
       
   266 void CT_LbsClientPosTp271::VerifyPsyStoppedTrackingL(TPositionModuleId& aUid)
       
   267     {
       
   268     _LIT(KPSYStatus,"Verifies that correct PSY has stopped tracking and is unloaded");
       
   269     INFO_PRINTF1(KPSYStatus);
       
   270     
       
   271     _LIT(KStoppedTrackingErr, "The PSY has not reported expected device status and has not stopped tracking"); 
       
   272     
       
   273     TPositionModuleStatus moduleStatus;
       
   274    
       
   275     iPosServer.GetModuleStatus(moduleStatus, aUid); 
       
   276    
       
   277     AssertTrueL(TPositionModuleStatus::EDeviceStandBy == moduleStatus.DeviceStatus(), 
       
   278                 KStoppedTrackingErr, 
       
   279                 KErrGeneral);
       
   280     }
       
   281 
       
   282 //  End of File