datacommsserver/esockserver/test/TE_Protocol/src/ProtocolTestSection.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 
       
     2 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 // All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 //
       
     9 // Initial Contributors:
       
    10 // Nokia Corporation - initial contribution.
       
    11 //
       
    12 // Contributors:
       
    13 //
       
    14 // Description:
       
    15 // This contains Protocol test cases from section 21 
       
    16 // CPROTOCOL TESTS
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file SocketTestSectioncpp
       
    22 */
       
    23 
       
    24 #include <e32base.h>
       
    25 #include "ProtocolTestSection.h"
       
    26 #include "ES_DUMMY.H"
       
    27 #include <es_sock.h>
       
    28 #include <es_mbuf.h>
       
    29 #include <es_prot.h>
       
    30 #include <e32test.h>
       
    31 #include <comms-infras/nifif.h>
       
    32 #include <es_mbuf.h>
       
    33 #include <ss_pman.h>
       
    34 #include <ss_glob.h>
       
    35 #include <e32math.h>
       
    36 #include <dns_qry.h>
       
    37 #include "pdummy.h"
       
    38 #include <agenterrors.h>
       
    39 
       
    40 
       
    41 // Test step 1
       
    42 const TDesC& CProtocolTest1::GetTestName()
       
    43 	{
       
    44 	_LIT(ret,"Test1");
       
    45 	return ret;
       
    46 	}
       
    47 
       
    48 enum TVerdict CProtocolTest1::InternalDoTestStepL( void )
       
    49 	// expected to Panic(EDoesNotBindAbove);
       
    50 	{
       
    51 	TServerProtocolDesc desc;
       
    52 	desc.iAddrFamily = KDummyAddrFamily;
       
    53 	iDummy = CDummyProtocol::NewL(KDummyOne, &iDesc);
       
    54 	CDummyProtocol* prot2 = new (ELeave) CDummyProtocol(&desc);
       
    55 	TInt ret = iDummy->ProtocolBaseBindTo(prot2);
       
    56 	delete prot2;
       
    57 	return EPass;
       
    58 	}
       
    59 	
       
    60 	 
       
    61 // Test step 2
       
    62 const TDesC& CProtocolTest2::GetTestName()
       
    63 	{
       
    64 	_LIT(ret,"Test2");
       
    65 	return ret;
       
    66 	}
       
    67 
       
    68 enum TVerdict CProtocolTest2::InternalDoTestStepL( void )
       
    69 	// expected to Panic(EDoesNotBindBelow);
       
    70 	{
       
    71 	TServerProtocolDesc desc;
       
    72 	desc.iAddrFamily = KDummyAddrFamily;
       
    73 	iDummy = CDummyProtocol::NewL(KDummyOne, &desc);
       
    74 	CDummyProtocol* prot2 = new (ELeave) CDummyProtocol(&desc);
       
    75 	TUint id = 0;
       
    76 	TInt ret = iDummy->ProtocolBaseBind(prot2, id);	
       
    77 	if (ret != KErrNone)
       
    78 		{
       
    79 		return EFail;
       
    80 		}
       
    81 	delete prot2;	
       
    82 	return EPass;
       
    83 	}
       
    84 	
       
    85 // Test step 3
       
    86 const TDesC& CProtocolTest3::GetTestName()
       
    87 	{
       
    88 	_LIT(ret,"Test3");
       
    89 	return ret;
       
    90 	}
       
    91 
       
    92 enum TVerdict CProtocolTest3::InternalDoTestStepL( void )
       
    93 	// expected to Panic(EErrorCallNotHandled)
       
    94 	{
       
    95 	TServerProtocolDesc desc;
       
    96 	desc.iAddrFamily = KDummyAddrFamily;
       
    97 	iDummy = CDummyProtocol::NewL(KDummyOne, &desc);
       
    98 	CDummyProtocol* prot2 = new (ELeave) CDummyProtocol(&desc);
       
    99 	TInt ret = iDummy->ProtocolBaseError(prot2);
       
   100 	if (ret != KErrNone)
       
   101 		{
       
   102 		return EFail;
       
   103 		}
       
   104 	delete prot2;
       
   105 	return EPass;
       
   106 	}
       
   107 	
       
   108 	 
       
   109 // Test step 4
       
   110 const TDesC& CProtocolTest4::GetTestName()
       
   111 	{
       
   112 	_LIT(ret,"Test4");
       
   113 	return ret;	
       
   114 	}
       
   115 
       
   116 enum TVerdict CProtocolTest4::InternalDoTestStepL( void )
       
   117 	// expected to return KErrNotSupported
       
   118 	{
       
   119 	TServerProtocolDesc desc;
       
   120 	desc.iAddrFamily = KDummyAddrFamily;
       
   121 	iDummy = CDummyProtocol::NewL(KDummyOne, &desc);
       
   122 	TUint level = 0;
       
   123 	TUint name  = 0;
       
   124 	TBuf8<20> buf;
       
   125 	CDummyProtocol* prot2 = new (ELeave) CDummyProtocol(&desc);
       
   126 	TInt ret = iDummy->ProtocolBaseGetOption(level, name, buf, prot2);
       
   127 	if (ret != KErrNotSupported)
       
   128 		{
       
   129 		return EFail;
       
   130 		}
       
   131 	delete prot2;
       
   132 	return EPass;
       
   133 	}
       
   134 		
       
   135 // Test step 5
       
   136 const TDesC& CProtocolTest5::GetTestName()
       
   137 	{
       
   138 	_LIT(ret,"Test5");
       
   139 	return ret;
       
   140 	}
       
   141 
       
   142 enum TVerdict CProtocolTest5::InternalDoTestStepL( void )
       
   143 	// expected to panic with Fault(EBadHostResolver);
       
   144 	{
       
   145 	TServerProtocolDesc desc;
       
   146 	desc.iAddrFamily = KDummyAddrFamily;
       
   147 	iDummy = CDummyProtocol::NewL(KDummyOne, &desc);
       
   148 	TInt ret = iDummy->ProtocolBaseNewHostResolver();
       
   149 	if (ret != KErrNone)
       
   150 		{
       
   151 		return EFail;
       
   152 		}
       
   153 	return EPass;
       
   154 	}
       
   155 	
       
   156 		
       
   157 // Test step 6
       
   158 const TDesC& CProtocolTest6::GetTestName()
       
   159 	{
       
   160 	_LIT(ret,"Test6");
       
   161 	return ret;
       
   162 	}
       
   163 
       
   164 enum TVerdict CProtocolTest6::InternalDoTestStepL( void )
       
   165 	// expected to panic with Fault(EBadNetDBRequest)
       
   166 	{
       
   167 	TServerProtocolDesc desc;
       
   168 	desc.iAddrFamily = KDummyAddrFamily;
       
   169 	iDummy = CDummyProtocol::NewL(KDummyOne, &desc);
       
   170 	TInt ret = iDummy->ProtocolBaseNewNetDatabase();
       
   171 	if (ret != KErrNone)
       
   172 		{
       
   173 		return EFail;
       
   174 		}
       
   175 	return EPass;
       
   176 	}
       
   177 	
       
   178 		
       
   179 // Test step 7
       
   180 const TDesC& CProtocolTest7::GetTestName()
       
   181 	{
       
   182 	_LIT(ret,"Test7");
       
   183 	return ret;
       
   184 	}
       
   185 
       
   186 enum TVerdict CProtocolTest7::InternalDoTestStepL( void )
       
   187 	// expected to panic with Fault(EOddSock)
       
   188 	{
       
   189 	TServerProtocolDesc desc;
       
   190 	desc.iAddrFamily = KDummyAddrFamily;
       
   191 	iDummy = CDummyProtocol::NewL(KDummyOne, &desc);
       
   192 	TUint aProt = 0;
       
   193 	TInt ret = iDummy->ProtocolBaseNewSAP(aProt);
       
   194 	if (ret != KErrNone)
       
   195 		{
       
   196 		return EFail;
       
   197 		}
       
   198 	return EPass;
       
   199 	}
       
   200 	
       
   201 		
       
   202 // Test step 8
       
   203 const TDesC& CProtocolTest8::GetTestName()
       
   204 	{
       
   205 	_LIT(ret,"Test8");
       
   206 	return ret;
       
   207 	}
       
   208 
       
   209 enum TVerdict CProtocolTest8::InternalDoTestStepL( void )
       
   210 	// expected to panic with Fault(EBadServiceResolver)
       
   211 	{
       
   212 	TServerProtocolDesc desc;
       
   213 	desc.iAddrFamily = KDummyAddrFamily;
       
   214 	iDummy = CDummyProtocol::NewL(KDummyOne, &desc);
       
   215 	TInt ret = iDummy->ProtocolBaseNewServiceResolver();
       
   216 	if (ret != KErrNone)
       
   217 		{
       
   218 		return EFail;
       
   219 		}
       
   220 	return EPass;
       
   221 	}
       
   222 	
       
   223 		
       
   224 // Test step 9
       
   225 const TDesC& CProtocolTest9::GetTestName()
       
   226 	{
       
   227 	_LIT(ret,"Test9");
       
   228 	return ret;
       
   229 	}
       
   230 
       
   231 enum TVerdict CProtocolTest9::InternalDoTestStepL( void )
       
   232 	// expected to panic with Panic(ECantProcessMbufs)
       
   233 	{
       
   234 	TServerProtocolDesc desc;
       
   235 	desc.iAddrFamily = KDummyAddrFamily;
       
   236 	iDummy = CDummyProtocol::NewL(KDummyOne, &iDesc);
       
   237 	CDummyProtocol* prot = new (ELeave) CDummyProtocol(&desc);
       
   238 	RMBufChain chain;
       
   239 	TInt ret = iDummy->ProtocolBaseProcess(chain, prot);
       
   240 	if (ret != KErrNone)
       
   241 		{
       
   242 		return EFail;
       
   243 		}
       
   244 	delete prot;
       
   245 	return EPass;
       
   246 	}
       
   247 	
       
   248 // Test step 10
       
   249 const TDesC& CProtocolTest10::GetTestName()
       
   250 	{
       
   251 	_LIT(ret,"Test10");
       
   252 	return ret;
       
   253 	}
       
   254 
       
   255 enum TVerdict CProtocolTest10::InternalDoTestStepL( void )
       
   256 	// expected to panic with Panic(ECantSendMBufs);
       
   257 	{
       
   258 	TServerProtocolDesc desc;
       
   259 	desc.iAddrFamily = KDummyAddrFamily;
       
   260 	iDummy = CDummyProtocol::NewL(KDummyOne, &iDesc);
       
   261 	CDummyProtocol* prot = new (ELeave) CDummyProtocol(&desc);
       
   262 	RMBufChain chain;
       
   263 	TInt ret = iDummy->ProtocolBaseSend(chain, prot);
       
   264 	if (ret != KErrNone)
       
   265 		{
       
   266 		return EFail;
       
   267 		}
       
   268 	delete prot;
       
   269 	return EPass;
       
   270 	}
       
   271 	
       
   272 // Test step 11
       
   273 const TDesC& CProtocolTest11::GetTestName()
       
   274 	{
       
   275 	_LIT(ret,"Test11");
       
   276 	return ret;
       
   277 	}
       
   278 
       
   279 enum TVerdict CProtocolTest11::InternalDoTestStepL( void )
       
   280 	// expected to return KErrNotSupported
       
   281 	{
       
   282 	CDummyProtocol* iDummy = CDummyProtocol::NewL(KDummyOne, &iDesc);
       
   283 	TUint level = 0;
       
   284 	TUint name  = 0;
       
   285 	TBuf8<20> buf;
       
   286 	TServerProtocolDesc desc;
       
   287 	desc.iAddrFamily = KDummyAddrFamily;
       
   288 	CDummyProtocol* prot = new (ELeave) CDummyProtocol(&desc);
       
   289 	TInt ret = iDummy->ProtocolBaseSetOption(level, name, buf, prot);
       
   290 	if (ret != KErrNotSupported)
       
   291 		{
       
   292 		return EFail;
       
   293 		}
       
   294 	delete prot;
       
   295 	return EPass;
       
   296 	}
       
   297 	
       
   298 // Test step 12
       
   299 const TDesC& CProtocolTest12::GetTestName()
       
   300 	{
       
   301 	_LIT(ret,"Test12");
       
   302 	return ret;
       
   303 	}
       
   304 
       
   305 enum TVerdict CProtocolTest12::InternalDoTestStepL( void )
       
   306 	{
       
   307 	// expected to panic with Panic(ECantSendDescriptors);
       
   308 	TServerProtocolDesc desc;
       
   309 	desc.iAddrFamily = KDummyAddrFamily;
       
   310 	TBuf8<20> buf;
       
   311 	TSockAddr to;
       
   312 	TSockAddr from;
       
   313 	CDummyProtocol* prot2 = new (ELeave) CDummyProtocol(&desc);
       
   314 	iDummy = CDummyProtocol::NewL(KDummyOne, &iDesc);
       
   315 	TInt ret = iDummy->ProtocolBaseSendWithAddress(buf, &to, &from, prot2);
       
   316 	if (ret != KErrNone)
       
   317 		{
       
   318 		return EFail;
       
   319 		}
       
   320 	delete prot2;
       
   321 	return EPass;
       
   322 	}
       
   323 	
       
   324 
       
   325 // Test step 13
       
   326 const TDesC& CProtocolTest13::GetTestName()
       
   327 	{
       
   328 	_LIT(ret,"Test13");
       
   329 	return ret;
       
   330 	}
       
   331 
       
   332 enum TVerdict CProtocolTest13::InternalDoTestStepL( void )
       
   333 	// expected to panic with Panic(ECantProcessMbufs)	
       
   334 	{
       
   335 	TServerProtocolDesc desc;
       
   336 	desc.iAddrFamily = KDummyAddrFamily;
       
   337 	TBuf8<20> buf;
       
   338 	TSockAddr to;
       
   339 	TSockAddr from;
       
   340 	CDummyProtocol* prot2 = new (ELeave) CDummyProtocol(&desc);
       
   341 	iDummy = CDummyProtocol::NewL(KDummyOne, &iDesc);
       
   342 	TInt ret = iDummy->ProtocolBaseProcessWithAddress(buf, &from, &to, prot2);
       
   343 	if (ret != KErrNone)
       
   344 		{
       
   345 		return EFail;
       
   346 		}
       
   347 	delete prot2;
       
   348 	return EPass;
       
   349 	}
       
   350