wapstack/wapmessageapi/te_wapstack/src/WapBoundWSPSteps.cpp
branchRCL_3
changeset 18 50bae5c5c85f
equal deleted inserted replaced
17:3f227a47ad75 18:50bae5c5c85f
       
     1 // Copyright (c) 2003-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 // CStepOne derived implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include "WapBoundWSPSteps.h"
       
    24 #include "WapStackSuiteDefs.h"
       
    25 #include <simtsy.h>
       
    26 #include <ecom/ecom.h>
       
    27 
       
    28 CBoundWSPStepBase::CBoundWSPStepBase()
       
    29 /**
       
    30 * Constructor
       
    31 */
       
    32 	{
       
    33 	}
       
    34 
       
    35 CBoundWSPStepBase::~CBoundWSPStepBase()
       
    36 /**
       
    37 * Destructor
       
    38 */
       
    39 	{
       
    40 	if(iImp) 
       
    41 		{
       
    42 		UnloadInterface();
       
    43 		}
       
    44 	}
       
    45 
       
    46 CWapBoundCLWSPService* CBoundWSPStepBase::LoadInterface()
       
    47 	{
       
    48 	TInt trapValue;
       
    49 	CWapBoundCLWSPService* implementation = NULL;
       
    50 	// UID {0x101FBB3C} - SWS implementation
       
    51 	TUid KInterfaceUid = {0x101FBB3C}; 	
       
    52 	INFO_PRINTF2(_L("Calling new NewL(0x%08X) method"), KInterfaceUid);
       
    53 	TRAP(trapValue, implementation = CWapBoundCLWSPService::NewL(KInterfaceUid));
       
    54 	if(!trapValue)
       
    55 		{
       
    56 		INFO_PRINTF2(_L("Interface is loaded: implementation.addr = 0x%08x"), implementation);
       
    57 		return implementation;
       
    58 		}
       
    59 	else return NULL;
       
    60 	}
       
    61 
       
    62 void CBoundWSPStepBase::UnloadInterface()
       
    63 	{
       
    64 	INFO_PRINTF2(_L("Interface at implementation.addr = 0x%08x is deleted"), iImp);
       
    65 	delete iImp;
       
    66 	iImp = NULL;
       
    67 	REComSession::FinalClose();	
       
    68 	}
       
    69 
       
    70 CBoundWSPStep_1::~CBoundWSPStep_1()
       
    71 /**
       
    72 * Destructor
       
    73 */
       
    74 	{
       
    75 	}
       
    76 
       
    77 CBoundWSPStep_1::CBoundWSPStep_1()
       
    78 /**
       
    79 * Constructor
       
    80 */
       
    81 	{
       
    82 	}
       
    83 
       
    84 TVerdict CBoundWSPStep_1::doTestStepL()
       
    85 /**
       
    86 * @return - TVerdict code
       
    87 * Override of base class pure virtual
       
    88 * Our implementation only gets called if the base class doTestStepPreambleL() did
       
    89 * not leave. That being the case, the current test result value will be EPass.
       
    90 */
       
    91 	{
       
    92 	//
       
    93 	// CWapBoundCLWSPService
       
    94 	// 
       
    95 	INFO_PRINTF1(_L("CreateImplementation - CWapBoundCLWSPService"));
       
    96 	INFO_PRINTF1(_L("Calling old NewL() method"));
       
    97 	
       
    98 	TInt trapValue; 
       
    99 	
       
   100 	SetTestStepResult(EFail);
       
   101 	TRAP(trapValue, iImp = CWapBoundCLWSPService::NewL());
       
   102 	if(!trapValue)
       
   103 		{
       
   104 		// interface is loaded
       
   105 		INFO_PRINTF2(_L("Interface is loaded: implementation.addr = 0x%08x"), iImp);
       
   106 		UnloadInterface();
       
   107 		iImp = LoadInterface();
       
   108 		if(iImp)
       
   109 			{
       
   110 			INFO_PRINTF1(_L("CreateImplementation - OK"));
       
   111 			SetTestStepResult(EPass);
       
   112 			UnloadInterface();
       
   113 			}
       
   114 		}
       
   115 	return TestStepResult();
       
   116 	}
       
   117 
       
   118 CBoundWSPStep_2::CBoundWSPStep_2()
       
   119 /**
       
   120 * Constructor
       
   121 */
       
   122 	{
       
   123 	}
       
   124 
       
   125 CBoundWSPStep_2::~CBoundWSPStep_2() 
       
   126 /**
       
   127 * Destructor
       
   128 */
       
   129 	{
       
   130 	}
       
   131 
       
   132 TVerdict CBoundWSPStep_2::doTestStepL()
       
   133 /** 
       
   134 * Test Connect methoths 
       
   135 * @return - TVerdict code
       
   136 * 
       
   137 */
       
   138 	{
       
   139 	INFO_PRINTF1(_L("BOUND-WSP: Testing Connect"));
       
   140 	if(TestStepResult() == EPass )
       
   141 		{
       
   142 		SetTestStepResult(EFail);
       
   143 		iImp = LoadInterface();
       
   144 		if(iImp)
       
   145 			{
       
   146 			TInt bearer, port;
       
   147 			TInt error	= KErrNone;
       
   148 			TBool secure= EFalse;
       
   149 			TBool reconnect= EFalse;
       
   150 			TBool delay = EFalse;
       
   151 			SetLastError(KErrNone);
       
   152 			
       
   153 			if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) iBearer = (Wap::TBearer)bearer;
       
   154 			if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port)) iLocalPort = (Wap::TPort)port;
       
   155 			if(GetIntFromConfig(ConfigSection(), KWapExError, error)) SetExpectedError(error);
       
   156 			if(GetBoolFromConfig(ConfigSection(), KWapSecure, secure)) iSecure = secure;
       
   157 			if(GetBoolFromConfig(ConfigSection(),_L("Reconnect"), reconnect)) iReconnect = reconnect;
       
   158 			if(GetBoolFromConfig(ConfigSection(),KWapDelayPortClosure, delay)) iDelayPortClosure = delay;
       
   159 			
       
   160 			if(UseSimTsy())
       
   161 				{
       
   162 				GetIntFromConfig(ConfigSection(), KWapSIMTSYState, iSimTsyState);
       
   163 				User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, iSimTsyState));
       
   164 				}
       
   165 			User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn));
       
   166 
       
   167 			SetState(EConnect);
       
   168 			iControl->ReStart();
       
   169 			ShowConnectionInfo();
       
   170 			StartScheduler();
       
   171 			UnloadInterface();
       
   172 			}
       
   173 		}
       
   174 	return TestStepResult();
       
   175 	}
       
   176 
       
   177 TInt CBoundWSPStep_2::CallStateMachine()
       
   178 	{
       
   179 	TInt err = KErrNone;
       
   180 	INFO_PRINTF2(_L("CallStateMachine: state %d"), State());
       
   181 	switch(iState)
       
   182 		{
       
   183 		case EConnect:
       
   184 			INFO_PRINTF1(_L("EConnect"));
       
   185 			err = iImp->Connect(iBearer, iLocalPort, iSecure);
       
   186 			INFO_PRINTF2(_L("Connection completed with code = %d"), err);
       
   187 			if( err == KErrNone)
       
   188 				{
       
   189 				if(iReconnect)
       
   190 					{ 
       
   191 					INFO_PRINTF1(_L("Reconnection"));
       
   192 					iControl->ReStart();
       
   193 					break;
       
   194 					}
       
   195 				}
       
   196 			SetState(EFinish);
       
   197 			SetLastError(err);
       
   198 			iControl->ReStart();
       
   199 			break;
       
   200 			
       
   201 		case EFinish:
       
   202 			// it's necessary to delay port closure, let the other concurrent test step
       
   203 			// can fail opening the same port with expected error EPortAlreadyBound (-5498)
       
   204 			if (iDelayPortClosure)
       
   205 				User::After(5000000);
       
   206 
       
   207 			INFO_PRINTF1(_L("EFinish"));
       
   208 			if(GetLastError() == GetExpectedError()) SetTestStepResult(EPass);
       
   209 			else SetTestStepResult(EFail);
       
   210 			SetState(EIdle);
       
   211 			StopScheduler();
       
   212 			break;
       
   213 			
       
   214 		case EIdle:
       
   215 		default:
       
   216 			INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State());
       
   217 			SetTestStepResult(EFail);
       
   218 			StopScheduler();
       
   219 			break;
       
   220 		}
       
   221 	return (0);
       
   222 	}
       
   223 
       
   224 CBoundWSPStep_3::CBoundWSPStep_3()
       
   225 /**
       
   226 * Constructor
       
   227 */
       
   228 	{
       
   229 	}
       
   230 
       
   231 CBoundWSPStep_3::~CBoundWSPStep_3() 
       
   232 /**
       
   233 * Destructor
       
   234 */
       
   235 	{
       
   236 	}
       
   237 
       
   238 TVerdict CBoundWSPStep_3::doTestStepL()
       
   239 /*
       
   240 * Test the BoundWSP APIs in unconnected state.
       
   241 */
       
   242 	{
       
   243 	INFO_PRINTF1(_L("BoundCLPush. Requests without connection"));
       
   244 	// check preamble result
       
   245 	TVerdict verdict = TestStepResult();
       
   246 	if (verdict==EPass)
       
   247 		{
       
   248 		TInt err, ret;
       
   249 		iImp = LoadInterface();
       
   250 		if (!iImp)
       
   251 			{
       
   252 			ERR_PRINTF1(_L("Unable to load BoundWSP Interface"));
       
   253 			verdict = EFail;
       
   254 			}
       
   255 		else
       
   256 			{
       
   257 			GetIntFromConfig(ConfigSection(),KWapExError,(TInt&)iExError);
       
   258 			ShowConnectionInfo();
       
   259 			TBuf8<100> header, body;
       
   260 			TPckgBuf<TUint8> idPckg;
       
   261 			TWSPStatus wspStatus;
       
   262 			TRequestStatus reqStatus;
       
   263 			TUint32 timeout = 0;
       
   264 			iImp->MethodResult(header, body, idPckg, wspStatus, reqStatus, timeout);
       
   265 			TRAP(ret, TEST_CHECKL(reqStatus.Int(), iExError, _L("MethodResult Fails not as expected")))
       
   266 				if (ret) 
       
   267 					verdict = EFail;
       
   268 				else
       
   269 					{
       
   270 					Wap::TPort port;
       
   271 					err=iImp->GetLocalPort(port);
       
   272 					TRAP(ret, TEST_CHECKL(err, iExError, _L("GetLocalPort Fails not as expected")))
       
   273 						if (ret)
       
   274 							verdict = EFail;
       
   275 						else
       
   276 							{
       
   277 							HBufC8* localHost;					
       
   278 							err=iImp->GetLocalAddress(localHost);
       
   279 							TRAP(ret, TEST_CHECKL(err, iExError, _L("GetLocalAddress Fails not as expected")))
       
   280 								if (ret) 
       
   281 									verdict = EFail;
       
   282 								else
       
   283 									{
       
   284 									err=iImp->GetBearer(iBearer);
       
   285 									TRAP(ret, TEST_CHECKL(err, iExError, _L("GetBearer Fails not as expected")))
       
   286 										if (ret) 
       
   287 											verdict = EFail;
       
   288 										else
       
   289 											{
       
   290 											HBufC8* host;
       
   291 											err=iImp->GetServerAddress(host);
       
   292 											TRAP(ret, TEST_CHECKL(err, iExError, _L("GetServerAddress Fails not as expected")))
       
   293 												if (ret) 
       
   294 													verdict = EFail;
       
   295 												else
       
   296 													{
       
   297 													TBuf<100> uri;
       
   298 													TUint8 id = 0;
       
   299 													err=iImp->MethodInvoke(iBearer, iRemoteHost, iRemotePort, 0x40, uri, header, body, id);
       
   300 													TRAP(ret, TEST_CHECKL(err, iExError, _L("MethodInvoke Fails not as expected")))
       
   301 														if (ret) 
       
   302 															verdict = EFail;
       
   303 													}
       
   304 											}
       
   305 									}
       
   306 							}
       
   307 					}
       
   308 				UnloadInterface();
       
   309 			}
       
   310 		}
       
   311 	if (verdict==EPass)
       
   312 		{
       
   313 		INFO_PRINTF1(_L("BoundWSP. Requests Fail as expected"));
       
   314 		}
       
   315 	SetTestStepResult(verdict);
       
   316 	return TestStepResult();
       
   317 	}
       
   318 
       
   319 TInt CBoundWSPStep_3::CallStateMachine()
       
   320 	{
       
   321 	return (0);
       
   322 	}
       
   323 
       
   324 
       
   325 CBoundWSPStep_4::CBoundWSPStep_4()
       
   326 /**
       
   327 * Constructor
       
   328 */
       
   329 	{
       
   330 	}
       
   331 
       
   332 CBoundWSPStep_4::~CBoundWSPStep_4() 
       
   333 /**
       
   334 * Destructor
       
   335 */
       
   336 	{
       
   337 	}
       
   338 
       
   339 TVerdict CBoundWSPStep_4::doTestStepL()
       
   340 /** 
       
   341 * Test Connect methoths 
       
   342 * @return - TVerdict code
       
   343 * 
       
   344 */
       
   345 	{
       
   346 	INFO_PRINTF1(_L("BOUND-WSP: UnitInvoke-UnitResult"));
       
   347 	if(TestStepResult() == EPass )
       
   348 		{
       
   349 		SetTestStepResult(EFail);
       
   350 		iImp = LoadInterface();
       
   351 		if(iImp)
       
   352 			{
       
   353 			SetLastError(KErrNone);
       
   354 			
       
   355 			TInt bearer, port, repeat, method;
       
   356 			TInt error = KErrNone;
       
   357 			TPtrC headers;
       
   358 			TPtrC body;
       
   359 			TPtrC uri;
       
   360 			
       
   361 			if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) iBearer = (Wap::TBearer)bearer;
       
   362 			if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port)) iLocalPort = (Wap::TPort)port;
       
   363 			if(GetIntFromConfig(ConfigSection(),KWapExError, error)) SetExpectedError(error);
       
   364 			if(GetIntFromConfig(ConfigSection(),KWapWSPMethod, method)) iMethod = method;
       
   365 			if(GetIntFromConfig(ConfigSection(), KWapRepeat, repeat)) iRepeat = repeat;
       
   366 
       
   367 			if(!GetStringFromConfig(ConfigSection(),KWapURI, uri)) 
       
   368 				{
       
   369 				User::Leave(KErrNoMemory);
       
   370 				}
       
   371 			
       
   372 			GetStringFromConfig(ConfigSection(),KWapWSPHeaders, headers);
       
   373 			GetStringFromConfig(ConfigSection(),KWapWSPBody, body);
       
   374 
       
   375 			User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn));
       
   376 			
       
   377 			if(UseSimTsy())
       
   378 				{
       
   379 				User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, 41));
       
   380 				}
       
   381 			
       
   382 			
       
   383 			iURI = HBufC16::NewL(uri.Length());
       
   384 			
       
   385 			iSendHeaders = HBufC8::NewL(headers.Length());
       
   386 			
       
   387 			iSendBody = HBufC8::NewL(body.Length());
       
   388 			
       
   389 			iRecvHeaders = HBufC8::NewL(KMaxWapWspHeaderBufferLength);
       
   390 			iRecvBody = HBufC8::NewL(KMaxWapWspDataBufferLength);
       
   391 
       
   392 			TPtr16 tmp16 = iURI->Des();
       
   393 			tmp16.Copy(uri);
       
   394 			TPtr8 tmp1 = iSendHeaders->Des();
       
   395 			tmp1.Copy(headers);
       
   396 			TPtr8 tmp2 = iSendBody->Des();
       
   397 			tmp2.Copy(body);
       
   398 
       
   399 			iRecvHeadersBuf.Set(iRecvHeaders->Des());
       
   400 			iRecvHeadersBuf.Zero();
       
   401 			iRecvBodyBuf.Set(iRecvBody->Des());
       
   402 			iRecvBodyBuf.Zero();
       
   403 			
       
   404 			SetState(EConnect);
       
   405 			iControl->ReStart();
       
   406 			ShowConnectionInfo();
       
   407 
       
   408 			StartScheduler();
       
   409 
       
   410 			delete iRecvBody;
       
   411 			iRecvBody=NULL;
       
   412 			delete iRecvHeaders;
       
   413 			iRecvHeaders=NULL;
       
   414 
       
   415 			delete iSendBody;
       
   416 			iSendBody=NULL;
       
   417 			delete iSendHeaders;
       
   418 			iSendHeaders=NULL;
       
   419 			delete iURI;
       
   420 			iURI=NULL;
       
   421 
       
   422 			UnloadInterface();
       
   423 			}
       
   424 		}
       
   425 	return TestStepResult();
       
   426 	}
       
   427 
       
   428 TInt CBoundWSPStep_4::CallStateMachine()
       
   429 	{
       
   430 	TVerdict verdict = EFail;
       
   431 	TInt err = KErrNone;
       
   432 	TInt activate = 0;
       
   433 	static TUint total_headers = 0;		
       
   434 	static TUint total_body = 0;		
       
   435 	static TUint repeat = 0;		
       
   436 	
       
   437 	INFO_PRINTF2(_L("CallStateMachine [state %d]"), State());
       
   438 
       
   439 	switch(iState)
       
   440 		{
       
   441 		case EConnect:
       
   442 			total_headers = 0;
       
   443 			total_body = 0;
       
   444 			err = iImp->Connect(iBearer, iLocalPort, EFalse);
       
   445 			if( err == KErrNone)
       
   446 				{
       
   447 				SetState(EUnitInvoke);
       
   448 				}
       
   449 			else
       
   450 				{
       
   451 				SetState(EFinish);
       
   452 				}
       
   453 			SetLastError(err);
       
   454 			INFO_PRINTF2(_L("Connection completed with code = %d"), err);
       
   455 			iControl->ReStart();
       
   456 			break;
       
   457 
       
   458 		case EUnitInvoke:
       
   459 			INFO_PRINTF2(_L("EUnitInvoke: Method - 0x%02x"), iMethod);
       
   460 			if(iBearer != Wap::EIP)
       
   461 			{
       
   462 				TRAP(err, WaitForInitializeL());
       
   463 			}
       
   464 			if(iSendHeaders->Length() !=0 )
       
   465 				{
       
   466 				INFO_PRINTF1(_L("Headers to send:"));
       
   467 				DumpBuf(iSendHeaders->Des());
       
   468 				}	
       
   469 			if(iSendBody->Length() !=0 )
       
   470 				{
       
   471 				INFO_PRINTF1(_L("Data to send:"));
       
   472 				DumpBuf(iSendBody->Des());
       
   473 				}
       
   474 			err = iImp->MethodInvoke(iBearer, iRemoteHost, iRemotePort, iMethod, iURI->Des(), iSendHeaders->Des(), iSendBody->Des(), iTransactionId);
       
   475 			INFO_PRINTF3(_L("MethodInvoke() retcode: - dec: %d hex: 0x%08x"), err, err);
       
   476 			if(err == KErrNone) 
       
   477 				{	
       
   478 				SetState(EUnitResult);
       
   479 				}
       
   480 			else 
       
   481 				{
       
   482 				SetState(EFinish);
       
   483 				}
       
   484 			SetLastError(err);
       
   485 			iControl->ReStart();
       
   486 			break;
       
   487 
       
   488 		case EUnitResult:
       
   489 
       
   490 			iRecvHeadersBuf.Set(iRecvHeaders->Des());
       
   491 			iRecvHeadersBuf.Zero();
       
   492 			iRecvBodyBuf.Set(iRecvBody->Des());
       
   493 			iRecvBodyBuf.Zero();
       
   494 			iImp->MethodResult(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, iWspStatus, *iStatus, iTimeout);
       
   495 			INFO_PRINTF2(_L("EUnitResult: status 0x%08x"), iStatus->Int());
       
   496 			activate = 1;
       
   497 			SetLastError(err);
       
   498 			SetState(EFinish);
       
   499 			break;
       
   500 			
       
   501 		case EFinish:
       
   502 			
       
   503 			INFO_PRINTF4(_L("EFinish: Status: %d, WSP status: %d (0x%02x)"), iStatus->Int(), iWspStatus, iWspStatus);
       
   504 
       
   505 			if(iRecvHeadersBuf.Length() != 0)
       
   506 				{
       
   507 				INFO_PRINTF1(_L("Headers"));
       
   508 				total_headers += iRecvHeadersBuf.Length();
       
   509 				DumpBuf(iRecvHeadersBuf);
       
   510 				}
       
   511 
       
   512 			if(iRecvBodyBuf.Length() != 0)
       
   513 				{
       
   514 				INFO_PRINTF1(_L("Body"));
       
   515 				total_body += iRecvBodyBuf.Length();
       
   516 				DumpBuf(iRecvBodyBuf);
       
   517 				}
       
   518 
       
   519 			if(iStatus->Int() != KErrNone) 
       
   520 				{
       
   521 				SetLastError(iStatus->Int());
       
   522 				if(iStatus->Int() == Wap::EMoreData)
       
   523 					{
       
   524 					INFO_PRINTF1(_L("NOTE: More data... calling MethodResult()"));
       
   525 					SetState(EUnitResult);
       
   526 					iControl->ReStart();
       
   527 					break;
       
   528 					}
       
   529 				}
       
   530 
       
   531 			INFO_PRINTF3(_L("Data received: headers - %d bytes, body - %d bytes"), total_headers, total_body);
       
   532 			total_headers = 0;
       
   533 			total_body = 0;
       
   534 			if((--iRepeat != 0) && (iStatus->Int() == KErrNone))
       
   535 				{
       
   536 				++repeat;
       
   537 				INFO_PRINTF2(_L("REPEAT TEST - %d"), repeat);
       
   538 				if(err == KErrNone) 
       
   539 					{	
       
   540 					SetState(EUnitInvoke);
       
   541 					iControl->ReStart();
       
   542 					break;
       
   543 					}
       
   544 				}
       
   545 
       
   546 			verdict = (GetLastError() == GetExpectedError())?EPass:EFail;
       
   547 			SetTestStepResult(verdict);
       
   548 			SetState(EIdle);
       
   549 			StopScheduler();
       
   550 			break;
       
   551 			
       
   552 		case EIdle:
       
   553 		default:
       
   554 			INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State());
       
   555 			SetTestStepResult(verdict);
       
   556 			StopScheduler();
       
   557 			break;
       
   558 		}
       
   559 	return (activate);
       
   560 	}
       
   561 
       
   562 CBoundWSPStep_5::CBoundWSPStep_5()
       
   563 /**
       
   564 * Constructor
       
   565 */
       
   566 	{
       
   567 	}
       
   568 
       
   569 CBoundWSPStep_5::~CBoundWSPStep_5() 
       
   570 /**
       
   571 * Destructor
       
   572 */
       
   573 	{
       
   574 	}
       
   575 
       
   576 TVerdict CBoundWSPStep_5::doTestStepL()
       
   577 /** 
       
   578 * Test Cancel Request 
       
   579 * @return - TVerdict code
       
   580 * 
       
   581 */
       
   582 	{
       
   583 	INFO_PRINTF1(_L("BoundCLPush. Testing Cancel Request"));
       
   584 	if(TestStepResult() == EPass )
       
   585 		{
       
   586 		SetTestStepResult(EFail);
       
   587 		iImp = LoadInterface();
       
   588 		if(iImp)
       
   589 			{
       
   590 			TInt bearer, port;
       
   591 			TInt err = KErrNone;
       
   592 			TBool secure= EFalse;
       
   593 			TBool reconnect= EFalse;
       
   594 			SetLastError(KErrNone);
       
   595 			
       
   596 			if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) iBearer = (Wap::TBearer)bearer;
       
   597 			if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port)) iLocalPort = (Wap::TPort)port;
       
   598 			if(GetIntFromConfig(ConfigSection(), KWapExError, err)) SetExpectedError(err);
       
   599 			if(GetBoolFromConfig(ConfigSection(), KWapSecure, secure)) iSecure = secure;
       
   600 			if(GetBoolFromConfig(ConfigSection(),_L("Reconnect"), reconnect)) iReconnect = reconnect;
       
   601 
       
   602 			ShowConnectionInfo();
       
   603 			err = iImp->Connect(iBearer, iLocalPort, iSecure);
       
   604 			INFO_PRINTF2(_L("Connection completed with code = %d"), err);
       
   605 			if( err == KErrNone)
       
   606 				{
       
   607 				TBuf8<100> header, body;
       
   608 				TPckgBuf<TUint8> idPckg;
       
   609 				TWSPStatus wspStatus;
       
   610 				TRequestStatus reqStatus;
       
   611 				TUint32 timeout=0;
       
   612 				iImp->MethodResult(header, body, idPckg, wspStatus, reqStatus, timeout);
       
   613 				SetState(EUnitResult);
       
   614 				StartScheduler();
       
   615 				iControl->ReStart();
       
   616 				if(reqStatus==KErrCancel)
       
   617 					{
       
   618 					SetTestStepResult(EPass);
       
   619 					}
       
   620 				
       
   621 				}
       
   622 			}
       
   623 		}
       
   624 	return TestStepResult();
       
   625 	}
       
   626 
       
   627 TInt CBoundWSPStep_5::CallStateMachine()
       
   628 	{
       
   629 	INFO_PRINTF2(_L("CallStateMachine: step %d"), State());
       
   630 	switch(iState)
       
   631 		{
       
   632 		case EUnitResult:
       
   633 			INFO_PRINTF1(_L("EUnitResult"));
       
   634 			iImp->CancelReq();
       
   635 			SetState(EFinish);
       
   636 			iControl->ReStart();
       
   637 			break;
       
   638 			
       
   639 		case EFinish:
       
   640 			INFO_PRINTF1(_L("EFinish"));
       
   641 			SetState(EIdle);
       
   642 			StopScheduler();
       
   643 			break;
       
   644 			
       
   645 		case EIdle:
       
   646 		default:
       
   647 			INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State());
       
   648 			SetTestStepResult(EFail);
       
   649 			StopScheduler();
       
   650 			break;
       
   651 		}
       
   652 	return (0);
       
   653 	}
       
   654 
       
   655 CBoundWSPStep_6::CBoundWSPStep_6() 
       
   656 	{
       
   657 	}
       
   658 CBoundWSPStep_6::~CBoundWSPStep_6()  
       
   659 	{
       
   660 	}
       
   661 
       
   662 TVerdict CBoundWSPStep_6::doTestStepL()
       
   663 /*
       
   664 * Test receive time out
       
   665 */
       
   666 	{
       
   667 	INFO_PRINTF1(_L("BOUND-WSP: Connect-UnitResult-TimeOut"));
       
   668 	if(TestStepResult() == EPass )
       
   669 		{
       
   670 		SetTestStepResult(EFail);
       
   671 		iImp = LoadInterface();
       
   672 		if(iImp)
       
   673 			{
       
   674 			SetLastError(KErrNone);
       
   675 			TInt bearer, port;
       
   676 			TInt error = KErrNone;
       
   677 			if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer))
       
   678 				{
       
   679 				iBearer = static_cast<Wap::TBearer>(bearer);
       
   680 				}
       
   681 			if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port))
       
   682 				{
       
   683 				iLocalPort = static_cast<Wap::TPort>(port);
       
   684 				}
       
   685 			if(GetIntFromConfig(ConfigSection(),KWapExError, error))
       
   686 				{
       
   687 				SetExpectedError(error);
       
   688 				}
       
   689 			TInt headerLength, bufLength, timeOut; 
       
   690 			if(GetIntFromConfig(ConfigSection(),KWapWSPRecvHeaderLength, headerLength))
       
   691 				{
       
   692 				iHeaderRecvBufLength=static_cast<TUint16>(headerLength);
       
   693 				}
       
   694 			if(GetIntFromConfig(ConfigSection(),KWapWSPRecvBodyLength, bufLength))
       
   695 				{
       
   696 				iBodyRecvBufLength=static_cast<TUint16>(bufLength);
       
   697 				}
       
   698 			if(GetIntFromConfig(ConfigSection(),KWapTimeOut, timeOut))
       
   699 				{
       
   700 				iTimeout=timeOut;
       
   701 				}
       
   702 			iRecvHeaders = HBufC8::NewL(iHeaderRecvBufLength);
       
   703 			iRecvBody = HBufC8::NewL(iBodyRecvBufLength);
       
   704 			SetState(EConnect);
       
   705 			iControl->ReStart();
       
   706 			ShowConnectionInfo();
       
   707 			StartScheduler();
       
   708 			delete iRecvBody;
       
   709 			iRecvBody=NULL;
       
   710 			delete iRecvHeaders;
       
   711 			iRecvHeaders=NULL;
       
   712 			UnloadInterface();
       
   713 			}
       
   714 		}
       
   715 	return TestStepResult();
       
   716 	}
       
   717 
       
   718 TInt CBoundWSPStep_6::CallStateMachine()
       
   719 /*
       
   720 * Test receive time out
       
   721 */
       
   722 	{
       
   723 	TVerdict verdict = EFail;
       
   724 	TInt err = KErrNone;
       
   725 	TInt activate = 0;
       
   726 	
       
   727 	INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State());
       
   728 	switch(iState)
       
   729 		{
       
   730 		case EConnect:
       
   731 			INFO_PRINTF1(_L("EConnect"));
       
   732 			err = iImp->Connect(iBearer, iLocalPort, EFalse);
       
   733 			INFO_PRINTF2(_L("Connection completed with code = %d"), err);
       
   734 			if( err == KErrNone)
       
   735 				{
       
   736 //				WaitForInitializeL();
       
   737 				iRecvHeadersBuf.Set(iRecvHeaders->Des());
       
   738 				iRecvBodyBuf.Set(iRecvBody->Des());
       
   739 				iImp->MethodResult(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, iWspStatus, *iStatus, iTimeout);
       
   740 				INFO_PRINTF1(_L("MethodResult"));
       
   741 				activate = 1;
       
   742 				}
       
   743 			else
       
   744 				{
       
   745 				iControl->ReStart();
       
   746 				}
       
   747 			SetLastError(err);
       
   748 			SetState(EFinish);
       
   749 			break;
       
   750 			
       
   751 		case EFinish:
       
   752 			
       
   753 			INFO_PRINTF1(_L("EFinish"));
       
   754 			if(iStatus->Int() != KErrNone) 
       
   755 				{
       
   756 				SetLastError(iStatus->Int());
       
   757 				}
       
   758 			verdict = (GetLastError() == GetExpectedError())?EPass:EFail;
       
   759 			SetTestStepResult(verdict);
       
   760 			SetState(EIdle);
       
   761 			StopScheduler();
       
   762 			break;
       
   763 			
       
   764 		case EIdle:
       
   765 		default:
       
   766 			INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State());
       
   767 			SetTestStepResult(verdict);
       
   768 			StopScheduler();
       
   769 			
       
   770 			break;
       
   771 		}
       
   772 	return (activate);
       
   773 	}
       
   774 
       
   775 CBoundWSPStep_7::CBoundWSPStep_7() 
       
   776 	{
       
   777 	}
       
   778 CBoundWSPStep_7::~CBoundWSPStep_7()
       
   779 	{
       
   780 	}
       
   781 
       
   782 TVerdict CBoundWSPStep_7::doTestStepL()
       
   783 //
       
   784 //Wrong sequence
       
   785 //
       
   786 	{
       
   787 	INFO_PRINTF1(_L("BOUND-WSP: Connect-UnitResult-UnitResult"));
       
   788 	if(TestStepResult() == EPass )
       
   789 		{
       
   790 		SetTestStepResult(EFail);
       
   791 		iImp = LoadInterface();
       
   792 		if(iImp)
       
   793 			{
       
   794 			SetLastError(KErrNone);
       
   795 			TInt bearer, port;
       
   796 			TInt error = KErrNone;
       
   797 			if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer))
       
   798 				{
       
   799 				iBearer = static_cast<Wap::TBearer>(bearer);
       
   800 				}
       
   801 			if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port))
       
   802 				{
       
   803 				iLocalPort = static_cast<Wap::TPort>(port);
       
   804 				}
       
   805 			if(GetIntFromConfig(ConfigSection(),KWapExError, error))
       
   806 				{
       
   807 				SetExpectedError(error);
       
   808 				}
       
   809 			TInt headerLength, bufLength; 
       
   810 			if(GetIntFromConfig(ConfigSection(),KWapWSPRecvHeaderLength, headerLength))
       
   811 				{
       
   812 				iHeaderRecvBufLength=static_cast<TUint16>(headerLength);
       
   813 				}
       
   814 			if(GetIntFromConfig(ConfigSection(),KWapWSPRecvBodyLength, bufLength))
       
   815 				{
       
   816 				iBodyRecvBufLength=static_cast<TUint16>(bufLength);
       
   817 				}
       
   818 			iRecvHeaders = HBufC8::NewL(iHeaderRecvBufLength);
       
   819 			iRecvBody = HBufC8::NewL(iBodyRecvBufLength);
       
   820 			SetState(EConnect);
       
   821 			iControl->ReStart();
       
   822 			ShowConnectionInfo();
       
   823 			// Start state machine
       
   824 			StartScheduler();
       
   825 			delete iRecvBody;
       
   826 			iRecvBody=NULL;
       
   827 			delete iRecvHeaders;
       
   828 			iRecvHeaders=NULL;
       
   829 			UnloadInterface();
       
   830 			}
       
   831 		}
       
   832 	return TestStepResult();
       
   833 	}
       
   834 
       
   835 TInt CBoundWSPStep_7::CallStateMachine()
       
   836 	{
       
   837 	TVerdict verdict = EFail;
       
   838 	TInt err = KErrNone;
       
   839 	TInt activate = 0;
       
   840 	
       
   841 	INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State());
       
   842 	switch(iState)
       
   843 		{
       
   844 		case EConnect:
       
   845 			INFO_PRINTF1(_L("EConnect"));
       
   846 			err = iImp->Connect(iBearer, iLocalPort, EFalse);
       
   847 			INFO_PRINTF2(_L("Connection completed with code = %d"), err);
       
   848 			if( err == KErrNone)
       
   849 				{
       
   850 //				WaitForInitializeL();
       
   851 				TRequestStatus reqStatus;
       
   852 				iRecvHeadersBuf.Set(iRecvHeaders->Des());
       
   853 				iRecvBodyBuf.Set(iRecvBody->Des());
       
   854 				iImp->MethodResult(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, iWspStatus, reqStatus, iTimeout);
       
   855 				iImp->MethodResult(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, iWspStatus, *iStatus, iTimeout);
       
   856 				INFO_PRINTF1(_L("MethodResult"));
       
   857 				activate = 1;
       
   858 				}
       
   859 			else
       
   860 				{
       
   861 				iControl->ReStart();
       
   862 				}
       
   863 			SetLastError(err);
       
   864 			SetState(EFinish);
       
   865 			break;
       
   866 			
       
   867 		case EFinish:
       
   868 			INFO_PRINTF1(_L("EFinish"));
       
   869 			iImp->CancelReq();
       
   870 			if(iStatus->Int() != KErrNone) 
       
   871 				{
       
   872 				SetLastError(iStatus->Int());
       
   873 				}
       
   874 			verdict = (GetLastError() == GetExpectedError())?EPass:EFail;
       
   875 			SetTestStepResult(verdict);
       
   876 			SetState(EIdle);
       
   877 			StopScheduler();
       
   878 			break;
       
   879 			
       
   880 		case EIdle:
       
   881 		default:
       
   882 			INFO_PRINTF2(_L("Error: EIdle or unknown state %d, State = %d"), State());
       
   883 			SetTestStepResult(verdict);
       
   884 			StopScheduler();
       
   885 			
       
   886 			break;
       
   887 		}
       
   888 	return (activate);
       
   889 	}
       
   890 
       
   891 CBoundWSPStep_8::CBoundWSPStep_8() 
       
   892 	{
       
   893 	}
       
   894 CBoundWSPStep_8::~CBoundWSPStep_8()  
       
   895 	{
       
   896 	}
       
   897 TVerdict CBoundWSPStep_8::doTestStepL()
       
   898 /*
       
   899 *	Using invalid values for API parameters:
       
   900 *	- Invalid TUid on construction
       
   901 *	- Invalid method for MethodInvoke
       
   902 *	- Invalid timeout for MethodResult
       
   903 *	Note: wrong bearer value has already been implemented as part of test 2
       
   904 */
       
   905 	{
       
   906 	INFO_PRINTF1(_L("BOUND-WSP: Wrong parameters testing"));
       
   907 	if(TestStepResult() == EPass )
       
   908 		{
       
   909 		TInt error;
       
   910 		if(GetIntFromConfig(ConfigSection(),KWapExError2, error))
       
   911 			{
       
   912 			iExError2=error;
       
   913 			}
       
   914 		TInt trapValue;
       
   915 		TUid invalidInterfaceUid = {0x00000000}; /*{0x101FBB3C};*/
       
   916 		INFO_PRINTF2(_L("Calling new NewL(0x%08X) method"), invalidInterfaceUid);
       
   917 		TRAP(trapValue, iImp = CWapBoundCLWSPService::NewL(invalidInterfaceUid));
       
   918 		TVerdict verdict = (trapValue == iExError2)?EPass:EFail;
       
   919 		if (verdict==EFail)
       
   920 			{
       
   921 			SetTestStepResult(EFail);
       
   922 			return TestStepResult();
       
   923 			}
       
   924 		else
       
   925 			{
       
   926 			INFO_PRINTF2(_L("CreateImplementation with wrong Uid- Failed as expected with error %d"),trapValue);
       
   927 			// Now use the correct Uid
       
   928 			iImp = LoadInterface();
       
   929 			if(iImp)
       
   930 				{
       
   931 				SetLastError(KErrNone);
       
   932 				TInt method;
       
   933 				TInt error = KErrNone;
       
   934 				TPtrC headers;
       
   935 				TPtrC body;
       
   936 				TPtrC uri;
       
   937 				
       
   938 				if(GetIntFromConfig(ConfigSection(), KWapExError, error))
       
   939 					{
       
   940 					SetExpectedError(error);
       
   941 					}
       
   942 				if (GetIntFromConfig(ConfigSection(),KWapWSPMethod, method))
       
   943 					{
       
   944 					iMethod=method;
       
   945 					}
       
   946 				
       
   947 				if(!GetStringFromConfig(ConfigSection(),KWapURI, uri) || \
       
   948 					!GetStringFromConfig(ConfigSection(),KWapWSPHeaders, headers) || \
       
   949 					!GetStringFromConfig(ConfigSection(),KWapWSPBody, body))
       
   950 					{
       
   951 					User::Leave(KErrNoMemory);
       
   952 					}
       
   953 				
       
   954 				iURI = HBufC16::NewL(uri.Length());
       
   955 				
       
   956 				iSendHeaders = HBufC8::NewL(headers.Length());
       
   957 				
       
   958 				iSendBody = HBufC8::NewL(body.Length());
       
   959 				
       
   960 				TPtr16 tmp16 = iURI->Des();
       
   961 				tmp16.Copy(uri);
       
   962 				TPtr8 tmp = iSendHeaders->Des();
       
   963 				tmp.Copy(headers);
       
   964 				TPtr8 tmp1 = iSendBody->Des();
       
   965 				tmp1.Copy(body);
       
   966 
       
   967 				ShowConnectionInfo();
       
   968 				error = iImp->Connect(iBearer, iLocalPort, EFalse);
       
   969 				INFO_PRINTF2(_L("Connection completed with code = %d"), error);
       
   970 				if( error == KErrNone)
       
   971 					{
       
   972 					error = iImp->MethodInvoke(iBearer, iRemoteHost, iRemotePort, iMethod, iURI->Des(), iSendHeaders->Des(), iSendBody->Des(), iTransactionId);
       
   973 					}
       
   974 				TVerdict verdict = (error == GetExpectedError())?EPass:EFail;
       
   975 				SetTestStepResult(verdict);
       
   976 				
       
   977 				delete iSendBody;
       
   978 				iSendBody=NULL;
       
   979 				delete iSendHeaders;
       
   980 				iSendHeaders=NULL;
       
   981 				delete iURI;
       
   982 				iURI=NULL;
       
   983 				UnloadInterface();
       
   984 				}
       
   985 			}
       
   986 		}
       
   987 	return TestStepResult();
       
   988 	}
       
   989 TInt CBoundWSPStep_8::CallStateMachine()
       
   990 	{
       
   991 	return (0);
       
   992 	}
       
   993 
       
   994 CBoundWSPStep_9::CBoundWSPStep_9() {}
       
   995 CBoundWSPStep_9::~CBoundWSPStep_9()  {}
       
   996 
       
   997 TVerdict CBoundWSPStep_9::doTestStepL()
       
   998 	{
       
   999 	return TestStepResult();
       
  1000 	}
       
  1001 
       
  1002 TInt CBoundWSPStep_9::CallStateMachine()
       
  1003 	{
       
  1004 	return (0);
       
  1005 	}