lbstest/lbstestproduct/lbsx3p/src/ctlbsx3pstepnegative.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2006-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 // @file ctlbsx3pStep_Neg.cpp
       
    15 // This is the class implementation for the LBS Client Test Step Base
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "ctlbsx3pstepnegative.h"
       
    20 
       
    21 #include <lbs/test/tlbsutils.h>
       
    22 #include <lbs/test/ctlbsasyncwaiter.h>
       
    23 
       
    24 
       
    25 #include <lbs.h>
       
    26 #include <lbs/lbsx3p.h>
       
    27 
       
    28 
       
    29 //_LIT(KLbsRefPos, "RefPos");
       
    30 
       
    31 
       
    32 	
       
    33 /**
       
    34  * @return - TVerdict
       
    35  * Implementation of CTestStep base class virtual
       
    36  * It is used for doing all initialisation common to derived classes in here.
       
    37  * Make it being able to leave if there are any errors here as there's no point in
       
    38  * trying to run a test step if anything fails.
       
    39  * The leave will be picked up by the framework.
       
    40  */
       
    41 TVerdict CT_LbsX3PStep_Negative::doTestStepPreambleL()
       
    42 	{
       
    43 	// Process some common pre setting to test steps then set SetTestStepResult to EFail or Epass.
       
    44 	INFO_PRINTF1(_L("&gt;&gt;CT_LbsX3PStep_Negative::doTestStepPreambleL()"));
       
    45 	SetTestStepResult(EPass);
       
    46 
       
    47 	return TestStepResult();
       
    48 	}
       
    49 
       
    50 
       
    51 /**
       
    52  * @return - TVerdict
       
    53  * Implementation of CTestStep base class virtual
       
    54  * It is used for doing all after test treatment common to derived classes in here.
       
    55  * Make it being able to leave
       
    56  * The leave will be picked up by the framework.
       
    57  */
       
    58 TVerdict CT_LbsX3PStep_Negative::doTestStepPostambleL()
       
    59 	{
       
    60 	// Process some common post setting to test steps then set SetTestStepResult to EFail or Epass.
       
    61 	INFO_PRINTF1(_L("&gt;&gt;CT_LbsX3PStep_Negative::doTestStepPostabmleL()"));
       
    62 
       
    63 	//SetTestStepResult(EPass);  // or EFail
       
    64 	return TestStepResult();
       
    65 	}
       
    66 
       
    67 
       
    68 CT_LbsX3PStep_Negative::~CT_LbsX3PStep_Negative()
       
    69 	{
       
    70 	}
       
    71 
       
    72 
       
    73 CT_LbsX3PStep_Negative::CT_LbsX3PStep_Negative(CT_LbsX3PServer& aParent) : iParent(aParent)
       
    74 	{
       
    75 		SetTestStepName(KLbsX3P_Step_Negative);
       
    76 	}
       
    77 	
       
    78 	
       
    79 	/**
       
    80 Static Constructor
       
    81 */
       
    82 CT_LbsX3PStep_Negative* CT_LbsX3PStep_Negative::New(CT_LbsX3PServer& aParent)
       
    83 	{
       
    84 	CT_LbsX3PStep_Negative* testStep = new CT_LbsX3PStep_Negative(aParent);
       
    85 	// Note the lack of ELeave.
       
    86 	// This means that having insufficient memory will return NULL;	
       
    87 
       
    88 	if (testStep)
       
    89 		{
       
    90 		TInt err = KErrNone;
       
    91 
       
    92 		TRAP(err, testStep->ConstructL());
       
    93 		if (err)
       
    94 			{
       
    95 			delete testStep;
       
    96 			testStep = NULL;
       
    97 			}
       
    98 		}
       
    99 		
       
   100 	return testStep;
       
   101 	}
       
   102 	
       
   103 	
       
   104 
       
   105 void CT_LbsX3PStep_Negative::ConstructL()
       
   106 	{
       
   107 
       
   108 	}
       
   109 
       
   110 
       
   111 
       
   112 
       
   113 // Need to implement these to actually do a test.
       
   114 TVerdict CT_LbsX3PStep_Negative::doTestStepL()
       
   115 	{
       
   116 		// Generic test step used to test the LBS Client Notify position update API.
       
   117 	INFO_PRINTF1(_L("&gt;&gt;CT_LbsX3PStep_Transmit::doTestStepL()"));
       
   118 
       
   119 	if (TestStepResult() == EPass)
       
   120 		{
       
   121 			if (GetIntFromConfig(ConfigSection(), KTestCaseId, iTestCaseId))
       
   122 			{
       
   123 			switch (iTestCaseId)
       
   124 				{
       
   125 				
       
   126 				// NEGATIVE TEST
       
   127 				// Test case LBS-X3P-Options-0002 	Attempt to set an invalid timeout
       
   128 				case 02:
       
   129 					{
       
   130 					TLbsTransmitPositionOptions transmitOptions;
       
   131 					transmitOptions.SetTimeOut(-1);
       
   132 					
       
   133 				
       
   134 
       
   135 					}
       
   136 					break;
       
   137 					
       
   138 					
       
   139 				// NEGATIVE TEST
       
   140 				// Test case LBS-X3P-Transmit-0031
       
   141 				case 131:
       
   142 				{
       
   143 					// Test case LBS-X3P-Transmit-0031	Request X3P when we have no server connection
       
   144 					//
       
   145 					// External step:	Inform module of required single position to be transmitted.
       
   146 					// Local step:		Do X3P.
       
   147 					// Local callbacks:	Test will probably panic before we can verify callback parameters.
       
   148 					//					NotifyMeasurementReportLocation callback, aPosition should match iVerifyPosInfoArr.
       
   149 					//					TransmitPosition callback, aStatus should be KErrNone
       
   150 					
       
   151 					RLbsTransmitPositionServer testServer;
       
   152 					RLbsTransmitPosition testPositionTransmitter;					
       
   153 
       
   154 					testPositionTransmitter.Open(testServer);
       
   155 	
       
   156 
       
   157 
       
   158 					}
       
   159 					break;
       
   160 								
       
   161 				// NEGATIVE TEST
       
   162 				// Test case LBS-X3P-Transmit-0032
       
   163 				case 132:
       
   164 					{
       
   165 					// Test case LBS-X3P-Transmit-0032	Request X3P when we have no subsession connection
       
   166 					//
       
   167 					// External step:	Inform module of required single position to be transmitted.
       
   168 					// Local step:		Do X3P.
       
   169 					// Local callbacks:	Test will probably panic before we can verify callback parameters.
       
   170 					//					NotifyMeasurementReportLocation callback, aPosition should match iVerifyPosInfoArr.
       
   171 					//					TransmitPosition callback, aStatus should be KErrNone
       
   172 
       
   173 					//	1. Create a sub-session, but don't open it
       
   174 					RLbsTransmitPositionServer testServer;
       
   175 									
       
   176 					User::LeaveIfError(testServer.Connect()); 
       
   177 					CleanupClosePushL(testServer);
       
   178 
       
   179 					//	4. RLbsTransmitPosition sub-session
       
   180 					RLbsTransmitPosition testPositionTransmitter;
       
   181 					CleanupClosePushL(testPositionTransmitter);
       
   182 				
       
   183 					// Do transmit location.
       
   184 					TPositionInfo* 	pPosInfo;
       
   185 					TPositionInfo	positionInfo;
       
   186 					pPosInfo = &positionInfo;
       
   187 					CleanupStack::PushL(pPosInfo);
       
   188 			
       
   189 				    TBool bRefPos;
       
   190 				    bRefPos = GetIntFromConfig(ConfigSection(), KLbsRefPos, bRefPos);
       
   191 				    
       
   192 					// Kick off transmit position.
       
   193 					TRequestStatus status = 1;
       
   194 					if(bRefPos)
       
   195 						testPositionTransmitter.TransmitPosition(KBadDestination, KBadPriority, status, *pPosInfo, status, *pPosInfo);
       
   196 					else
       
   197 						testPositionTransmitter.TransmitPosition(KBadDestination, KBadPriority, status, *pPosInfo);
       
   198 				
       
   199 					
       
   200 					CleanupStack::Pop(pPosInfo);
       
   201 					}
       
   202 					break;
       
   203 								
       
   204 				default:
       
   205 					{
       
   206 					User::Panic(KLbsX3P_Step_Negative, KErrUnknown);
       
   207 					}
       
   208 					
       
   209 				}
       
   210 			}
       
   211 		}
       
   212 		
       
   213 	return TestStepResult();	
       
   214 	}
       
   215 
       
   216 
       
   217