lbstest/lbstestproduct/lbssimulationpsy/src/ctlbssimulationpsypostp262.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-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 "ctlbssimulationpsypostp262.h"
       
    20 
       
    21 // CONSTANTS
       
    22 
       
    23 #ifdef __WINS__    
       
    24     _LIT(KSimFile, "z:\\system\\test\\TestData\\simulationData.sps");
       
    25     _LIT(KSimFileBadSyntax, "z:\\system\\test\\TestData\\simulationBadSyntax1.sps");
       
    26     //simulationBadSyntax1.sps
       
    27     _LIT(KIncorrectNmeaFile, "z:\\system\\test\\TestData\\IncorrectChecksum.nme");
       
    28 #else
       
    29     _LIT(KSimFile, "c:\\system\\test\\TestData\\simulationData.sps");
       
    30     _LIT(KIncorrectNmeaFile, "c:\\system\\test\\TestData\\IncorrectChecksum.nme");
       
    31     _LIT(KSimFileBadSyntax, "c:\\system\\test\\TestData\\simulationBadSyntax1.sps");
       
    32 #endif
       
    33 
       
    34 _LIT(KServiceName, "TP262");
       
    35 
       
    36 
       
    37 // ---------------------------------------------------------
       
    38 // Constructor.
       
    39 // ---------------------------------------------------------
       
    40 CT_LbsSimulationPSYPosTp262::CT_LbsSimulationPSYPosTp262(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
       
    41 	{
       
    42 	_LIT(KTestName, "TP262 - Status Events");
       
    43 	SetTestStepName(KTestName);
       
    44 	}
       
    45 
       
    46 // ---------------------------------------------------------
       
    47 // Destructor.
       
    48 // ---------------------------------------------------------
       
    49 CT_LbsSimulationPSYPosTp262::~CT_LbsSimulationPSYPosTp262()
       
    50 	{
       
    51 	}
       
    52 
       
    53 // ---------------------------------------------------------
       
    54 // CT_LbsSimulationPSYPosTp262::StartL
       
    55 //
       
    56 // (other items were commented in a header).
       
    57 // ---------------------------------------------------------
       
    58 //
       
    59 void CT_LbsSimulationPSYPosTp262::StartL()
       
    60     {
       
    61     _LIT(KConnectErr, "Error when connecing to Position Server, %d");
       
    62     
       
    63     TInt err = iPosServer.Connect();
       
    64 	AssertTrueL(err == KErrNone, KConnectErr, err); 
       
    65 	
       
    66     //SIMULATION mode starts here
       
    67     //normal case in simulation mode
       
    68 	_LIT(KInfDatafileCorrect, "***Correct sim datafile***");
       
    69     INFO_PRINTF1(KInfDatafileCorrect);
       
    70     SetSimDataFileL(KSimFile);
       
    71 
       
    72     iModuleEvent.SetRequestedEvents(TPositionModuleStatusEvent::EEventAll);
       
    73     
       
    74     OpenL(KErrNone);
       
    75 
       
    76     VerifyStatusRequestL(
       
    77                     TPositionModuleStatus::EDeviceReady, 
       
    78                     TPositionModuleStatus::EDataQualityNormal);
       
    79 
       
    80     iPositioner.SetRequestor(
       
    81                     CRequestor::ERequestorService,
       
    82 					CRequestor::EFormatApplication, KServiceName);
       
    83 
       
    84     MakePosRequestL(KErrNone);
       
    85     CloseAndVerifyStatusL();
       
    86    
       
    87     //Missing sim data file
       
    88     _LIT(KInfDatafileMissing, "***Missing sim datafile***");
       
    89     INFO_PRINTF1(KInfDatafileMissing);
       
    90     _LIT(KPath, "c:\\dfsfsdf.sps");
       
    91     SetSimDataFileL(KPath); //maybe also test a file that does not exist and
       
    92     OpenL(KErrNotFound);
       
    93 
       
    94     VerifyStatusRequestL(
       
    95                     TPositionModuleStatus::EDeviceError, 
       
    96                     TPositionModuleStatus::EDataQualityUnknown);
       
    97 
       
    98     CloseAndVerifyStatusL();
       
    99 
       
   100     //bad syntax sim datafile
       
   101     _LIT(KInfDatafileBadSintax, "***Bad syntax sim datafile***");
       
   102     INFO_PRINTF1(KInfDatafileBadSintax);
       
   103     SetSimDataFileL(KSimFileBadSyntax);
       
   104     OpenL(KErrCorrupt);
       
   105 
       
   106     VerifyStatusRequestL(
       
   107                     TPositionModuleStatus::EDeviceError, 
       
   108                     TPositionModuleStatus::EDataQualityUnknown);
       
   109 
       
   110     CloseAndVerifyStatusL();
       
   111 
       
   112     //NMEA test starts here
       
   113     //bad checksum, but this should not affect anything should
       
   114     //be treated as the normal case just a little bit more tricky
       
   115     _LIT(KInfDatafileCorrectNmea, "***Correct nmea datafile***");
       
   116     INFO_PRINTF1(KInfDatafileCorrectNmea);
       
   117     SetSimDataFileL(KIncorrectNmeaFile);
       
   118     
       
   119     OpenL(KErrNone); 
       
   120     VerifyStatusRequestL(
       
   121                     TPositionModuleStatus::EDeviceReady, 
       
   122                     TPositionModuleStatus::EDataQualityNormal);
       
   123     
       
   124     iPositioner.SetRequestor(
       
   125                     CRequestor::ERequestorService,
       
   126 					CRequestor::EFormatApplication, KServiceName);   
       
   127 
       
   128     MakePosRequestL(KErrNone);
       
   129 
       
   130     CloseAndVerifyStatusL();    
       
   131 
       
   132     //missing nme datafile
       
   133     _LIT(KInfDatafileMissingNmea, "***Missing nme datafile***");
       
   134     INFO_PRINTF1(KInfDatafileMissingNmea);
       
   135     _LIT(KFileName, "dfsfsdf.nme");
       
   136     SetSimDataFileL(KFileName);
       
   137     // For some reason if no drive is specified in filename, KErrPathNotFound is returned
       
   138     OpenL(KErrPathNotFound);
       
   139 
       
   140     VerifyStatusRequestL(
       
   141                     TPositionModuleStatus::EDeviceError, 
       
   142                     TPositionModuleStatus::EDataQualityUnknown);
       
   143 
       
   144     CloseAndVerifyStatusL();
       
   145 
       
   146     //general test cases starts here
       
   147     _LIT(KInfSimNotNmeOrSps, "***sim file that is neither nme or sps file***");
       
   148     INFO_PRINTF1(KInfSimNotNmeOrSps);
       
   149     _LIT(Kdfsfsdf, "dfsfsdf");
       
   150     SetSimDataFileL(Kdfsfsdf);
       
   151     OpenL(KErrNotSupported);
       
   152 
       
   153     VerifyStatusRequestL(
       
   154                     TPositionModuleStatus::EDeviceError, 
       
   155                     TPositionModuleStatus::EDataQualityUnknown);
       
   156 
       
   157     CloseAndVerifyStatusL();
       
   158 
       
   159 	//Test with empty string as simulation data file in registry
       
   160     _LIT(KEmptyStringFile, "***empty string as file***");
       
   161     INFO_PRINTF1(KEmptyStringFile);
       
   162     _LIT(KEmptyString, "");
       
   163     SetSimDataFileL(KEmptyString);
       
   164 
       
   165   }
       
   166 
       
   167 // ---------------------------------------------------------
       
   168 // CT_LbsSimulationPSYPosTp262::OpenL
       
   169 //
       
   170 // (other items were commented in a header).
       
   171 // ---------------------------------------------------------
       
   172 //
       
   173 void CT_LbsSimulationPSYPosTp262::OpenL(const TInt aExpectedError)
       
   174     {
       
   175     _LIT(KFunctionName, "Opening");
       
   176     INFO_PRINTF1(KFunctionName);
       
   177     _LIT(KOpenErr, "Error or unexpected error when opening positioner,  %d");
       
   178     
       
   179     IssueStatusRequest();
       
   180     TInt err = iPositioner.Open(iPosServer, iUidSimulationPsy);
       
   181   
       
   182     User::WaitForRequest(iEventStatus);  
       
   183     AssertTrueL(err == aExpectedError, KOpenErr, err);
       
   184     }
       
   185 
       
   186 // ---------------------------------------------------------
       
   187 // CT_LbsSimulationPSYPosTp262::OpenAndVerifyStatus
       
   188 //
       
   189 // (other items were commented in a header).
       
   190 // ---------------------------------------------------------
       
   191 //
       
   192 void CT_LbsSimulationPSYPosTp262::CloseAndVerifyStatusL()
       
   193     {
       
   194     _LIT(KFunctionName, "Closing and verifying status");
       
   195     INFO_PRINTF1(KFunctionName);
       
   196    
       
   197     IssueStatusRequest();
       
   198     iPositioner.Close();
       
   199     User::WaitForRequest(iEventStatus); 
       
   200    
       
   201     VerifyStatusRequestL(
       
   202                     TPositionModuleStatus::EDeviceInactive, 
       
   203                     TPositionModuleStatus::EDataQualityUnknown);
       
   204 
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------
       
   208 // CT_LbsSimulationPSYPosTp262::OpenAndVerifyStatus
       
   209 //
       
   210 // (other items were commented in a header).
       
   211 // ---------------------------------------------------------
       
   212 //
       
   213 void CT_LbsSimulationPSYPosTp262::MakePosRequestL(const TInt aExpectedStatus)
       
   214     {
       
   215     _LIT(KInfoFunction, "Requests a positioning and verifies completed status");
       
   216     INFO_PRINTF1(KInfoFunction);
       
   217     _LIT(KStatusErr, "Unexpected status when request completed , %d");
       
   218     
       
   219     TRequestStatus status;
       
   220     TPositionInfo posInfo;
       
   221     iPositioner.NotifyPositionUpdate(posInfo, status);
       
   222     User::WaitForRequest(status);
       
   223 
       
   224     AssertTrueL(status.Int() == aExpectedStatus, KStatusErr, status.Int());
       
   225     }
       
   226 
       
   227 // ---------------------------------------------------------
       
   228 // CT_LbsSimulationPSYPosTp262::IssueStatusRequest()
       
   229 //
       
   230 // (other items were commented in a header).
       
   231 // ---------------------------------------------------------
       
   232 //
       
   233 void CT_LbsSimulationPSYPosTp262::IssueStatusRequest()
       
   234     {
       
   235     _LIT(KFunctionName, "We are inside IssueStatusRequest()");
       
   236     INFO_PRINTF1(KFunctionName);
       
   237     iPosServer.NotifyModuleStatusEvent(iModuleEvent, iEventStatus, iUidSimulationPsy);
       
   238     }
       
   239     
       
   240 // ---------------------------------------------------------
       
   241 // CT_LbsSimulationPSYPosTp262::VerifyStatusRequest()
       
   242 //
       
   243 // (other items were commented in a header).
       
   244 // ---------------------------------------------------------
       
   245 //
       
   246 void CT_LbsSimulationPSYPosTp262::VerifyStatusRequestL(
       
   247                                 const TPositionModuleStatus::TDeviceStatus& aStatus,
       
   248                                 const TPositionModuleStatus::TDataQualityStatus& aQuality)
       
   249     {
       
   250     _LIT(KInfFunction, "Verifies reported device status and quality status");
       
   251     INFO_PRINTF1(KInfFunction);
       
   252 
       
   253     _LIT(KStatusErr, "NotifyModuleStatusEvent is not returning status KErrNone but %d");
       
   254     _LIT(KDeviceStatusErr, "The PSY has not reported expected Device Status"); 
       
   255     _LIT(KQualityStatusErr, "The PSY has not reported expected Quality Status");
       
   256     
       
   257     AssertTrueL(iEventStatus.Int() == KErrNone, KStatusErr, iEventStatus.Int());
       
   258 
       
   259     TPositionModuleStatus moduleStatus;
       
   260     iModuleEvent.GetModuleStatus(moduleStatus);
       
   261     
       
   262     TInt deviceStatus = moduleStatus.DeviceStatus();  
       
   263     TInt qualityStatus = moduleStatus.DataQualityStatus(); 
       
   264     AssertTrueL(deviceStatus == aStatus, KDeviceStatusErr, KErrGeneral);
       
   265     AssertTrueL(qualityStatus == aQuality, KQualityStatusErr, KErrGeneral);
       
   266     
       
   267     }
       
   268 
       
   269 // ---------------------------------------------------------
       
   270 // CT_LbsSimulationPSYPosTp262::CloseTest()
       
   271 //
       
   272 // (other items were commented in a header).
       
   273 // ---------------------------------------------------------
       
   274 //
       
   275 void CT_LbsSimulationPSYPosTp262::CloseTest()
       
   276 	{
       
   277     iPosServer.CancelRequest(EPositionServerNotifyModuleStatusEvent);
       
   278   
       
   279     iPositioner.Close();
       
   280     iPosServer.Close();
       
   281     }
       
   282 
       
   283 //  End of File