servicediscoveryandcontrol/pnp/test/upnp/unittests/testclient/src/testclientstep.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-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 // testupnpdescriptionservicestep.cpp
       
    15 // Contains implementation of testupnpdescriptionservicestep class
       
    16 // @internalAll
       
    17 // 
       
    18 //
       
    19 
       
    20 // System Include
       
    21 // for StartC32()
       
    22 #include <c32comm.h>
       
    23 #include <e32base.h>
       
    24 #include "pnputils.h"
       
    25 
       
    26 // User Include
       
    27 #include "testclientstep.h"
       
    28 /**
       
    29 Constructor: Sets the test step name.
       
    30 @internalTechnology
       
    31 @test
       
    32 */
       
    33 CTestClientServiceTestStep::CTestClientServiceTestStep()
       
    34 	{
       
    35 
       
    36 	SetTestStepName(KTestClientServiceStep);
       
    37 	}
       
    38 
       
    39 
       
    40 /**
       
    41 Destructor: Closes the iFileServ.
       
    42 @internalTechnology
       
    43 @test
       
    44 */
       
    45 CTestClientServiceTestStep::~CTestClientServiceTestStep()
       
    46 	{
       
    47 	}
       
    48 
       
    49 
       
    50 /**
       
    51 Base class virtual doTestStepPreambleL():
       
    52 Create and install the active scheduler and connect to iFileServ (RFs).
       
    53 @internalTechnology
       
    54 @test
       
    55 @param		None
       
    56 @return		EPass or EFail.
       
    57 */
       
    58 TVerdict CTestClientServiceTestStep::doTestStepPreambleL()
       
    59 	{
       
    60     return TestStepResult();
       
    61 	}	// doTestPreambleL
       
    62 
       
    63 
       
    64 /**
       
    65 Base class pure virtual doTestStepL():
       
    66 @internalTechnology
       
    67 @test
       
    68 @param		None
       
    69 @return		EPass or EFail indicating the result of the test step.
       
    70 */
       
    71 TVerdict CTestClientServiceTestStep::doTestStepL()
       
    72 	{
       
    73 	_LIT(KUriValidity, "uriValidity");
       
    74 	_LIT(KHostResolver, "hostResolver");
       
    75 
       
    76 	TInt result = 0;
       
    77 	TInt testUriValidity;
       
    78 	TInt testHostResolver;
       
    79 	
       
    80 	if (!GetIntFromConfig(ConfigSection(),KUriValidity,testUriValidity)||
       
    81 	!GetIntFromConfig(ConfigSection(),KHostResolver,testHostResolver))
       
    82 		{
       
    83 		SetTestStepResult(EFail);
       
    84 		return TestStepResult();
       
    85 		}
       
    86 	
       
    87 	while( testUriValidity )
       
    88 		{
       
    89 		switch ( testUriValidity )
       
    90 		{
       
    91 			
       
    92 		case 1 : 
       
    93 			{
       
    94 			_LIT8(KDes,"des");
       
    95 			result = CUPnPUtils::GenericUriValidity ( KDes ,CUPnPUtils::EDevice);
       
    96 			if ( result == KErrCorrupt)
       
    97 				testUriValidity = 2;
       
    98 			else
       
    99 				{
       
   100 				SetTestStepResult(EFail);
       
   101 				return TestStepResult();
       
   102 				}
       
   103 			}
       
   104 			break;
       
   105 		case 2:
       
   106 			{
       
   107 			_LIT8(KUid,"uuidhelloworld");
       
   108 			result = CUPnPUtils::GenericUriValidity ( KUid ,CUPnPUtils::EDevice);
       
   109 			if ( result == KErrCorrupt)
       
   110 				testUriValidity = 3;
       
   111 			else
       
   112 				{
       
   113 				SetTestStepResult(EFail);
       
   114 				return TestStepResult();
       
   115 				}
       
   116 			}
       
   117 			
       
   118 			break;
       
   119 		case 3 : 
       
   120 			{
       
   121 			_LIT8(KHello,"helloworld");
       
   122 			result = CUPnPUtils::GenericUriValidity ( KHello ,CUPnPUtils::EDevice);
       
   123 			if ( result == KErrCorrupt)
       
   124 				testUriValidity = 4;
       
   125 			else
       
   126 				{
       
   127 				SetTestStepResult(EFail);
       
   128 				return TestStepResult();
       
   129 				}
       
   130 			}
       
   131 			break;		
       
   132 		case 4 : 
       
   133 			{
       
   134 			_LIT8(KUrn,"urn:");
       
   135 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EDevice);
       
   136 			if ( result == KErrCorrupt)
       
   137 				testUriValidity = 5;
       
   138 			else
       
   139 				{
       
   140 				SetTestStepResult(EFail);
       
   141 				return TestStepResult();
       
   142 				}
       
   143 			}
       
   144 			break;	
       
   145 		case 5 : 
       
   146 			{
       
   147 			_LIT8(KUrn,"urn:able");
       
   148 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EDevice);
       
   149 			if ( result == KErrCorrupt)
       
   150 				testUriValidity = 6;
       
   151 			else
       
   152 				{
       
   153 				SetTestStepResult(EFail);
       
   154 				return TestStepResult();
       
   155 				}
       
   156 			}
       
   157 			break;	
       
   158 		case 6 : 
       
   159 			{
       
   160 			_LIT8(KUrn,"urn:able:");
       
   161 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EDevice);
       
   162 			if ( result == KErrCorrupt)
       
   163 				testUriValidity = 7;
       
   164 			else
       
   165 				{
       
   166 				SetTestStepResult(EFail);
       
   167 				return TestStepResult();
       
   168 				}
       
   169 			}
       
   170 			break;		
       
   171 		case 7 : 
       
   172 			{
       
   173 			_LIT8(KUrn,"urn:able:");
       
   174 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EDevice);
       
   175 			if ( result == KErrCorrupt)
       
   176 				testUriValidity = 8;
       
   177 			else
       
   178 				{
       
   179 				SetTestStepResult(EFail);
       
   180 				return TestStepResult();
       
   181 				}
       
   182 			}
       
   183 			break;	
       
   184 		case 8 : 
       
   185 			{
       
   186 			_LIT8(KUrn,"urn:able:device");
       
   187 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EDevice);
       
   188 			if ( result == KErrCorrupt)
       
   189 				testUriValidity = 9;
       
   190 			else
       
   191 				{
       
   192 				SetTestStepResult(EFail);
       
   193 				return TestStepResult();
       
   194 				}
       
   195 			}
       
   196 			break;	
       
   197 		case 9 : 
       
   198 			{
       
   199 			_LIT8(KUrn,"urn:able:service:1");
       
   200 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EDevice);
       
   201 			if ( result == KErrCorrupt)
       
   202 				testUriValidity = 10;
       
   203 			else
       
   204 				{
       
   205 				SetTestStepResult(EFail);
       
   206 				return TestStepResult();
       
   207 				}
       
   208 			}
       
   209 			break;	
       
   210 		case 10 : 
       
   211 			{
       
   212 			_LIT8(KUrn,"urn:able:device:1");
       
   213 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EService);
       
   214 			if ( result == KErrCorrupt)
       
   215 				testUriValidity = 11;
       
   216 			else
       
   217 				{
       
   218 				SetTestStepResult(EFail);
       
   219 				return TestStepResult();
       
   220 				}
       
   221 			}
       
   222 			break;	
       
   223 		case 11 : 
       
   224 			{
       
   225 			_LIT8(KUrn,"urn:able:helllo:1");
       
   226 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EAny);
       
   227 			if ( result == KErrCorrupt)
       
   228 				testUriValidity = 12;
       
   229 			else
       
   230 				{
       
   231 				SetTestStepResult(EFail);
       
   232 				return TestStepResult();
       
   233 				}
       
   234 			}
       
   235 			break;	
       
   236 		case 12 : 
       
   237 			{
       
   238 			_LIT8(KUrn,"urn:able:helllo:1");
       
   239 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EDevice);
       
   240 			if ( result == KErrCorrupt)
       
   241 				testUriValidity = 13;
       
   242 			else
       
   243 				{
       
   244 				SetTestStepResult(EFail);
       
   245 				return TestStepResult();
       
   246 				}
       
   247 			}
       
   248 			break;	
       
   249 		case 13 : 
       
   250 			{
       
   251 			_LIT8(KUrn,"urn:able:service:");
       
   252 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EService);
       
   253 			if ( result == KErrCorrupt)
       
   254 				testUriValidity = 14;
       
   255 			else
       
   256 				{
       
   257 				SetTestStepResult(EFail);
       
   258 				return TestStepResult();
       
   259 				}
       
   260 			}
       
   261 			break;	
       
   262 		case 14 : 
       
   263 			{
       
   264 			_LIT8(KUrn,"urn:able:service:serviceType");
       
   265 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EService);
       
   266 			if ( result == KErrCorrupt)
       
   267 				testUriValidity = 15;
       
   268 			else
       
   269 				{
       
   270 				SetTestStepResult(EFail);
       
   271 				return TestStepResult();
       
   272 				}
       
   273 			}
       
   274 			break;	
       
   275 		case 15 : 
       
   276 			{
       
   277 			_LIT8(KUrn,"urn:able:service:serviceType");
       
   278 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EService);
       
   279 			if ( result == KErrCorrupt)
       
   280 				testUriValidity = 16;
       
   281 			else
       
   282 				{
       
   283 				SetTestStepResult(EFail);
       
   284 				return TestStepResult();
       
   285 				}
       
   286 			}
       
   287 			break;	
       
   288 		case 16 : 
       
   289 			{
       
   290 			_LIT8(KUrn,"urn:able:service:abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij:1");
       
   291 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EService);
       
   292 			if ( result == KErrCorrupt)
       
   293 				testUriValidity = 17;
       
   294 			else
       
   295 				{
       
   296 				SetTestStepResult(EFail);
       
   297 				return TestStepResult();
       
   298 				}
       
   299 			}
       
   300 			break;		
       
   301 		case 17 : 
       
   302 			{
       
   303 			_LIT8(KUrn,"urn:able:service:serviceType:+");
       
   304 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EService);
       
   305 			if ( result == KErrCorrupt)
       
   306 				testUriValidity = 18;
       
   307 			else
       
   308 				{
       
   309 				SetTestStepResult(EFail);
       
   310 				return TestStepResult();
       
   311 				}
       
   312 			}
       
   313 			break;
       
   314 			
       
   315 		case 18 : 
       
   316 			{
       
   317 			_LIT8(KUrn,"urn:able:service:serviceType:a");
       
   318 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EService);
       
   319 			if ( result == KErrCorrupt)
       
   320 				testUriValidity = 19;
       
   321 			else
       
   322 				{
       
   323 				SetTestStepResult(EFail);
       
   324 				return TestStepResult();
       
   325 				}
       
   326 			}
       
   327 			break;
       
   328 		case 19 :
       
   329 			{
       
   330 			_LIT8(KUrn,"uuid:1348481083930030030");
       
   331 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EDevice);
       
   332 			if ( result == KErrNone)
       
   333 				testUriValidity = 20;
       
   334 			else
       
   335 				{
       
   336 				SetTestStepResult(EFail);
       
   337 				return TestStepResult();
       
   338 				}
       
   339 			}
       
   340 			break;
       
   341 		case 20 :
       
   342 			{
       
   343 			_LIT8(KUrn,"upnp:rootdevice");
       
   344 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EDevice);
       
   345 			if ( result == KErrNone)
       
   346 				testUriValidity = 21;
       
   347 			else
       
   348 				{
       
   349 				SetTestStepResult(EFail);
       
   350 				return TestStepResult();
       
   351 				}
       
   352 			}
       
   353 			break;
       
   354 		case 21 :
       
   355 			{
       
   356 			_LIT8(KUrn,"urn:schemas-upnp-org:service:ContentDirectory:1");
       
   357 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EService);
       
   358 			if ( result == KErrNone)
       
   359 				testUriValidity = 22;
       
   360 			else
       
   361 				{
       
   362 				SetTestStepResult(EFail);
       
   363 				return TestStepResult();
       
   364 				}
       
   365 			}
       
   366 			break;
       
   367 		case 22 :
       
   368 			{
       
   369 			_LIT8(KUrn,"urn:schemas-upnp-org:device:ContentDirectory:1");
       
   370 			result = CUPnPUtils::GenericUriValidity ( KUrn ,CUPnPUtils::EDevice);
       
   371 			if ( result == KErrNone)
       
   372 				{
       
   373 				testUriValidity = 0;
       
   374 				SetTestStepResult(EPass);
       
   375 				return TestStepResult();
       
   376 				}
       
   377 			else
       
   378 				{
       
   379 				SetTestStepResult(EFail);
       
   380 				return TestStepResult();
       
   381 				}
       
   382 			}			
       
   383 			
       
   384 		
       
   385 		default:
       
   386 			{
       
   387 			SetTestStepResult(EFail);
       
   388 			return TestStepResult();		
       
   389 			}			
       
   390 		}
       
   391 		}
       
   392 	while ( testHostResolver )
       
   393 		{
       
   394 		RSocketServ ss;
       
   395 		TInt err = ss.Connect();
       
   396 		RHostResolver resolver;
       
   397 		err = resolver.Open( ss , KAfInet , KProtocolInetTcp);// , iConnection);
       
   398 		TInetAddr address;
       
   399 		switch ( testHostResolver )
       
   400 			{
       
   401 			case 1:
       
   402 				{
       
   403 				_LIT8(KUri,"http://10.192.197.2:2869/");
       
   404 				TRAP(err, CUPnPUtils::ResolveHostAddressL ( resolver,KUri, address ));
       
   405 				if ( err == KErrNone )
       
   406 					testHostResolver = 2;
       
   407 				else
       
   408 					{
       
   409 					SetTestStepResult(EFail);
       
   410 					return TestStepResult();
       
   411 					}	
       
   412 				}	
       
   413 			case 2:
       
   414 				{
       
   415 				_LIT8(KUri,"junk://notneeded.com/");
       
   416 				TRAP(err, CUPnPUtils::ResolveHostAddressL ( resolver,KUri, address ));
       
   417 				if ( err == KErrCorrupt )
       
   418 					testHostResolver = 3;
       
   419 				else
       
   420 					{
       
   421 					SetTestStepResult(EFail);
       
   422 					return TestStepResult();
       
   423 					}	
       
   424 				}	
       
   425 			case 3:
       
   426 				{
       
   427 				_LIT8(KUri,"http://www.google.com/");
       
   428 				TRAP(err, CUPnPUtils::ResolveHostAddressL ( resolver,KUri, address ));
       
   429 				if ( err == KErrNone )
       
   430 					{
       
   431 					SetTestStepResult(EPass);
       
   432 					return TestStepResult();
       
   433 					}
       
   434 				else
       
   435 					{
       
   436 					SetTestStepResult(EFail);
       
   437 					return TestStepResult();
       
   438 					}
       
   439 				}
       
   440 				
       
   441 			}
       
   442 		}
       
   443 	
       
   444 	SetTestStepResult(EPass);
       
   445 	return TestStepResult();
       
   446 	}
       
   447