applayerpluginsandutils/uripermissionservices/Test/tineturilisttests.h
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2006-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 // tbmtests.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <ineturilistdef.h>
       
    19 #include <ineturilist.h>
       
    20 class CTestWrapper;
       
    21 
       
    22 using namespace InetUriList;
       
    23 
       
    24 // ------------Test URIs
       
    25 _LIT8 (KTestUri, "http://www.google.com/index.html" );
       
    26 _LIT8 (KTestUri2, "http://www.yahoo.com/ab/cd/bc/index.html" );
       
    27 _LIT8 (KTestUri3, "http://www.google.com/cd/tf/mypage.html" );
       
    28 
       
    29 _LIT8 (KTestUri4, "http://www.mynewdomain.com/cd/tf/mypage.html" );
       
    30 _LIT8 (KTestUri5, "http://www.mynewdomain.com/ab/tf/mypage.html" );
       
    31 _LIT8 (KTestUri6, "http://www.mynewdomain.com/ef/tf/mypage.html" );
       
    32 
       
    33 _LIT8 ( KTestUri7, "http://www.mydomain.com/index.html" );
       
    34 _LIT8 ( KTestUri8, "http://pws.mydomain.com/index.html" );
       
    35 _LIT8 ( KTestUri9, "http://mail.mydomain.com/index.html" );
       
    36 _LIT8 ( KTestUri10, "http://messenger.mydomain.com/index.html" );
       
    37 _LIT8 ( KTestUri11, "http://webdav.mydomain.com/index.html" );
       
    38 
       
    39 _LIT8 ( KUriFavouriteName, "Google website" );
       
    40 _LIT8 ( KUriFavouriteName2, "Yahoo website" );
       
    41 _LIT8 ( KUriFavouriteName3, "My new domain" );
       
    42 
       
    43 _LIT8 ( KUnknownUri, "http://myinvaliddomain.com/mypage.html" );
       
    44 _LIT8 ( KPartialPathSuffixUri, "http://www.mynewdomain.com/mypage.html" );
       
    45 _LIT8 ( KPartialPathPrefixUri, "http://www.mynewdomain.com/ab" );
       
    46 _LIT8 ( KDomainSearchStr, "http://www.mydomain.com" );
       
    47 
       
    48 //Test Uris For QueryTld functionality
       
    49 _LIT8 ( KTldTestUri1, "http://www.yahoo.test/index.html" );	//Whitelisted in TLD 'test'
       
    50 _LIT8 ( KTldTestUri2, "http://www.yaqQzz.test/index.html" );//Blacklisted in TLD 'test'
       
    51 _LIT8 ( KTldTestUri3, "http://www.yahoo.twt/index.html" );	//Whitelisted in TLD 'twt'
       
    52 _LIT8 ( KTldTestUri4, "http://www.yaqQzz.twt/index.html" );	//No Blacklist data for TLD 'twt'
       
    53 _LIT8 ( KTldTestUri5, "http://www.yahoo.tbl/index.html" );	//Whitelisted in TLD 'tbl', No Whitelist data for TLD 'tbl' 
       
    54 _LIT8 ( KTldTestUri6, "http://www.yaqQzz.tbl/index.html" );	//Blacklisted in TLD 'tbl', No Whitelist data for TLD 'tbl' 		
       
    55 _LIT8 ( KTldTestUri7, "http://www.yahoo.tza/index.html" );	//TLD does not exist
       
    56 _LIT8 ( KTldTestUri8, "http://www.yahoo.tzz/index.html" );	//TLD does not exist
       
    57 
       
    58 
       
    59 _LIT ( KUriListInitFileSrcPath, "z:\\ineturilist\\config\\ineturilist.xml" );
       
    60 _LIT ( KUriListInitFileDestPath, "c:\\private\\20009d70\\ineturilist.xml" );
       
    61 // -------------------------
       
    62 
       
    63 class CInetUriListTestsBase : public CBase
       
    64 	{
       
    65 	public:	
       
    66 	virtual ~CInetUriListTestsBase ();
       
    67 	
       
    68 	void RunTestsL ();
       
    69 //	
       
    70 	protected:	
       
    71 	CInetUriListTestsBase ( CTestWrapper& aTestWrapper, TBool aNormalRun );
       
    72 	void ConstructL ();
       
    73 	
       
    74 	RInetUri CreateNewUriL ( const TDesC8& aUri, TServiceType aServiceType, TListType aListType );
       
    75 	
       
    76 	private:
       
    77 	virtual void DoOperationL () = 0;
       
    78 	virtual void DoCleanupL () = 0;	
       
    79 	protected:	
       
    80 	RInetUriList 	iInetUriList;
       
    81 	CTestWrapper& 	iTestWrapper;
       
    82 	TBool		  	iNormalRun;
       
    83 	};
       
    84 
       
    85 
       
    86 class CInetUriListStorageTests : public CInetUriListTestsBase 
       
    87 	{
       
    88 	public:
       
    89 	static CInetUriListStorageTests* NewL ( CTestWrapper& aTestWrapper, TBool aNormalRun = ETrue );
       
    90 	~CInetUriListStorageTests ();
       
    91 		
       
    92 	private:
       
    93 	void DoOperationL ();
       
    94 	void DoCleanupL ();
       
    95 	
       
    96 	CInetUriListStorageTests ( CTestWrapper& aTestWrapper, TBool aNormalRun );
       
    97 
       
    98 	void AddTestsL ();
       
    99 	void RemoveTestsL ();
       
   100 	void UpdateTestsL ();
       
   101 	void GetListTypeL ();
       
   102 	void SameUriDiffServiceTypeTestsL ();
       
   103 	void AddFewMoreUrisL ();
       
   104 	};
       
   105 
       
   106 typedef RArray <RInetUri> QueryResultsArray;
       
   107 
       
   108 class CInetUriListQuery : public CInetUriListTestsBase,
       
   109 						 public MQueryResultsCallback
       
   110 	{
       
   111 	public:
       
   112 	static CInetUriListQuery* NewLC ( CTestWrapper& aTest, TBool aNormalRun = ETrue );
       
   113 	virtual ~CInetUriListQuery ();
       
   114 
       
   115 	TBool OnQueryResultsL ( RInetUri aUri );
       
   116 		
       
   117 	protected:
       
   118 	CInetUriListQuery ( CTestWrapper& aTest, TBool aNormalRun );	
       
   119 	CInetUriListQuery ( CTestWrapper& aTest, QueryResultsArray aResults );		
       
   120 	
       
   121 	private:
       
   122 	void DoQueryL ( TQueryArgs aArgs );
       
   123 	void DoQueryPolicyL();
       
   124 	void DoQueryListL();		
       
   125 	void DoQueryPolcydataL ( TPolicyQueryArgs aArgs, TQueryResults aResults );
       
   126 	void DoQueryTldListInfoL ( TPolicyQueryArgs aArgs, TQueryResults aResults );
       
   127 	
       
   128 	void Cleanup ();
       
   129 	void ClearArray ( QueryResultsArray& aUriArray );
       
   130 
       
   131 	void AppendExpectedUriL ( const TDesC8& aUri, TServiceType aServiceType );
       
   132 	void MatchQueryResults ();
       
   133 	
       
   134 	void DoOperationL ();	
       
   135 	void QueryListL ();	
       
   136 	void DoCleanupL ();	
       
   137 	void QueryTldListL();
       
   138 		
       
   139 	private:
       
   140 	QueryResultsArray iResults;
       
   141 	QueryResultsArray iExpectedResults;
       
   142 	};
       
   143 
       
   144 
       
   145 class CInetUriListCleanup : public CInetUriListTestsBase,
       
   146 						 	public MQueryResultsCallback
       
   147 	{
       
   148 	public:
       
   149 	static CInetUriListCleanup* NewL ( CTestWrapper& aTest );
       
   150 	~CInetUriListCleanup ();
       
   151 	
       
   152 	void DoOperationL ();
       
   153 	void DoCleanupL ();	
       
   154 	TBool OnQueryResultsL ( RInetUri aUri );
       
   155 	
       
   156 	private:
       
   157 	CInetUriListCleanup ( CTestWrapper& aTest );
       
   158 	};
       
   159