datacommsserver/esockserver/test/TE_ESock/EsockTestSection17.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     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 // This contains ESock Test cases from section 17
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 #include <in_sock.h>
       
    21 
       
    22 // Test system includes
       
    23 #include "EsockTestSection17.h"
       
    24 
       
    25 
       
    26 // Test step 17.1
       
    27 const TDesC& CEsockTest17_1::GetTestName()
       
    28 	{
       
    29 	// store the name of this test case
       
    30 	_LIT(ret,"Test17.1");
       
    31 	return ret;
       
    32 	}
       
    33 
       
    34 CEsockTest17_1::~CEsockTest17_1()
       
    35 	{
       
    36 	appendixInArray.Close();
       
    37 	}
       
    38 
       
    39 enum TVerdict CEsockTest17_1::easyTestStepL()
       
    40 	{
       
    41 	//
       
    42 	// ClassA()  	   //
       
    43 	//
       
    44 	
       
    45 	// Get Valid IPv4 Addresses - appendixInArray
       
    46 	if (!GetAppendixB1())
       
    47 		return EFail;
       
    48 	
       
    49 	for (TInt i = 0;i < appendixInArray.Count();i++)
       
    50 		{
       
    51 		// Get IP Class A
       
    52 		if ((i == 0)||(i==5)||(i==6))	//These are all class A addresses
       
    53 			{
       
    54 			TESTL(appendixInArray[i].IsClassA()!=EFalse);
       
    55 			}
       
    56 		else
       
    57 			{
       
    58 			TESTL(appendixInArray[i].IsClassA()==EFalse);
       
    59 			}
       
    60 		} 
       
    61 
       
    62 	appendixInArray.Reset();
       
    63 	return EPass;
       
    64 	}
       
    65 
       
    66 
       
    67 // Test step 17.2
       
    68 const TDesC& CEsockTest17_2::GetTestName()
       
    69 	{
       
    70 	// store the name of this test case
       
    71 	_LIT(ret,"Test17.2");
       
    72 	return ret;
       
    73 	}
       
    74 
       
    75 CEsockTest17_2::~CEsockTest17_2()
       
    76 	{
       
    77 	appendixInArray.Close();
       
    78 	}
       
    79 
       
    80 enum TVerdict CEsockTest17_2::easyTestStepL()
       
    81 	{
       
    82 	//
       
    83 	// ClassB()  	   //
       
    84 	//
       
    85 	
       
    86 	// Get Valid IPv4 Addresses - appendixInArray
       
    87 	if (!GetAppendixB1())
       
    88 		return EFail;
       
    89 	
       
    90 	for (TInt i = 0;i < appendixInArray.Count();i++)
       
    91 		{
       
    92 		// Get IP Class B
       
    93 		if (i == 1)
       
    94 			{
       
    95 			TESTL(appendixInArray[i].IsClassB()!=EFalse);
       
    96 			}
       
    97 		else
       
    98 			{
       
    99 			TESTL(appendixInArray[i].IsClassB()==EFalse);
       
   100 			}
       
   101 		}
       
   102 	
       
   103 	appendixInArray.Reset();
       
   104 	return EPass;
       
   105 	}
       
   106 
       
   107 
       
   108 // Test step 17.3
       
   109 const TDesC& CEsockTest17_3::GetTestName()
       
   110 	{
       
   111 	// store the name of this test case
       
   112 	_LIT(ret,"Test17.3");
       
   113 	return ret;
       
   114 	}
       
   115 
       
   116 CEsockTest17_3::~CEsockTest17_3()
       
   117 	{
       
   118 	appendixInArray.Close();
       
   119 	}
       
   120 
       
   121 enum TVerdict CEsockTest17_3::easyTestStepL()
       
   122 	{
       
   123 	//
       
   124 	// ClassC()  	   //
       
   125 	//
       
   126 	
       
   127 	// Get Valid IPv4 Addresses - appendixInArray
       
   128 	if (!GetAppendixB1())
       
   129 		return EFail;
       
   130 	
       
   131 	for (TInt i = 0;i < appendixInArray.Count();i++)
       
   132 		{
       
   133 		if (i == 2)
       
   134 			{
       
   135 			TESTL(appendixInArray[i].IsClassC()!=EFalse);
       
   136 			}
       
   137 		else
       
   138 			{
       
   139 			TESTL(appendixInArray[i].IsClassC()==EFalse);
       
   140 			}
       
   141 		}
       
   142 	
       
   143 	appendixInArray.Reset();
       
   144 	return EPass;
       
   145 	}
       
   146 
       
   147 
       
   148 // Test step 17.4
       
   149 const TDesC& CEsockTest17_4::GetTestName()
       
   150 	{
       
   151 	// store the name of this test case
       
   152 	_LIT(ret,"Test17.4");
       
   153 	return ret;
       
   154 	}
       
   155 
       
   156 CEsockTest17_4::~CEsockTest17_4()
       
   157 	{
       
   158 	appendixInArray.Close();
       
   159 	}
       
   160 
       
   161 enum TVerdict CEsockTest17_4::easyTestStepL()
       
   162 	{
       
   163 	//
       
   164 	// IsMulticast() - ClassD //
       
   165 	//
       
   166 	
       
   167 	// Get Valid IPv4 Addresses - appendixInArray
       
   168 	if (!GetAppendixB1())
       
   169 		return EFail;
       
   170 	
       
   171 	for (TInt i = 0;i < appendixInArray.Count();i++)
       
   172 		{
       
   173 		if (i == 3)
       
   174 			{
       
   175 			TESTL(appendixInArray[i].IsMulticast()!=EFalse);
       
   176 			}
       
   177 		else
       
   178 			{
       
   179 			TESTL(appendixInArray[i].IsMulticast()==EFalse);
       
   180 			}
       
   181 		}
       
   182 	
       
   183 	appendixInArray.Reset();
       
   184 	return EPass;
       
   185 	}
       
   186 
       
   187 
       
   188 // Test step 17.5
       
   189 const TDesC& CEsockTest17_5::GetTestName()
       
   190 	{
       
   191 	// store the name of this test case
       
   192 	_LIT(ret,"Test17.5");
       
   193 	return ret;
       
   194 	}
       
   195 
       
   196 CEsockTest17_5::~CEsockTest17_5()
       
   197 	{
       
   198 	appendixInArray.Close();
       
   199 	}
       
   200 
       
   201 enum TVerdict CEsockTest17_5::easyTestStepL()
       
   202 	{
       
   203 	//
       
   204 	// IsWildAddr()           //
       
   205 	//
       
   206 	
       
   207 	// Get Valid IPv4 Addresses - appendixInArray
       
   208 	if (!GetAppendixB1())
       
   209 		return EFail;
       
   210 	
       
   211 	for (TInt i = 0;i < appendixInArray.Count();i++)
       
   212 		{
       
   213 		if (i == 6)
       
   214 			{
       
   215 			TESTL(appendixInArray[i].IsWildAddr()!=EFalse);
       
   216 			}
       
   217 		else
       
   218 			{
       
   219 			TESTL(appendixInArray[i].IsWildAddr()==EFalse);
       
   220 			}
       
   221 		}
       
   222 	
       
   223 	appendixInArray.Reset();
       
   224 	return EPass;
       
   225 	}
       
   226 
       
   227 
       
   228 // Test step 17.6
       
   229 const TDesC& CEsockTest17_6::GetTestName()
       
   230 	{
       
   231 	// store the name of this test case
       
   232 	_LIT(ret,"Test17.6");
       
   233 	return ret;
       
   234 	}
       
   235 
       
   236 CEsockTest17_6::~CEsockTest17_6()
       
   237 	{
       
   238 	appendixInArray.Close();
       
   239 	}
       
   240 
       
   241 enum TVerdict CEsockTest17_6::easyTestStepL()
       
   242 	{
       
   243 	//
       
   244 	// IsBroadcast()          //
       
   245 	//
       
   246 	
       
   247 	// Get Valid IPv4 Addresses - appendixInArray
       
   248 	if (!GetAppendixB1())
       
   249 		return EFail;
       
   250 	
       
   251 	for (TInt i = 0;i < appendixInArray.Count();i++)
       
   252 		{
       
   253 		if (i == 7)
       
   254 			{
       
   255 			TESTL(appendixInArray[i].IsBroadcast()!=EFalse);
       
   256 			}
       
   257 		else
       
   258 			{
       
   259 			TESTL(appendixInArray[i].IsBroadcast()==EFalse);
       
   260 			}
       
   261 		}
       
   262 	
       
   263 	appendixInArray.Reset();
       
   264 	return EPass;
       
   265 	}
       
   266 
       
   267 
       
   268 // Test step 17.7
       
   269 const TDesC& CEsockTest17_7::GetTestName()
       
   270 	{
       
   271 	// store the name of this test case
       
   272 	_LIT(ret,"Test17.7");
       
   273 	return ret;
       
   274 	}
       
   275 
       
   276 CEsockTest17_7::~CEsockTest17_7()
       
   277 	{
       
   278 	}
       
   279 
       
   280 enum TVerdict CEsockTest17_7::easyTestStepL()
       
   281 	{
       
   282 	//
       
   283 	//     IsWildPort() //
       
   284 	//
       
   285 	
       
   286 	TInetAddr addr;
       
   287 	
       
   288 	addr.SetAddress(IPADDR(126,0,0,1));
       
   289 	addr.SetPort(0);		// IP Address to 126,0,0,1 and Port to Zero
       
   290 	TESTL(addr.IsWildPort()!=EFalse);				// Port = 0 -	True
       
   291 	
       
   292 	addr.SetPort(21);								// Sets Port to 21 FTP
       
   293 	TESTL(addr.IsWildPort()==EFalse);				// Port = 21 -	False
       
   294 	
       
   295 	addr.SetAddress(IPADDR(191,220,145,22));		// IP Address to 191.220.145.22
       
   296 	TESTL(addr.IsWildPort()==EFalse);				// Port = 21 -	False
       
   297 	
       
   298 	addr.SetPort(0);								// Sets Port to 0
       
   299 	TESTL(addr.IsWildPort()!=EFalse);				// Port = 0 -	True
       
   300 	
       
   301 	return EPass;
       
   302 	}
       
   303 
       
   304 
       
   305 // Test step 17.8
       
   306 const TDesC& CEsockTest17_8::GetTestName()
       
   307 	{
       
   308 	// store the name of this test case
       
   309 	_LIT(ret,"Test17.8");
       
   310 	return ret;
       
   311 	}
       
   312 
       
   313 CEsockTest17_8::~CEsockTest17_8()
       
   314 	{
       
   315 	appendixInArray.Close();
       
   316 	}
       
   317 
       
   318 enum TVerdict CEsockTest17_8::easyTestStepL()
       
   319 	{
       
   320 	//
       
   321 	// IsLoopback()           //
       
   322 	//
       
   323 	
       
   324 	// Get Valid IPv4 Addresses - appendixInArray
       
   325 	if (!GetAppendixB1())
       
   326 		return EFail;
       
   327 	
       
   328 	for (TInt i = 0;i < appendixInArray.Count();i++)
       
   329 		{
       
   330 		if (i == 5)
       
   331 			{
       
   332 			TESTL(appendixInArray[i].IsLoopback()!=EFalse);
       
   333 			}
       
   334 		else
       
   335 			{
       
   336 			TESTL(appendixInArray[i].IsLoopback()==EFalse);
       
   337 			}
       
   338 		}
       
   339 	
       
   340 	appendixInArray.Reset();
       
   341 	return EPass;
       
   342 	}
       
   343 
       
   344 
       
   345 // Test step 17.9
       
   346 const TDesC& CEsockTest17_9::GetTestName()
       
   347 	{
       
   348 	// store the name of this test case
       
   349 	_LIT(ret,"Test17.9");
       
   350 	return ret;
       
   351 	}
       
   352 
       
   353 CEsockTest17_9::~CEsockTest17_9()
       
   354 	{
       
   355 	appendixInArray.Close();
       
   356 	}
       
   357 
       
   358 enum TVerdict CEsockTest17_9::easyTestStepL()
       
   359 	{
       
   360 	//
       
   361 	// IsUnspecified()        //
       
   362 	//
       
   363 	
       
   364 	// Get Valid IPv4 Addresses - appendixInArray
       
   365 	if (!GetAppendixB1())
       
   366 		return EFail;
       
   367 	
       
   368 	for (TInt i = 0;i < appendixInArray.Count();i++)
       
   369 		{
       
   370 		if (i == 6)
       
   371 			{
       
   372 			TESTL(appendixInArray[i].IsUnspecified()!=EFalse);
       
   373 			}
       
   374 		else
       
   375 			{
       
   376 			TESTL(appendixInArray[i].IsUnspecified()==EFalse);
       
   377 			}
       
   378 		}
       
   379 	
       
   380 	appendixInArray.Reset();
       
   381 	return EPass;
       
   382 	}
       
   383 
       
   384 
       
   385 // Test step 17.10
       
   386 const TDesC& CEsockTest17_10::GetTestName()
       
   387 	{
       
   388 	// store the name of this test case
       
   389 	_LIT(ret,"Test17.10");
       
   390 	return ret;
       
   391 	}
       
   392 
       
   393 CEsockTest17_10::~CEsockTest17_10()
       
   394 	{
       
   395 	appendixInArray.Close();
       
   396 	}
       
   397 
       
   398 enum TVerdict CEsockTest17_10::easyTestStepL()
       
   399 	{
       
   400 	//
       
   401 	// IsUnicast()     //
       
   402 	//	If NOT Multicast() (0xff) then is IsUnicast()
       
   403 	
       
   404 	// Get Valid IPv4 Addresses - appendixInArray
       
   405 	if (!GetAppendixB1())
       
   406 		return EFail;
       
   407 	
       
   408 	// Class A - Pass
       
   409 	TESTL(appendixInArray[0].IsUnicast()!=EFalse);
       
   410 	
       
   411 	// Class B - Pass
       
   412 	TESTL(appendixInArray[1].IsUnicast()!=EFalse);
       
   413 	
       
   414 	// Class C - Pass
       
   415 	TESTL(appendixInArray[2].IsUnicast()!=EFalse);
       
   416 	
       
   417 	// Class D - Fail
       
   418 	TESTL(appendixInArray[3].IsUnicast()==EFalse);
       
   419 	
       
   420 	// Loopback - Pass
       
   421 	TESTL(appendixInArray[5].IsUnicast()!=EFalse);
       
   422 	
       
   423 	// Unspecified - Fail
       
   424 	TESTL(appendixInArray[6].IsUnicast()==EFalse);
       
   425 	
       
   426 	appendixInArray.Reset();
       
   427 	return EPass;
       
   428 	}
       
   429