applayerprotocols/httptransportfw/Test/t_httptransporthandler/ctestengine.cpp
changeset 0 b16258d2340f
child 37 5f1cd966e0d9
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     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 "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 #include "ctestengine.h"
       
    17 
       
    18 #include <chttptransportlayer.h>
       
    19 #include <msocketfactory.h>
       
    20 #include <ecom/ecom.h>
       
    21 #include<sslerr.h>
       
    22 #include <http/rhttpconnectioninfo.h>
       
    23 
       
    24 #include "csocketlistenerdriver.h"
       
    25 #include "csocketconnectordriver.h"
       
    26 
       
    27 // 'this' used in base member initializer list, The 'this' pointer being used is a base class pointer.
       
    28 #pragma warning( disable : 4355 )
       
    29 
       
    30 _LIT(KTestHttpdTransportHandlerTitle, "HTTP Daemon Transport Handler Unit Test Harness");
       
    31 
       
    32 const TInt KLogBufSize	= 128;
       
    33 const TInt KPortNumber	= 80;
       
    34 
       
    35 //propagated error code from CSocketConnector.cpp file. not defined prior in any of the files.
       
    36 const TInt KErrConnectError=(-5130);
       
    37 
       
    38 GLDEF_D TBool	gLongHostName;
       
    39 GLDEF_D TBool 	gReaderShutdown;
       
    40 GLDEF_D TBool 	gInvalidListenPort;
       
    41 GLDEF_D TBool 	gInvalidConnectPort; 
       
    42 GLDEF_D TBool	gInvalidSecureHost;
       
    43 GLDEF_D TBool 	gWriterShutdown;
       
    44 GLDEF_D TBool 	gReqCertificate;
       
    45 GLDEF_D TBool   gListenAbort;
       
    46 
       
    47 CTestEngine* CTestEngine::NewL()
       
    48 	{
       
    49 	CTestEngine* self = new (ELeave) CTestEngine();
       
    50 	CleanupStack::PushL(self);
       
    51 	self->ConstructL();
       
    52 	CleanupStack::Pop(self);
       
    53 	return self;
       
    54 	}
       
    55 
       
    56 CTestEngine::~CTestEngine()
       
    57 	{
       
    58 	iConnection.Close();
       
    59 	iSocketServer.Close();
       
    60 
       
    61 	delete iTestUtils;
       
    62 	}
       
    63 
       
    64 CTestEngine::CTestEngine()
       
    65 : CBase(), iTransportLayerParams(*this), iUseConnection(ETrue)
       
    66 	{
       
    67 	}
       
    68 
       
    69 void CTestEngine::ConstructL()
       
    70 	{
       
    71 	iTestUtils = CHTTPTestUtils::NewL(KTestHttpdTransportHandlerTitle());
       
    72 	iTestUtils->InitCommsL();
       
    73 
       
    74 	// Create and start a comms connection
       
    75 	User::LeaveIfError(iSocketServer.Connect());
       
    76 	User::LeaveIfError(iConnection.Open(iSocketServer));
       
    77 	User::LeaveIfError(iConnection.Start());
       
    78 	}
       
    79 
       
    80 void CTestEngine::DoOOMTest(TTestFunctionL aDoTestFunctionL)
       
    81 	{
       
    82 	TInt err = 1;
       
    83 	TInt count = 0;
       
    84 
       
    85 	iOOMTesting = ETrue;
       
    86 	while( err || iDoingTest )
       
    87 		{
       
    88 		__UHEAP_MARK;
       
    89 		__UHEAP_SETFAIL(RHeap::EFailNext, count); // This is a Macro, not leaving function
       
    90 		TRAP(err, (this->*aDoTestFunctionL)());
       
    91 		REComSession::FinalClose();
       
    92 		__UHEAP_MARKEND;
       
    93 		++count;
       
    94 		}
       
    95 	__UHEAP_RESET;
       
    96 	iOOMTesting = EFalse;
       
    97 	}
       
    98 
       
    99 void CTestEngine::DoTestsL()
       
   100 	{
       
   101 	iTestUtils->SetSilent(EFalse);		
       
   102 	TBuf<KLogBufSize> buf;
       
   103 	buf.Format(_L("@SYMTestCaseID IWS-APPPROTOCOLS-HTTP-FRAMEWORK-T_HTTPTRANSPORTHANDLER-0001  "));
       
   104 	iTestUtils->LogIt(buf);
       
   105 	iTestUtils->SetSilent(ETrue);
       
   106 	
       
   107 	// Run through tests...
       
   108 
       
   109 	// Don't use the existing comms connection
       
   110 	iUseConnection = EFalse;
       
   111 
       
   112 	// Basic test case
       
   113 	iTestUtils->StartTestL(_L("Basic Test Case HTTP-U-2051"));
       
   114 	DoBasicTestCaseL();
       
   115 	iTestUtils->EndTest(iTestFailed);
       
   116 
       
   117 	// Do OOM testing on Basic test case
       
   118 	iTestUtils->StartTestL(_L("OOM Testing of Basic Test Case HTTP-U-2052"));
       
   119 	DoOOMTest(&CTestEngine::DoBasicTestCaseL);
       
   120 	iTestUtils->EndTest(iTestFailed);
       
   121 
       
   122 	// Reset so that the existing comms connection is used from this point
       
   123 	iUseConnection = ETrue;
       
   124 
       
   125 	// Do Multiple Connections test case
       
   126 	iTestUtils->StartTestL(_L("Multiple Connections Test Case HTTP-U-2053"));
       
   127 	DoMultipleConnectionsTestCaseL();
       
   128 	iTestUtils->EndTest(iTestFailed);
       
   129 
       
   130 	// Do OOM testing Multiple Connections test case
       
   131 	User::After(1000);
       
   132 	iTestUtils->StartTestL(_L("OOM Testing of Multiple Connections Test Case HTTP-U-2054"));
       
   133 	DoOOMTest(&CTestEngine::DoMultipleConnectionsTestCaseL);
       
   134 	iTestUtils->EndTest(iTestFailed);
       
   135 
       
   136 	// Do Connect Control test case
       
   137 	iTestUtils->StartTestL(_L("Connect Control Test Case HTTP-U-2055"));
       
   138 	DoConnectControlTestCaseL();
       
   139 	iTestUtils->EndTest(iTestFailed);
       
   140 
       
   141 	// Do OOM testing Connect Control test case
       
   142 	iTestUtils->StartTestL(_L("OOM Testing of Connect Control Test Case HTTP-U-2056"));
       
   143 	DoOOMTest(&CTestEngine::DoConnectControlTestCaseL);
       
   144 	iTestUtils->EndTest(iTestFailed);
       
   145 
       
   146 	// Run secure test
       
   147 	iTestUtils->StartTestL(_L("Basic Secure Test Case"));
       
   148 	DoBasicSecureTestCaseL();
       
   149 	iTestUtils->EndTest(iTestFailed);
       
   150 
       
   151 	// Do OOM testing of secure test case
       
   152 	iTestUtils->StartTestL(_L("OOM Testing of Basic Secure Test Case"));
       
   153 	DoOOMTest(&CTestEngine::DoBasicSecureTestCaseL);
       
   154 	iTestUtils->EndTest(iTestFailed);
       
   155 
       
   156 
       
   157 #if defined (_LOGGING) 
       
   158 	// test case - to test invalid LongHostName 
       
   159 	gLongHostName = ETrue;
       
   160 	iTestUtils->StartTestL(_L("Invalid Long Host Name Test Case "));
       
   161 	DoBasicTestCaseL();
       
   162 	iTestUtils->EndTest(iTestFailed);
       
   163 	gLongHostName = EFalse;
       
   164 #endif	
       
   165 
       
   166 	// Run Multiple secure test
       
   167 	iTestUtils->StartTestL(_L("Multiple Secure Test Case"));
       
   168 	DoMultipleSecureConnectionsTestCaseL();
       
   169 	iTestUtils->EndTest(iTestFailed);
       
   170 
       
   171 	//Test case - to test improper shutdown of SocketReader
       
   172 	gReaderShutdown = ETrue;
       
   173 	iTestUtils->StartTestL(_L(" Invalid Reader Shutdown Test Case "));
       
   174 	DoBasicTestCaseL();
       
   175 	iTestUtils->EndTest(iTestFailed);
       
   176 	gReaderShutdown = EFalse;
       
   177 	
       
   178 	//Test case - to test socket listen on invalid local port
       
   179 	gInvalidListenPort = ETrue;
       
   180 	iTestUtils->StartTestL(_L("Testing Multiple Listen on Invalid Port"));
       
   181 	DoMultipleConnectionsTestCaseL();
       
   182 	iTestUtils->EndTest(iTestFailed);	
       
   183 	gInvalidListenPort = EFalse;
       
   184 	
       
   185 	//Test case - to test Basic secure socket connection with non-secure port
       
   186 	gLongHostName = EFalse;
       
   187 	gInvalidConnectPort = ETrue;
       
   188 	iTestUtils->StartTestL(_L("Basic Invalid Secure Host Name Test Case "));
       
   189 	DoBasicSecureTestCaseL();
       
   190 	iTestUtils->EndTest(iTestFailed);
       
   191 	gInvalidConnectPort = EFalse;	
       
   192 	
       
   193 	//Test case - to test improper shutdown of SocketWriter
       
   194 	gInvalidSecureHost = ETrue;
       
   195 	gWriterShutdown=ETrue;
       
   196 	iTestUtils->StartTestL(_L(" Invalid Writer Shutdown Test Case "));
       
   197 	DoMultipleSecureConnectionsTestCaseL();
       
   198 	iTestUtils->EndTest(iTestFailed);	
       
   199 
       
   200 	//Test case - to test Multiple secure socket connection with non-secure port
       
   201 	gInvalidSecureHost = ETrue;
       
   202 	gWriterShutdown=EFalse;
       
   203 	iTestUtils->StartTestL(_L(" Multiple Invalid Secure Host Name Test Case "));
       
   204 	DoMultipleSecureConnectionsTestCaseL();
       
   205 	iTestUtils->EndTest(iTestFailed);
       
   206 	gInvalidSecureHost = EFalse;
       
   207 	
       
   208 	//Test case - Requests Server Certificate on Writer for Non-Secure Connection
       
   209 	gReqCertificate = ETrue;
       
   210 	iTestUtils->StartTestL(_L("Check Server Certificate for Non-Secure Test case"));
       
   211 	DoBasicTestCaseL();
       
   212 	iTestUtils->EndTest(iTestFailed);
       
   213 	gReqCertificate = EFalse;	
       
   214 	
       
   215 	//Test case - Requests Server Certificate on Writer for Secure Connection	
       
   216 	gReqCertificate = ETrue;
       
   217 	iTestUtils->StartTestL(_L("Check Server Certificate for Secure Test case"));
       
   218 	DoBasicSecureTestCaseL();
       
   219 	iTestUtils->EndTest(iTestFailed);
       
   220 	gReqCertificate = EFalse;	
       
   221 		
       
   222 	gListenAbort=ETrue;
       
   223 	iTestUtils->StartTestL(_L("Improper Socket Listen, Abort Test Case"));
       
   224 	DoListenAbortTestL();
       
   225 	iTestUtils->EndTest(iTestFailed);
       
   226 	gListenAbort=EFalse;
       
   227 	
       
   228 	}
       
   229 
       
   230 void CTestEngine::DoBasicTestCaseL()
       
   231 	{
       
   232 	// Do basic test case...
       
   233 
       
   234 	do
       
   235 		{
       
   236 		// Create the http transport layer
       
   237 		CHttpTransportLayer* transportLayer = CHttpTransportLayer::NewL(_L8("TCP"), iTransportLayerParams);
       
   238 		CleanupStack::PushL(transportLayer);
       
   239 
       
   240 		// Create the socket listener driver - single connect listener.
       
   241 		CSocketListenerDriver* socketListenerDriver = CSocketListenerDriver::NewL(*this, transportLayer->SocketFactory());
       
   242 		CleanupStack::PushL(socketListenerDriver);
       
   243 		socketListenerDriver->SetSingleListenL();
       
   244 
       
   245 		socketListenerDriver->Start();
       
   246 
       
   247 		// Create the socket connector driver - single connect connector
       
   248 		CSocketConnectorDriver* socketConnectorDriver = CSocketConnectorDriver::NewL(*this, transportLayer->SocketFactory());
       
   249 		CleanupStack::PushL(socketConnectorDriver);
       
   250 		socketConnectorDriver->SetSingleConnectL();
       
   251 
       
   252 		socketConnectorDriver->Start();
       
   253 			
       
   254 		StartTesting();
       
   255 
       
   256 		CleanupStack::PopAndDestroy(3, transportLayer);
       
   257 		} while( iResetTest );
       
   258 	}
       
   259 
       
   260 void CTestEngine::DoMultipleConnectionsTestCaseL()
       
   261 	{
       
   262 	// Do multiple connections test case...
       
   263 
       
   264 	do
       
   265 		{
       
   266 		// Create the http transport layer
       
   267 		CHttpTransportLayer* transportLayer = CHttpTransportLayer::NewL(_L8("TCP"), iTransportLayerParams);
       
   268 		CleanupStack::PushL(transportLayer);
       
   269 
       
   270 		// Create the socket listener driver - double connect listener.
       
   271 		CSocketListenerDriver* socketListenerDriver = CSocketListenerDriver::NewL(*this, transportLayer->SocketFactory());
       
   272 		CleanupStack::PushL(socketListenerDriver);
       
   273 		socketListenerDriver->SetDoubleListenL();
       
   274 
       
   275 		socketListenerDriver->Start();
       
   276 
       
   277 		// Create the socket connector driver#1 - single connect connector
       
   278 		CSocketConnectorDriver* socketConnectorDriver1 = CSocketConnectorDriver::NewL(*this, transportLayer->SocketFactory());
       
   279 		CleanupStack::PushL(socketConnectorDriver1);
       
   280 		socketConnectorDriver1->SetSingleConnectL();
       
   281 
       
   282 		socketConnectorDriver1->Start();
       
   283 			
       
   284 		// Create the socket connector driver#2 - single connect connector
       
   285 		CSocketConnectorDriver* socketConnectorDriver2 = CSocketConnectorDriver::NewL(*this, transportLayer->SocketFactory());
       
   286 		CleanupStack::PushL(socketConnectorDriver2);
       
   287 		socketConnectorDriver2->SetSingleConnectL();
       
   288 
       
   289 		socketConnectorDriver2->Start();
       
   290 
       
   291 		StartTesting();
       
   292 
       
   293 		CleanupStack::PopAndDestroy(4, transportLayer);
       
   294 		} while( iResetTest );
       
   295 	}
       
   296 
       
   297 void CTestEngine::DoConnectControlTestCaseL()
       
   298 	{
       
   299 	// Do connect control test case...
       
   300 
       
   301 	do
       
   302 		{
       
   303 		// Create the http transport layer
       
   304 		CHttpTransportLayer* transportLayer = CHttpTransportLayer::NewL(_L8("TCP"), iTransportLayerParams);
       
   305 		CleanupStack::PushL(transportLayer);
       
   306 
       
   307 		// Create the socket listener driver - single connect listener.
       
   308 		CSocketListenerDriver* socketListenerDriver = CSocketListenerDriver::NewL(*this, transportLayer->SocketFactory());
       
   309 		CleanupStack::PushL(socketListenerDriver);
       
   310 		socketListenerDriver->SetSingleListenL();
       
   311 
       
   312 		socketListenerDriver->Start();
       
   313 
       
   314 		// Create the socket connector driver - double connect connector
       
   315 		CSocketConnectorDriver* socketConnectorDriver = CSocketConnectorDriver::NewL(*this, transportLayer->SocketFactory());
       
   316 		CleanupStack::PushL(socketConnectorDriver);
       
   317 		socketConnectorDriver->SetDoubleConnectL();
       
   318 
       
   319 		socketConnectorDriver->Start();
       
   320 			
       
   321 		StartTesting();
       
   322 
       
   323 		CleanupStack::PopAndDestroy(3, transportLayer);
       
   324 		} while( iResetTest );
       
   325 	}
       
   326 
       
   327 void CTestEngine::DoBasicSecureTestCaseL()
       
   328 	{
       
   329 	// Do basic test case...
       
   330 
       
   331 	do
       
   332 		{
       
   333 		// Create the http transport layer
       
   334 		CHttpTransportLayer* transportLayer = CHttpTransportLayer::NewL(_L8("TCP"), iTransportLayerParams);
       
   335 		CleanupStack::PushL(transportLayer);
       
   336 
       
   337 		// Create the socket connector driver - single connect connector
       
   338 		CSocketConnectorDriver* socketConnectorDriver = CSocketConnectorDriver::NewL(*this, transportLayer->SocketFactory());
       
   339 		CleanupStack::PushL(socketConnectorDriver);
       
   340 		socketConnectorDriver->SetSingleSecureConnectL();
       
   341 
       
   342 		socketConnectorDriver->Start();
       
   343 
       
   344 		StartTesting();		
       
   345 
       
   346 		CleanupStack::PopAndDestroy(2, transportLayer);
       
   347 		} while( iResetTest );
       
   348 	}
       
   349 
       
   350 void CTestEngine::DoMultipleSecureConnectionsTestCaseL()
       
   351 	{
       
   352 	// Do multiple secure connections test case...
       
   353 	do
       
   354 		{
       
   355 		// Create the http transport layer
       
   356 		CHttpTransportLayer* transportLayer = CHttpTransportLayer::NewL(_L8("TCP"), iTransportLayerParams);
       
   357 		CleanupStack::PushL(transportLayer);
       
   358 
       
   359 		// Create the socket connector driver#1 - single connect connector
       
   360 		CSocketConnectorDriver* socketConnectorDriver1 = CSocketConnectorDriver::NewL(*this, transportLayer->SocketFactory());
       
   361 		CleanupStack::PushL(socketConnectorDriver1);
       
   362 		socketConnectorDriver1->SetSingleSecureConnectL();
       
   363 
       
   364 		socketConnectorDriver1->Start();
       
   365 
       
   366 		
       
   367 		// Create the socket connector driver#2 - single connect connector
       
   368 		CSocketConnectorDriver* socketConnectorDriver2 = CSocketConnectorDriver::NewL(*this, transportLayer->SocketFactory());
       
   369 		CleanupStack::PushL(socketConnectorDriver2);
       
   370 		socketConnectorDriver2->SetSingleSecureConnectL();
       
   371 
       
   372 		socketConnectorDriver2->Start();
       
   373 
       
   374 		StartTesting();		
       
   375 
       
   376 		CleanupStack::PopAndDestroy(3, transportLayer);
       
   377 		} while( iResetTest );
       
   378 	}
       
   379 
       
   380 void CTestEngine::DoListenAbortTestL()
       
   381 	{		
       
   382 	// Create the http transport layer
       
   383 	CHttpTransportLayer* transportLayer = CHttpTransportLayer::NewL(_L8("TCP"), iTransportLayerParams);
       
   384 	CleanupStack::PushL(transportLayer);		
       
   385 
       
   386 	// Create the socket listener driver
       
   387 	CSocketListenerDriver* socketListenerDriver = CSocketListenerDriver::NewL(*this, transportLayer->SocketFactory());
       
   388 	CleanupStack::PushL(socketListenerDriver);
       
   389 	
       
   390 	transportLayer->SocketFactory().ListenL(*socketListenerDriver, KPortNumber);
       
   391 		
       
   392 	// Create the socket connector driver
       
   393 	CSocketConnectorDriver* socketConnectorDriver = CSocketConnectorDriver::NewL(*this, transportLayer->SocketFactory());
       
   394 	CleanupStack::PushL(socketConnectorDriver);
       
   395 	transportLayer->SocketFactory().ConnectL (*socketConnectorDriver, _L8("127.0.0.1"), KPortNumber);	
       
   396 		
       
   397 	transportLayer->SocketFactory().StopListen();
       
   398 	
       
   399 	socketConnectorDriver->SetSingleConnectL();
       
   400 	socketConnectorDriver->Start();
       
   401 	
       
   402 	StartTesting();
       
   403 		
       
   404 	CleanupStack::PopAndDestroy(3, transportLayer);	
       
   405 	
       
   406 	}
       
   407 
       
   408 void CTestEngine::StartTesting()
       
   409 	{
       
   410 	iTestCount	= 0;
       
   411 	iTestFailed	= EFalse;
       
   412 	iDoingTest	= ETrue;
       
   413 	iResetTest	= EFalse;
       
   414 	CActiveScheduler::Start();
       
   415 	}
       
   416 
       
   417 void CTestEngine::StopTesting()
       
   418 	{
       
   419 	CActiveScheduler::Stop();
       
   420 	iDoingTest = EFalse;
       
   421 	}
       
   422 
       
   423 void CTestEngine::ResetTest()
       
   424 	{
       
   425 	StopTesting();
       
   426 	iResetTest = ETrue;
       
   427 	}
       
   428 
       
   429 /*
       
   430  *	Methods from MDriverObserver
       
   431  */
       
   432 
       
   433 void CTestEngine::NotifyError(TInt aError)
       
   434 	{
       
   435 	if( !iTestFailed && iDoingTest )
       
   436 		{
       
   437 		iTestFailed = ETrue;
       
   438 
       
   439 		// Are we doing OOM testing?
       
   440 		if( iOOMTesting && aError == KErrNoMemory )
       
   441 			{
       
   442 			// This is not an error.
       
   443 			TBuf<KLogBufSize> buf;
       
   444 			buf.Format(_L("--> OOM Testing : alloc failure : %d"), aError);
       
   445 			Log(buf);
       
   446 
       
   447 			// Don't stop testing, but stop scheduler.
       
   448 			CActiveScheduler::Stop();
       
   449 			}
       
   450 		else if( aError == KErrInUse )
       
   451 			{
       
   452 			TBuf<KLogBufSize> buf;
       
   453 			buf.Format(_L("--> Listen port still not shutdown : %d - re-start test..."), aError);
       
   454 			Log(buf);
       
   455 
       
   456 			ResetTest();
       
   457 			}
       
   458 		else if( aError == KErrNotReady )
       
   459 			{
       
   460 			TBuf<KLogBufSize> buf;
       
   461 			buf.Format(_L("--> Comms connection has timed-out : %d - re-start it..."), aError);
       
   462 			Log(buf);
       
   463 
       
   464 			aError = iConnection.Start();
       
   465 			if( aError == KErrNone )
       
   466 				{
       
   467 				buf.Format(_L("--> Comms connection has re-started - re-start test..."));
       
   468 				Log(buf);
       
   469 				ResetTest();
       
   470 				}
       
   471 			else
       
   472 				{
       
   473 				buf.Format(_L("--> Could not start comms connection : %d - stop test"), aError);
       
   474 				Log(buf);
       
   475 				StopTesting();
       
   476 				}
       
   477 			}
       
   478 		else if( gLongHostName && aError == KErrConnectError ) 
       
   479 			{
       
   480 				//connection to invalid long host cannot be established hence error is expected
       
   481 				//so no use in testing further.
       
   482 				iTestFailed = EFalse;
       
   483 				StopTesting();
       
   484 			}
       
   485 		else if (gReaderShutdown && (aError == KErrEof || aError == KErrNone))
       
   486 			{//Making reader shutdown in the middle of Data-recieving, error is expected.
       
   487 			//so no use in testing further.
       
   488 			iTestFailed = EFalse;
       
   489 			StopTesting();
       
   490 			}
       
   491 		else if( gInvalidListenPort && aError == KErrCouldNotConnect )
       
   492 			{//Listening to invalid port, connection cannot be established hence error is expected
       
   493 			//so no use in testing further.
       
   494 			iTestFailed = EFalse;
       
   495 			StopTesting();
       
   496 			}
       
   497 		else if (gInvalidConnectPort && aError == KErrSSLAlertUnexpectedMessage)			
       
   498 			{//Trying to connect non-secure host on a Secure Port, error is expected.
       
   499 			//so no use in testing further.
       
   500 			iTestFailed = EFalse;
       
   501 			StopTesting();
       
   502 			}
       
   503 		else if (gInvalidSecureHost && gWriterShutdown && aError == KErrNone)			
       
   504 			{//Trying to connect invalid secure host and making immediate shutdown of the WriterStream, error is expected.
       
   505 			//so no use in testing further.
       
   506 			iTestFailed = EFalse;
       
   507 			StopTesting();
       
   508 			}			
       
   509 		else if (gInvalidSecureHost && !gWriterShutdown && aError == KErrSSLAlertIllegalParameter)
       
   510 			{//Trying to connect invalid secure host on a Secure Port, error is expected.
       
   511 			//so no use in testing further.
       
   512 			iTestFailed = EFalse;
       
   513 			StopTesting();
       
   514 			}
       
   515 		else if (gListenAbort && aError==KErrCancel)
       
   516 			{//Making Listen to stop abruptly, error is expected. 
       
   517 			//so no use in testing further.
       
   518 			iTestFailed = EFalse;
       
   519 			StopTesting();	
       
   520 			}				
       
   521 		else
       
   522 			{
       
   523 			// Log the failure
       
   524 			TBuf<KLogBufSize> buf;
       
   525 			buf.Format(_L("--> Test error : %d"), aError);
       
   526 			Log(buf);
       
   527 
       
   528 			// Stop the scheduler and the test.
       
   529 			StopTesting();
       
   530 			}
       
   531 		}
       
   532 	}
       
   533 
       
   534 void CTestEngine::NotifyStart()
       
   535 	{
       
   536 	++iTestCount;
       
   537 	}
       
   538 
       
   539 void CTestEngine::NotifyComplete()
       
   540 	{
       
   541 	--iTestCount;
       
   542 	if( iTestCount == 0 )
       
   543 		{
       
   544 		// Log success
       
   545 		Log(_L("Test completed"));
       
   546 
       
   547 		// All tests have completed - stop the scheduler
       
   548 		StopTesting();
       
   549 		}
       
   550 	}
       
   551 
       
   552 void CTestEngine::Log(const TDesC& aComment)
       
   553 	{
       
   554 	// Do not log this to summary file - go silent, but remember current state.
       
   555 	TBool isSilent = iTestUtils->IsSilent();
       
   556 	iTestUtils->SetSilent(ETrue);
       
   557 
       
   558 	// Log the comment...
       
   559 	iTestUtils->LogIt(aComment);
       
   560 
       
   561 	// Go back to original state.
       
   562 	iTestUtils->SetSilent(isSilent);
       
   563 	}
       
   564 
       
   565 TBool CTestEngine::SupplyCommsConnection(RConnection*& aConnectionPtr)
       
   566 	{
       
   567 	// If transport layer requests a comms connection, provide one if test is configured to reuse one
       
   568 	if(iUseConnection)
       
   569 		{
       
   570 		aConnectionPtr = &iConnection;
       
   571 		return ETrue;
       
   572 		}
       
   573 	return EFalse;
       
   574 	}
       
   575 
       
   576 void CTestEngine::SetCommsConnectionL(RConnection* /*aConnectionPtr*/)
       
   577 	{
       
   578 	// Dont't need to do anything here
       
   579 	}
       
   580 
       
   581 void CTestEngine::GetSecurityPrefs(TBool& aDialogPrompt, MSecurityPolicy*& aSecurityPolicy)
       
   582 	{
       
   583 	if(gInvalidSecureHost && !gWriterShutdown)
       
   584 		aDialogPrompt = EFalse;
       
   585 	else
       
   586 		aDialogPrompt = ETrue;
       
   587 	
       
   588 	aSecurityPolicy = NULL;
       
   589 	}
       
   590 
       
   591 TBool CTestEngine::ImmediateSocketShutdown()
       
   592 	{
       
   593 	if (iUseConnection)
       
   594 		return ETrue;
       
   595 	else
       
   596 		return EFalse;
       
   597 	}
       
   598 
       
   599 
       
   600 TInt CTestEngine::SessionId()
       
   601 	{
       
   602 	return KErrNotSupported;
       
   603 	}
       
   604 
       
   605 TBool CTestEngine::SupplySocketServerHandle ( TInt& aSocketServerHandle )
       
   606 	{
       
   607 	if(iUseConnection)
       
   608 		{
       
   609 		aSocketServerHandle = iSocketServer.Handle();
       
   610 		return ETrue;
       
   611 		}
       
   612 	return EFalse;	
       
   613 	}
       
   614 	
       
   615 void CTestEngine::SetSocketServerHandleL ( TInt /*aSocketServerHandle*/ )	
       
   616 	{	
       
   617 	// do nothing
       
   618 	}	
       
   619 
       
   620 TInt CTestEngine::GetRecvBufferSize()
       
   621 	{
       
   622 	return KDefaultBufferSize;
       
   623 	}
       
   624