applayerpluginsandutils/uripermissionservices/Test/tineturilisttests.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2007-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 "tineturilisttests.h"
       
    17 #include <cauthentication.h>
       
    18 #include "testutils.h"
       
    19 
       
    20 #define __LEAVEIFOOM__ if ( err == KErrNoMemory ) \
       
    21 				User::Leave ( err );
       
    22 #define __PRINTIFNOTOOM__ if ( iNormalRun )
       
    23 
       
    24 CInetUriListTestsBase::CInetUriListTestsBase ( CTestWrapper& aTestWrapper, TBool aNormalRun )
       
    25 : iTestWrapper ( aTestWrapper ),
       
    26 iNormalRun ( aNormalRun )
       
    27 	{
       
    28 		
       
    29 	}
       
    30 
       
    31 CInetUriListTestsBase::~CInetUriListTestsBase ()
       
    32 	{
       
    33 	iInetUriList.Close ();		
       
    34 	}
       
    35 
       
    36 void CInetUriListTestsBase::ConstructL ()
       
    37 	{
       
    38 	iInetUriList.OpenL ();
       
    39 	}
       
    40 
       
    41 RInetUri CInetUriListTestsBase::CreateNewUriL ( const TDesC8& aUri, TServiceType aServiceType, TListType aListType )
       
    42 	{
       
    43 	RInetUri myInetUri;
       
    44 	CleanupClosePushL ( myInetUri );
       
    45 	myInetUri.CreateL ( aUri, aServiceType, aListType );
       
    46 	CleanupStack::Pop (); // myInetUri 
       
    47 	return myInetUri;			
       
    48 	}
       
    49 
       
    50 void CInetUriListTestsBase::RunTestsL ()
       
    51 	{
       
    52 	if ( iNormalRun )
       
    53 		{
       
    54 		DoCleanupL ();
       
    55 		DoOperationL ();		
       
    56 		}		
       
    57 	else
       
    58 		{
       
    59 		TInt ret = KErrNoMemory;
       
    60 		TInt failAt = 0;
       
    61 		while( ret != KErrNone )
       
    62 			{
       
    63 			DoCleanupL ();
       
    64 			failAt++;
       
    65    			iTestWrapper.Tester().Printf( _L( "Test step: %d\n" ), failAt );					
       
    66 			__UHEAP_RESET;
       
    67 			__UHEAP_SETFAIL( RHeap::EDeterministic, failAt );
       
    68 			TInt countBefore = User::CountAllocCells();			
       
    69 			
       
    70 			TRAP ( ret, DoOperationL () );
       
    71 
       
    72 			TInt countAfter = User::CountAllocCells();					
       
    73 			__UHEAP_RESET;	
       
    74 			if ( countBefore != countAfter )
       
    75 				{
       
    76 				iTestWrapper.Tester().Printf ( _L ("OOM test failed at iteration %d"), failAt );
       
    77 				break;
       
    78 				}
       
    79 			}	
       
    80 		iTestWrapper.Tester().Printf ( _L ("OOM test has been successfully completed. Total iterations: %d"), failAt );							
       
    81 		}
       
    82 	}
       
    83 // -----------------------
       
    84 
       
    85 CInetUriListStorageTests* CInetUriListStorageTests::NewL ( CTestWrapper& aTestWrapper, TBool aNormalRun )
       
    86 	{
       
    87 	CInetUriListStorageTests* self  = new ( ELeave )CInetUriListStorageTests ( aTestWrapper, aNormalRun );
       
    88 	CleanupStack::PushL ( self );
       
    89 	self->ConstructL ();
       
    90 	CleanupStack::Pop ();
       
    91 	return self;
       
    92 	}
       
    93 	
       
    94 CInetUriListStorageTests::~CInetUriListStorageTests ()
       
    95 	{
       
    96 		
       
    97 	}
       
    98 
       
    99 CInetUriListStorageTests::CInetUriListStorageTests ( CTestWrapper& aTestWrapper, TBool aNormalRun )
       
   100 : CInetUriListTestsBase ( aTestWrapper, aNormalRun )
       
   101 	{
       
   102 		
       
   103 	}
       
   104 
       
   105 void CInetUriListStorageTests::DoOperationL ()
       
   106 	{
       
   107 	iTestWrapper.SetFile ( _L ("tineturilisttests.cpp") );
       
   108 	AddTestsL ();
       
   109 	GetListTypeL ();
       
   110 	UpdateTestsL ();		
       
   111 	RemoveTestsL ();
       
   112 	SameUriDiffServiceTypeTestsL ();
       
   113 	AddFewMoreUrisL ();
       
   114 	}
       
   115 
       
   116 void CInetUriListStorageTests::DoCleanupL ()
       
   117 	{
       
   118 	CInetUriListCleanup* listCleanup = CInetUriListCleanup::NewL (iTestWrapper);
       
   119 	CleanupStack::PushL ( listCleanup );
       
   120 	listCleanup->DoOperationL ();
       
   121 	CleanupStack::PopAndDestroy (); // listCleanup		
       
   122 	}
       
   123 
       
   124 void CInetUriListStorageTests::AddTestsL ()
       
   125 	{
       
   126 	__PRINTIFNOTOOM__
       
   127 	iTestWrapper.Next ( _L ( "URI add tests" ) );
       
   128 	// Create a new uri
       
   129 	RInetUri myInetUri = CreateNewUriL ( KTestUri(), InetUriList::EWapPush, InetUriList::EWhiteList );
       
   130 	CleanupClosePushL ( myInetUri );
       
   131 	myInetUri.SetFavouriteNameL ( KUriFavouriteName() );
       
   132 	
       
   133 	// Add the uri
       
   134 	TRAPD ( err, iInetUriList.AddL ( myInetUri ) );
       
   135 	__LEAVEIFOOM__	
       
   136 	iTestWrapper.TESTE( err==KErrNone, err );
       
   137 	
       
   138 	// Create another uri
       
   139 	RInetUri myInetUri2 = CreateNewUriL ( KTestUri2(), InetUriList::EWapPush, InetUriList::EWhiteList );
       
   140 	CleanupClosePushL ( myInetUri2 );
       
   141 
       
   142 	// Add the uri
       
   143 	TRAP ( err, iInetUriList.AddL ( myInetUri2 ) );
       
   144 	__LEAVEIFOOM__
       
   145 	iTestWrapper.TESTE( err==KErrNone, err );
       
   146 	
       
   147 	TRAP ( err, iInetUriList.AddL ( myInetUri ) );
       
   148 	__LEAVEIFOOM__
       
   149 	iTestWrapper.TESTE( err==InetUriList::KErrUriAlreadyExists, err );
       
   150 
       
   151 	// Create another uri
       
   152 	RInetUri myInetUri3 = CreateNewUriL ( KTestUri3(), InetUriList::EWapPush, InetUriList::EBlackList );
       
   153 	CleanupClosePushL ( myInetUri3 );
       
   154 
       
   155 	// Add the uri
       
   156 	TRAP ( err, iInetUriList.AddL ( myInetUri3 ) );
       
   157 	__LEAVEIFOOM__
       
   158 	iTestWrapper.TESTE( err==KErrNone, err );
       
   159 	
       
   160 	TInt count = iInetUriList.Count ( InetUriList::EWapPush, InetUriList::EWhiteList );
       
   161 	// 2 URI has been added
       
   162 	iTestWrapper.TEST( count == 2 );
       
   163 	
       
   164 	CleanupStack::PopAndDestroy (3); // inetUri, inetUri2, inetUri3
       
   165 
       
   166 	
       
   167 	count = iInetUriList.Count ( InetUriList::EWapPush, InetUriList::EWhiteList );
       
   168 	// 2 URI has been added
       
   169 	iTestWrapper.TEST( count == 2 );
       
   170 	count = iInetUriList.Count ( InetUriList::EWapPush, InetUriList::EBlackList );
       
   171 	// 2 URI has been added
       
   172 	iTestWrapper.TEST( count == 1 );
       
   173 		
       
   174 	}
       
   175 
       
   176 void CInetUriListStorageTests::RemoveTestsL ()
       
   177 	{
       
   178 	__PRINTIFNOTOOM__
       
   179 	iTestWrapper.Next ( _L ( "URI remove test" ) );			
       
   180 	RInetUri myInetUri = iInetUriList.OpenInetUriL ( KTestUri2(), InetUriList::EWapPush );
       
   181 	CleanupClosePushL ( myInetUri );
       
   182 	TRAPD ( err, iInetUriList.RemoveL ( myInetUri ) );
       
   183 	__LEAVEIFOOM__
       
   184 	iTestWrapper.TEST ( err == KErrNone );
       
   185 	
       
   186 	// Try to update. Must return KErrNotFound
       
   187 	TRAP ( err, iInetUriList.UpdateL ( myInetUri ) );
       
   188 	__LEAVEIFOOM__
       
   189 	iTestWrapper.TEST ( err == InetUriList::KErrUriNotFound );
       
   190 
       
   191 	CleanupStack::PopAndDestroy ( &myInetUri );	
       
   192 	
       
   193 	// Open the same URI
       
   194 	TRAP ( err, myInetUri = iInetUriList.OpenInetUriL ( KTestUri2(), InetUriList::EWapPush ) );		
       
   195 	__LEAVEIFOOM__
       
   196 	iTestWrapper.TEST ( err == InetUriList::KErrUriNotFound );
       
   197 	
       
   198 	// Now we are having only 1 URI in whitelist and blacklist
       
   199 	TInt count = iInetUriList.Count ( InetUriList::EWapPush, InetUriList::EWhiteList );
       
   200 	// 1 URI has been added
       
   201 	iTestWrapper.TEST( count == 1 );
       
   202 	count = iInetUriList.Count ( InetUriList::EWapPush, InetUriList::EBlackList );
       
   203 	// 1 URI has been added
       
   204 	iTestWrapper.TEST( count == 1 );		
       
   205 	}
       
   206 
       
   207 void CInetUriListStorageTests::UpdateTestsL ()
       
   208 	{
       
   209 	__PRINTIFNOTOOM__
       
   210 	iTestWrapper.Next ( _L ( "URI update test" ) );		
       
   211 	RInetUri myInetUri = iInetUriList.OpenInetUriL ( KTestUri2(), InetUriList::EWapPush );
       
   212 	CleanupClosePushL ( myInetUri );
       
   213 	// Update list type
       
   214 	myInetUri.SetListType ( InetUriList::EBlackList );
       
   215 	TRAPD ( err, iInetUriList.UpdateL ( myInetUri ) );
       
   216 	__LEAVEIFOOM__
       
   217 	iTestWrapper.TESTE( err==KErrNone, err );
       
   218 	CleanupStack::PopAndDestroy (&myInetUri); // myInetUri
       
   219 
       
   220 	// Check list type is updated proeprly
       
   221 	myInetUri = iInetUriList.OpenInetUriL ( KTestUri2(), InetUriList::EWapPush );
       
   222 	CleanupClosePushL ( myInetUri );	
       
   223 	iTestWrapper.TEST ( myInetUri.ListType() == InetUriList::EBlackList );
       
   224 	// Update favourite name
       
   225 	myInetUri.SetFavouriteNameL ( KUriFavouriteName2() );
       
   226 	TRAP ( err, iInetUriList.UpdateL ( myInetUri ) );
       
   227 	__LEAVEIFOOM__
       
   228 	iTestWrapper.TESTE( err==KErrNone, err );
       
   229 	CleanupStack::PopAndDestroy (); // myInetUri
       
   230 	
       
   231 	// Open again and see favourite name is updated properly
       
   232 	myInetUri = iInetUriList.OpenInetUriL ( KTestUri2(), InetUriList::EWapPush );
       
   233 	CleanupClosePushL ( myInetUri );	
       
   234 	iTestWrapper.TEST ( myInetUri.FavouriteName().Compare ( KUriFavouriteName2() ) == 0 );
       
   235 	CleanupStack::PopAndDestroy (); // myInetUri
       
   236 
       
   237 	// Now we are having 1 URI in whitelist and 2 URI in blacklist
       
   238 	TInt count = iInetUriList.Count ( InetUriList::EWapPush, InetUriList::EWhiteList );
       
   239 	// 2 URI has been added
       
   240 	iTestWrapper.TEST( count == 1 );
       
   241 	count = iInetUriList.Count ( InetUriList::EWapPush, InetUriList::EBlackList );
       
   242 	// 2 URI has been added
       
   243 	iTestWrapper.TEST( count == 2 );
       
   244 		
       
   245 	}
       
   246 
       
   247 void CInetUriListStorageTests::GetListTypeL ()
       
   248 	{
       
   249 	__PRINTIFNOTOOM__
       
   250 	iTestWrapper.Next ( _L ( "Retrieve URI list type" ) );	
       
   251 	InetUriList::TListType listType;
       
   252 	TInt err = iInetUriList.GetListType ( KTestUri(), InetUriList::EWapPush, listType );
       
   253 	__LEAVEIFOOM__
       
   254 	iTestWrapper.TEST ( err == KErrNone );
       
   255 	iTestWrapper.TEST ( listType == InetUriList::EWhiteList );
       
   256 	
       
   257 	err = iInetUriList.GetListType ( KTestUri3(), InetUriList::EWapPush, listType );
       
   258 	__LEAVEIFOOM__
       
   259 	iTestWrapper.TEST ( err == KErrNone );
       
   260 	iTestWrapper.TEST ( listType == InetUriList::EBlackList );
       
   261 
       
   262 	err = iInetUriList.GetListType ( KUnknownUri(), InetUriList::EWapPush, listType );
       
   263 	__LEAVEIFOOM__
       
   264 	iTestWrapper.TEST ( err == InetUriList::KErrUriNotFound );
       
   265 	
       
   266 	// Open an invalid URI
       
   267 	RInetUri myInetUri;
       
   268 	TRAP ( err, myInetUri = iInetUriList.OpenInetUriL ( KUnknownUri(), EWapPush ) );
       
   269 	__LEAVEIFOOM__
       
   270 	iTestWrapper.TEST ( err == InetUriList::KErrUriNotFound );
       
   271 	}
       
   272 
       
   273 void CInetUriListStorageTests::SameUriDiffServiceTypeTestsL ()
       
   274 	{
       
   275 	RInetUri myInetUri = CreateNewUriL ( KTestUri4(), InetUriList::EWapPush, InetUriList::EWhiteList );
       
   276 	CleanupClosePushL ( myInetUri );
       
   277 	RInetUri myInetUri2 = CreateNewUriL ( KTestUri4(), InetUriList::EBrowser, InetUriList::EWhiteList );
       
   278 	CleanupClosePushL ( myInetUri2 );
       
   279 	
       
   280 	// Add the 2 URIs
       
   281 	TRAPD ( err, iInetUriList.AddL ( myInetUri ) );
       
   282 	__LEAVEIFOOM__
       
   283 	iTestWrapper.TEST ( err == KErrNone );
       
   284 	TRAP ( err, iInetUriList.AddL ( myInetUri2 ) );
       
   285 	__LEAVEIFOOM__
       
   286 	iTestWrapper.TEST ( err == KErrNone );
       
   287 	
       
   288 	CleanupStack::PopAndDestroy (2); // myInetUri, myInetUri2
       
   289 	
       
   290 	// Now open the URI
       
   291 	TRAP ( err, myInetUri = iInetUriList.OpenInetUriL ( KTestUri4(), InetUriList::EWapPush ) );
       
   292 	__LEAVEIFOOM__
       
   293 	iTestWrapper.TEST ( err == KErrNone );
       
   294 	CleanupClosePushL ( myInetUri );
       
   295 	// Remove the URI
       
   296 	TRAP ( err, iInetUriList.RemoveL ( myInetUri ) );
       
   297 	__LEAVEIFOOM__
       
   298 	iTestWrapper.TEST ( err == KErrNone );
       
   299 	CleanupStack::PopAndDestroy ( &myInetUri );
       
   300 	
       
   301 	TRAP ( err, myInetUri = iInetUriList.OpenInetUriL ( KTestUri4(), InetUriList::EWapPush ) );	
       
   302 	__LEAVEIFOOM__
       
   303 	iTestWrapper.TEST ( err == InetUriList::KErrUriNotFound );
       
   304 	
       
   305 	TRAP ( err, myInetUri = iInetUriList.OpenInetUriL ( KTestUri4(), InetUriList::EBrowser ) );	
       
   306 	__LEAVEIFOOM__
       
   307 	iTestWrapper.TEST ( err == KErrNone );
       
   308 	myInetUri.Close ();
       
   309 
       
   310 	// Now we are having 1 URI in Browser Service Type in whitelist
       
   311 	TInt count = iInetUriList.Count ( InetUriList::EBrowser, InetUriList::EWhiteList );
       
   312 	// 1 URI has been added
       
   313 	iTestWrapper.TEST( count == 1 );
       
   314 	
       
   315 	// Add few more URIs in Browser service type 1 in BL and 1 in WL
       
   316 	myInetUri = CreateNewUriL ( KTestUri5(), InetUriList::EBrowser, InetUriList::EBlackList );
       
   317 	CleanupClosePushL ( myInetUri );
       
   318 	myInetUri2 = CreateNewUriL ( KTestUri6(), InetUriList::EBrowser, InetUriList::EWhiteList );
       
   319 	CleanupClosePushL ( myInetUri2 );
       
   320 	myInetUri2.SetFavouriteNameL ( KUriFavouriteName3() );
       
   321 	
       
   322 	TRAP ( err, iInetUriList.AddL ( myInetUri ) );
       
   323 	__LEAVEIFOOM__
       
   324 	iTestWrapper.TEST ( err == KErrNone );
       
   325 	TRAP ( err, iInetUriList.AddL ( myInetUri2 ) );
       
   326 	__LEAVEIFOOM__
       
   327 	iTestWrapper.TEST ( err == KErrNone );
       
   328 	CleanupStack::PopAndDestroy ( 2 ); // myInetUri, myInetUri2			
       
   329 	}
       
   330 
       
   331 void CInetUriListStorageTests::AddFewMoreUrisL ()
       
   332 	{
       
   333 	RInetUri myInetUri = CreateNewUriL ( KTestUri7(), EBrowser, EWhiteList );
       
   334 	CleanupClosePushL ( myInetUri );
       
   335 	RInetUri myInetUri2 = CreateNewUriL ( KTestUri8(), EBrowser, EWhiteList );
       
   336 	CleanupClosePushL ( myInetUri2 );
       
   337 	RInetUri myInetUri3 = CreateNewUriL ( KTestUri9(), EBrowser, EBlackList );
       
   338 	CleanupClosePushL ( myInetUri3 );
       
   339 	RInetUri myInetUri4 = CreateNewUriL ( KTestUri10(), EBrowser, EBlackList );
       
   340 	CleanupClosePushL ( myInetUri4 );
       
   341 	RInetUri myInetUri5 = CreateNewUriL ( KTestUri11(), EBrowser, EBlackList );
       
   342 	CleanupClosePushL ( myInetUri5 );
       
   343 	
       
   344 	TRAPD ( err, iInetUriList.AddL ( myInetUri ) );
       
   345 	__LEAVEIFOOM__
       
   346 	iTestWrapper.TEST ( err == KErrNone );
       
   347 	TRAP ( err, iInetUriList.AddL ( myInetUri2 ) );
       
   348 	__LEAVEIFOOM__
       
   349 	iTestWrapper.TEST ( err == KErrNone );
       
   350 	TRAP ( err, iInetUriList.AddL ( myInetUri3 ) );
       
   351 	__LEAVEIFOOM__
       
   352 	iTestWrapper.TEST ( err == KErrNone );
       
   353 	TRAP ( err, iInetUriList.AddL ( myInetUri4 ) );
       
   354 	__LEAVEIFOOM__
       
   355 	iTestWrapper.TEST ( err == KErrNone );
       
   356 	TRAP ( err, iInetUriList.AddL ( myInetUri5 ) );
       
   357 	__LEAVEIFOOM__
       
   358 	iTestWrapper.TEST ( err == KErrNone );
       
   359 	
       
   360 	CleanupStack::PopAndDestroy (5); // myInetUri ... myInetUri4	
       
   361 	}
       
   362 
       
   363 
       
   364 
       
   365 // -------------------------
       
   366 
       
   367 CInetUriListQuery* CInetUriListQuery::NewLC ( CTestWrapper& aTest, TBool aNormalRun )
       
   368 	{
       
   369 	CInetUriListQuery* self = new (ELeave)CInetUriListQuery ( aTest, aNormalRun );
       
   370 	CleanupStack::PushL ( self );
       
   371 	self->ConstructL ();
       
   372 	return self;
       
   373 	}
       
   374 
       
   375 
       
   376 CInetUriListQuery::CInetUriListQuery ( CTestWrapper& aTest, TBool aNormalRun )
       
   377 : CInetUriListTestsBase ( aTest, aNormalRun )
       
   378 	{
       
   379 		
       
   380 	}
       
   381 
       
   382 
       
   383 CInetUriListQuery::~CInetUriListQuery ()
       
   384 	{
       
   385 	Cleanup ();
       
   386 	}
       
   387 
       
   388 void CInetUriListQuery::DoOperationL ()
       
   389 	{
       
   390 	TRAPD ( err, QueryListL() );
       
   391 	Cleanup ();
       
   392 	User::LeaveIfError ( err );
       
   393 	TRAPD ( tlderr, QueryTldListL());
       
   394 	User::LeaveIfError ( tlderr );
       
   395 	}
       
   396 
       
   397 void CInetUriListQuery::QueryListL ()
       
   398 	{	
       
   399 	__PRINTIFNOTOOM__
       
   400 	iTestWrapper.Next ( _L ( "Query URIs with ServiceType & ListType - Browser & Whitelist") );
       
   401 	// Generate the expected URIs for this query
       
   402 	AppendExpectedUriL ( KTestUri4(), EBrowser );
       
   403 	AppendExpectedUriL ( KTestUri6(), EBrowser );
       
   404 	AppendExpectedUriL ( KTestUri7(), EBrowser );
       
   405 	AppendExpectedUriL ( KTestUri8(), EBrowser );	
       
   406 	TQueryArgs args ( InetUriList::EBrowser, InetUriList::EWhiteList );	
       
   407 	DoQueryL ( args );
       
   408 	
       
   409 	__PRINTIFNOTOOM__
       
   410 	iTestWrapper.Next ( _L ( "Query URIs with ServiceType & ListType - Browser & Blacklist") );	
       
   411 	AppendExpectedUriL ( KTestUri5(), EBrowser );
       
   412 	AppendExpectedUriL ( KTestUri9(), EBrowser );
       
   413 	AppendExpectedUriL ( KTestUri10(), EBrowser );
       
   414 	AppendExpectedUriL ( KTestUri11(), EBrowser );			
       
   415 	TQueryArgs args2 ( InetUriList::EBrowser, InetUriList::EBlackList );	
       
   416 	DoQueryL ( args2 );
       
   417 
       
   418 	// Do query operation with exact path match and a list type
       
   419 	__PRINTIFNOTOOM__
       
   420 	iTestWrapper.Next ( _L ( "Query URIs with exact path match & ListType") );		
       
   421 	AppendExpectedUriL ( KTestUri6(), EBrowser );
       
   422 	const TPtrC8 uri ( KTestUri6() );
       
   423 	TQueryArgs args3 ( &uri, EBrowser, EWhiteList, EExactPath );
       
   424 	DoQueryL ( args3 );
       
   425 	
       
   426 	// Do query operation with partial suffix path match and a list type
       
   427 	__PRINTIFNOTOOM__
       
   428 	iTestWrapper.Next ( _L ( "Query URIs with partial suffix path match & ListType") );		
       
   429 	const TPtrC8 uri2 ( KPartialPathSuffixUri() );
       
   430 	AppendExpectedUriL ( KTestUri4(), EBrowser );
       
   431 	AppendExpectedUriL ( KTestUri6(), EBrowser );
       
   432 	TQueryArgs args4 ( &uri2, EBrowser, EWhiteList, EPartialSuffixPath );
       
   433 	DoQueryL ( args4 );
       
   434 	
       
   435 	// Do query operation with partial prefix path match and a list type
       
   436 	__PRINTIFNOTOOM__
       
   437 	iTestWrapper.Next ( _L ( "Query URIs with partial prefix path match & ListType") );	
       
   438 	AppendExpectedUriL ( KTestUri5(), EBrowser );
       
   439 	const TPtrC8 uri3 ( KPartialPathPrefixUri() );
       
   440 	TQueryArgs args5 ( &uri3, EBrowser, EBlackList, EPartialPrefixPath );
       
   441 	DoQueryL ( args5 );
       
   442 	
       
   443 	// Do query operation with partial suffix path match and without a list type
       
   444 	__PRINTIFNOTOOM__
       
   445 	iTestWrapper.Next ( _L ( "Query URIs with partial suffix path match & without ListType") );	
       
   446 	AppendExpectedUriL ( KTestUri4(), EBrowser );
       
   447 	AppendExpectedUriL ( KTestUri5(), EBrowser );	
       
   448 	AppendExpectedUriL ( KTestUri6(), EBrowser );	
       
   449 	const TPtrC8 uri4 ( KPartialPathSuffixUri() );
       
   450 	TQueryArgs args6 ( &uri4, EBrowser, EPartialSuffixPath );
       
   451 	DoQueryL ( args6 );
       
   452 	
       
   453 	// Do query operation with partial prefix path match and without a list type
       
   454 	__PRINTIFNOTOOM__
       
   455 	iTestWrapper.Next ( _L ( "Query URIs with partial prefix path match & without ListType") );		
       
   456 	AppendExpectedUriL ( KTestUri5(), EBrowser );
       
   457 	const TPtrC8 uri5 ( KPartialPathPrefixUri() );
       
   458 	TQueryArgs args7 ( &uri5, EBrowser, EPartialPrefixPath );
       
   459 	DoQueryL ( args7 );
       
   460 	
       
   461 	// Do a domain search with List type - 2 in whitelist & 3 in blacklist for mydomain.com
       
   462 	// Domain search with servicetype & listtype ( Browser & Whitelist )
       
   463 	__PRINTIFNOTOOM__
       
   464 	iTestWrapper.Next ( _L ( "Query URIs with domain match with ListType - WhiteList") );
       
   465 	const TPtrC8 uri6 ( KDomainSearchStr() );
       
   466 	AppendExpectedUriL ( KTestUri7(), EBrowser );
       
   467 	AppendExpectedUriL ( KTestUri8(), EBrowser );	
       
   468 	TQueryArgs args8 ( &uri6, EBrowser, EWhiteList, EDomain );
       
   469 	DoQueryL ( args8 );	
       
   470 
       
   471 	__PRINTIFNOTOOM__
       
   472 	iTestWrapper.Next ( _L ( "Query URIs with domain match with ListType - BlackList") );	
       
   473 	const TPtrC8 uri7 ( KDomainSearchStr() );	
       
   474 	AppendExpectedUriL ( KTestUri9(), EBrowser );
       
   475 	AppendExpectedUriL ( KTestUri10(), EBrowser );	
       
   476 	AppendExpectedUriL ( KTestUri11(), EBrowser );		
       
   477 	TQueryArgs args9 ( &uri7, EBrowser, EBlackList, EDomain );
       
   478 	DoQueryL ( args9 );	
       
   479 	
       
   480 	__PRINTIFNOTOOM__
       
   481 	iTestWrapper.Next ( _L ( "Query URIs with domain match with no ListType") );		
       
   482 	const TPtrC8 uri8 ( KDomainSearchStr() );		
       
   483 	AppendExpectedUriL ( KTestUri7(), EBrowser );
       
   484 	AppendExpectedUriL ( KTestUri8(), EBrowser );	
       
   485 	AppendExpectedUriL ( KTestUri9(), EBrowser );
       
   486 	AppendExpectedUriL ( KTestUri10(), EBrowser );	
       
   487 	AppendExpectedUriL ( KTestUri11(), EBrowser );		
       
   488 	TQueryArgs args10 ( &uri8, EBrowser, EDomain );
       
   489 	DoQueryL ( args10 );	
       
   490 	}
       
   491 
       
   492 void CInetUriListQuery::DoQueryL ( TQueryArgs aArgs )
       
   493 	{
       
   494 	iInetUriList.QueryUriL ( aArgs, this );
       
   495 	MatchQueryResults	();
       
   496 	Cleanup	();
       
   497 	}
       
   498 
       
   499 void CInetUriListQuery::QueryTldListL()
       
   500 	{
       
   501 	DoQueryPolicyL();
       
   502 	DoQueryListL();
       
   503 	}
       
   504 
       
   505 void CInetUriListQuery::DoQueryPolicyL()
       
   506 	{
       
   507 	__PRINTIFNOTOOM__
       
   508 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri, ListType and TldQueryType -- Fetch WhiteList data") );
       
   509 	const TPtrC8 tlduri1 ( KTldTestUri1() );
       
   510 	TPolicyQueryArgs queryArg1( &tlduri1, EWhiteList, EPolicyCharSet);
       
   511 	TQueryResults PolicyDataArg1;
       
   512 	DoQueryPolcydataL(queryArg1, PolicyDataArg1);
       
   513 	
       
   514 		__PRINTIFNOTOOM__
       
   515 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri, ListType and TldQueryType -- Fetch BlackList data") );
       
   516 	const TPtrC8 tlduri2 ( KTldTestUri2() );
       
   517 	TPolicyQueryArgs queryArg2( &tlduri2, EBlackList, EPolicyCharSet);
       
   518 	TQueryResults PolicyDataArg2;
       
   519 	DoQueryPolcydataL(queryArg2, PolicyDataArg2);
       
   520 	
       
   521 		__PRINTIFNOTOOM__
       
   522 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri, ListType and TldQueryType -- Fetch WhiteList data") );
       
   523 	const TPtrC8 tlduri3 ( KTldTestUri3() );
       
   524 	TPolicyQueryArgs queryArg3( &tlduri3, EWhiteList, EPolicyCharSet);
       
   525 	TQueryResults PolicyDataArg3;
       
   526 	DoQueryPolcydataL(queryArg3, PolicyDataArg3);
       
   527 	
       
   528 		__PRINTIFNOTOOM__
       
   529 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri, ListType and TldQueryType -- Fetch BlackList data") );
       
   530 	const TPtrC8 tlduri4 ( KTldTestUri4() );
       
   531 	TPolicyQueryArgs queryArg4( &tlduri4, EBlackList, EPolicyCharSet);
       
   532 	TQueryResults PolicyDataArg4;
       
   533 	DoQueryPolcydataL(queryArg4, PolicyDataArg4);
       
   534 	
       
   535 		__PRINTIFNOTOOM__
       
   536 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri, ListType and TldQueryType -- Fetch WhiteList data") );
       
   537 	const TPtrC8 tlduri5 ( KTldTestUri5() );
       
   538 	TPolicyQueryArgs queryArg5( &tlduri5, EWhiteList, EPolicyCharSet);
       
   539 	TQueryResults PolicyDataArg5;
       
   540 	DoQueryPolcydataL(queryArg5, PolicyDataArg5);
       
   541 	
       
   542 		__PRINTIFNOTOOM__
       
   543 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri, ListType and TldQueryType -- Fetch BlackList data") );
       
   544 	const TPtrC8 tlduri6 ( KTldTestUri6() );
       
   545 	TPolicyQueryArgs queryArg6( &tlduri6, EBlackList, EPolicyCharSet);
       
   546 	TQueryResults PolicyDataArg6;
       
   547 	DoQueryPolcydataL(queryArg6, PolicyDataArg6);
       
   548 	
       
   549 		__PRINTIFNOTOOM__
       
   550 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri, ListType and TldQueryType -- Fetch WhiteList data") );
       
   551 	const TPtrC8 tlduri7 ( KTldTestUri7() );
       
   552 	TPolicyQueryArgs queryArg7( &tlduri7, EWhiteList, EPolicyCharSet);
       
   553 	TQueryResults PolicyDataArg7;
       
   554 	DoQueryPolcydataL(queryArg7, PolicyDataArg7);
       
   555 	
       
   556 		__PRINTIFNOTOOM__
       
   557 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri, ListType and TldQueryType -- Fetch BlackList data") );
       
   558 	const TPtrC8 tlduri8 ( KTldTestUri7() );
       
   559 	TPolicyQueryArgs queryArg8( &tlduri8, EBlackList, EPolicyCharSet);
       
   560 	TQueryResults PolicyDataArg8;
       
   561 	DoQueryPolcydataL(queryArg8, PolicyDataArg8);
       
   562 	
       
   563 		__PRINTIFNOTOOM__
       
   564 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri, ListType and TldQueryType -- Fetch WhiteList data") );
       
   565 	const TPtrC8 tlduri9 ( KTldTestUri8() );
       
   566 	TPolicyQueryArgs queryArg9( &tlduri9, EWhiteList, EPolicyCharSet);
       
   567 	TQueryResults PolicyDataArg9;
       
   568 	DoQueryPolcydataL(queryArg9, PolicyDataArg9);
       
   569 	
       
   570 		__PRINTIFNOTOOM__
       
   571 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri, ListType and TldQueryType -- Fetch BlackList data") );
       
   572 	const TPtrC8 tlduri10 ( KTldTestUri8() );
       
   573 	TPolicyQueryArgs queryArg10( &tlduri10, EBlackList, EPolicyCharSet);
       
   574 	TQueryResults PolicyDataArg10;
       
   575 	DoQueryPolcydataL(queryArg10, PolicyDataArg10);
       
   576 
       
   577 	//Negative tests
       
   578 	
       
   579 		__PRINTIFNOTOOM__
       
   580 	iTestWrapper.Next ( _L ( "Query TLD URIs without Uri -- Negative test") );
       
   581 	TPolicyQueryArgs queryArg11( EBlackList, EPolicyCharSet);
       
   582 	TQueryResults PolicyDataArg11;
       
   583 	DoQueryPolcydataL(queryArg11, PolicyDataArg11);
       
   584 	
       
   585 	__PRINTIFNOTOOM__
       
   586 	iTestWrapper.Next ( _L ( "Query TLD URIs without List Type and TldQueryType -- Negative test") );
       
   587 	const TPtrC8 tlduri12 ( KTldTestUri8() );
       
   588 	TPolicyQueryArgs queryArg12( &tlduri12 );
       
   589 	TQueryResults PolicyDataArg12;
       
   590 	DoQueryPolcydataL(queryArg12, PolicyDataArg12);
       
   591 	
       
   592 	__PRINTIFNOTOOM__
       
   593 	iTestWrapper.Next ( _L ( "Query TLD URIs without URI & List Type  -- Negative test") );
       
   594 	TPolicyQueryArgs queryArg13( EPolicyCharSet );
       
   595 	TQueryResults PolicyDataArg13;
       
   596 	DoQueryPolcydataL(queryArg13, PolicyDataArg13);
       
   597 	
       
   598 		__PRINTIFNOTOOM__
       
   599 	iTestWrapper.Next ( _L ( "Query TLD URIs without URI & TldQueryType -- Negative test") );
       
   600 	TPolicyQueryArgs queryArg14( EBlackList );
       
   601 	TQueryResults PolicyDataArg14;
       
   602 	DoQueryPolcydataL(queryArg14, PolicyDataArg14);
       
   603 	
       
   604 	__PRINTIFNOTOOM__
       
   605 	iTestWrapper.Next ( _L ( "Query TLD URIs without TldQueryType -- Negative test") );
       
   606 	const TPtrC8 tlduri15 ( KTldTestUri8() );
       
   607 	TPolicyQueryArgs queryArg15( &tlduri15, EBlackList );
       
   608 	TQueryResults PolicyDataArg15;
       
   609 	DoQueryPolcydataL(queryArg15, PolicyDataArg15);
       
   610 	
       
   611 		__PRINTIFNOTOOM__
       
   612 	iTestWrapper.Next ( _L ( "Query TLD URIs without ListType -- Negative test") );
       
   613 	const TPtrC8 tlduri16 ( KTldTestUri8() );
       
   614 	TPolicyQueryArgs queryArg16( &tlduri16, EPolicyCharSet );
       
   615 	TQueryResults PolicyDataArg16;
       
   616 	DoQueryPolcydataL(queryArg16, PolicyDataArg16);
       
   617 	}
       
   618 
       
   619 void CInetUriListQuery::DoQueryListL()
       
   620 	{
       
   621 	__PRINTIFNOTOOM__
       
   622 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri and TldQueryType -- Gets White/Black list Host") );
       
   623 	const TPtrC8 tldlisturi1 ( KTldTestUri1() );
       
   624 	TPolicyQueryArgs query1( &tldlisturi1, EPolicyListType);
       
   625 	TQueryResults resultList1;
       
   626 	DoQueryTldListInfoL(query1, resultList1);
       
   627 
       
   628 	__PRINTIFNOTOOM__
       
   629 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri and TldQueryType -- Gets White/Black list Host") );
       
   630 	const TPtrC8 tldlisturi2 ( KTldTestUri2() );
       
   631 	TPolicyQueryArgs query2( &tldlisturi2, EPolicyListType);
       
   632 	TQueryResults resultList2;
       
   633 	DoQueryTldListInfoL(query2, resultList2);
       
   634 	
       
   635 		__PRINTIFNOTOOM__
       
   636 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri and TldQueryType -- Gets White/Black list Host") );
       
   637 	const TPtrC8 tldlisturi3 ( KTldTestUri3() );
       
   638 	TPolicyQueryArgs query3( &tldlisturi3, EPolicyListType);
       
   639 	TQueryResults resultList3;
       
   640 	DoQueryTldListInfoL(query3, resultList3);
       
   641 	
       
   642 		__PRINTIFNOTOOM__
       
   643 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri and TldQueryType -- Gets White/Black list Host") );
       
   644 	const TPtrC8 tldlisturi4 ( KTldTestUri4() );
       
   645 	TPolicyQueryArgs query4( &tldlisturi4, EPolicyListType);
       
   646 	TQueryResults resultList4;
       
   647 	DoQueryTldListInfoL(query4, resultList4);
       
   648 	
       
   649 		__PRINTIFNOTOOM__
       
   650 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri and TldQueryType -- Gets White/Black list Host") );
       
   651 	const TPtrC8 tldlisturi5 ( KTldTestUri5() );
       
   652 	TPolicyQueryArgs query5( &tldlisturi5, EPolicyListType);
       
   653 	TQueryResults resultList5;
       
   654 	DoQueryTldListInfoL(query5, resultList5);
       
   655 	
       
   656 		__PRINTIFNOTOOM__
       
   657 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri and TldQueryType -- Gets White/Black list Host") );
       
   658 	const TPtrC8 tldlisturi6 ( KTldTestUri6() );
       
   659 	TPolicyQueryArgs query6( &tldlisturi6, EPolicyListType);
       
   660 	TQueryResults resultList6;
       
   661 	DoQueryTldListInfoL(query6, resultList6);
       
   662 	
       
   663 		__PRINTIFNOTOOM__
       
   664 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri and TldQueryType -- Gets White/Black list Host") );
       
   665 	const TPtrC8 tldlisturi7 ( KTldTestUri7() );
       
   666 	TPolicyQueryArgs query7( &tldlisturi7, EPolicyListType);
       
   667 	TQueryResults resultList7;
       
   668 	DoQueryTldListInfoL(query7, resultList7);
       
   669 	
       
   670 		__PRINTIFNOTOOM__
       
   671 	iTestWrapper.Next ( _L ( "Query TLD URIs with Uri and TldQueryType -- Gets White/Black list Host") );
       
   672 	const TPtrC8 tldlisturi8 ( KTldTestUri8() );
       
   673 	TPolicyQueryArgs query8( &tldlisturi8, EPolicyListType);
       
   674 	TQueryResults resultList8;
       
   675 	DoQueryTldListInfoL(query8, resultList8);
       
   676 	}
       
   677 
       
   678 /**
       
   679 Tests Fetching Policy data for given Uri
       
   680 */
       
   681 void CInetUriListQuery::DoQueryPolcydataL ( TPolicyQueryArgs aArgs, TQueryResults aResults )
       
   682 	{
       
   683 	TInt error(KErrNone);
       
   684 	TRAP( error, iInetUriList.QueryTldInfoL ( aArgs, aResults ) );
       
   685 	if(error == KErrNone )
       
   686 		{
       
   687 		HBufC8* policyData = aResults.CharsetL();
       
   688 		delete policyData;	
       
   689 		}
       
   690 	iTestWrapper.TEST (ETrue);
       
   691 	}
       
   692 
       
   693 /**
       
   694 Tests Fetching List type of given Uri
       
   695 */
       
   696 void CInetUriListQuery::DoQueryTldListInfoL ( TPolicyQueryArgs aArgs, TQueryResults aResults )
       
   697 	{
       
   698 	TInt error(KErrNone);
       
   699 	TRAP( error, iInetUriList.QueryTldInfoL ( aArgs, aResults ) );
       
   700 		if(error == KErrNone )
       
   701 		{
       
   702 		InetUriList::TListType listType = aResults.ListType();
       
   703 		}
       
   704 	iTestWrapper.TEST (ETrue);
       
   705 	}
       
   706 
       
   707 TBool CInetUriListQuery::OnQueryResultsL ( RInetUri aUri )
       
   708 	{
       
   709 	TInt count = iResults.Count ();
       
   710 	CleanupClosePushL ( aUri );
       
   711 	iResults.AppendL ( aUri );
       
   712 	CleanupStack::Pop (); // aUri
       
   713 	return ETrue;
       
   714 	}
       
   715 
       
   716 void CInetUriListQuery::MatchQueryResults ()
       
   717 	{
       
   718 	iTestWrapper.TEST ( iExpectedResults.Count() == iResults.Count() );
       
   719 	}
       
   720 
       
   721 void CInetUriListQuery::Cleanup ()
       
   722 	{
       
   723 	ClearArray ( iResults );
       
   724 	ClearArray ( iExpectedResults );		
       
   725 	}
       
   726 
       
   727 void CInetUriListQuery::ClearArray ( QueryResultsArray& aUriArray )
       
   728 	{
       
   729 	TInt count = aUriArray.Count ();
       
   730 	while ( count > 0 )
       
   731 		{
       
   732 		aUriArray[--count].Close ();			
       
   733 		aUriArray.Remove (count);
       
   734 		}
       
   735 	aUriArray.Reset ();	
       
   736 	TInt count2 = aUriArray.Count ();
       
   737 	}
       
   738 
       
   739 void CInetUriListQuery::AppendExpectedUriL ( const TDesC8& aUri, TServiceType aServiceType )
       
   740 	{
       
   741 	RInetUri myInetUri = iInetUriList.OpenInetUriL ( aUri, aServiceType );
       
   742 	CleanupClosePushL ( myInetUri );
       
   743 	iExpectedResults.AppendL ( myInetUri );
       
   744 	CleanupStack::Pop ();
       
   745 	}
       
   746 
       
   747 void CInetUriListQuery::DoCleanupL ()
       
   748 	{
       
   749 	Cleanup ();		
       
   750 	}
       
   751 
       
   752 // -----------------------------------------------------
       
   753 
       
   754 CInetUriListCleanup* CInetUriListCleanup::NewL ( CTestWrapper& aTest )
       
   755 	{
       
   756 	CInetUriListCleanup* self = new ( ELeave )CInetUriListCleanup ( aTest );
       
   757 	CleanupStack::PushL ( self );
       
   758 	self->ConstructL ();
       
   759 	CleanupStack::Pop ();
       
   760 	return self;
       
   761 	}
       
   762 
       
   763 CInetUriListCleanup::~CInetUriListCleanup ()
       
   764 	{
       
   765 		
       
   766 	}
       
   767 
       
   768 CInetUriListCleanup::CInetUriListCleanup ( CTestWrapper& aTest )
       
   769 : CInetUriListTestsBase ( aTest, ETrue )
       
   770 	{
       
   771 		
       
   772 	}
       
   773 
       
   774 TBool CInetUriListCleanup::OnQueryResultsL ( RInetUri aUri )
       
   775 	{
       
   776 	CleanupClosePushL ( aUri );
       
   777 	iInetUriList.RemoveL ( aUri );
       
   778 	CleanupStack::PopAndDestroy (); // aUri
       
   779 	return ETrue;
       
   780 	}
       
   781 
       
   782 void CInetUriListCleanup::DoOperationL ()
       
   783 	{
       
   784 	TQueryArgs args ( EBrowser );
       
   785 	iInetUriList.QueryUriL ( args, this );
       
   786 	TQueryArgs args2 ( EWapPush );	
       
   787 	iInetUriList.QueryUriL ( args2, this );	
       
   788 	}
       
   789 
       
   790 void CInetUriListCleanup::DoCleanupL ()
       
   791 	{
       
   792 	// Do nothing
       
   793 	}
       
   794 
       
   795 // -----------------------------------------------------