os/ossrv/genericservices/httputils/Test/t_uriparser/CUriAndAuthorityTest.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 //
    15 
    16 #ifndef __CURIANDAUTHORITYTEST_H__
    17 #define __CURIANDAUTHORITYTEST_H__
    18 
    19 // System includes
    20 //
    21 #include <e32base.h>
    22 
    23 // Local includes
    24 //
    25 #include "IpuTestUtils.h"
    26 #include <uri8.h>
    27 #include <uri16.h>
    28 #include <authority8.h>
    29 #include <authority16.h>
    30 #include <delimitedpath8.h>
    31 #include <delimitedpath16.h>
    32 #include "ctestbase.h"
    33 
    34 enum TUriMatchAndPresenceFlags
    35 	{
    36 	ESchemeFlag			= 0x01,
    37 	EUserinfoFlag		= 0x02,
    38 	EHostFlag			= 0x04,
    39 	EPortFlag			= 0x08,
    40 	EPathFlag			= 0x10,
    41 	EQueryFlag			= 0x20,
    42 	EFragmentFlag		= 0x40
    43 	};
    44 
    45 // CUriAndAuthorityTest - test class for the Uri and Authority family of classes
    46 //
    47 class CUriAndAuthorityTest : public CTestBase
    48 	{
    49 public:
    50 
    51 	// Static factory c'tor. Leaves pointer to created object on the cleanup stack.
    52 	//
    53 	// Rtn: pointer to newly created object - ownership transfered to caller.
    54 	//
    55 	static CUriAndAuthorityTest* NewLC(CIpuTestHarness* aTestHarness);
    56 
    57 	// Static factory c'tor.
    58 	//
    59 	// Rtn: pointer to newly created object - ownership transfered to caller.
    60 	//
    61 	static CUriAndAuthorityTest* NewL(CIpuTestHarness* aTestHarness);
    62 
    63 	// D'tor
    64 	//
    65 	~CUriAndAuthorityTest();
    66 
    67 	// Runs the defined tests.
    68 	//
    69 	void DoTestsL();
    70 
    71 //
    72 //
    73 //	Uri Tests
    74 //
    75 //
    76 
    77 	// Tests the parsing of TUriParser components
    78 	//
    79 	// In:
    80 	// aUri			- the uri to be parsed
    81 	// aScheme		- what the scheme should be
    82 	// aUserInfo	- what the userinfo should be
    83 	// aHost		- what the host should be
    84 	// aPort		- what the port should be
    85 	// aPath		- what the path should be
    86 	// aQuery		- what the query should be
    87 	// aFragment	- what the fragment should be
    88 	//
    89 	void TestUriComponentExtractionL(const TDesC16& aUri, const TDesC16& aScheme,
    90 									   const TDesC16& aUserinfo, const TDesC16& aHost, 
    91 									   const TDesC16& aPort, const TDesC16& aPath, 
    92 									   const TDesC16& aQuery, const TDesC16& aFragment) const;
    93 
    94 
    95 	void TestUriRemoveComponentL(const TDesC& aUri_NoScheme, const TDesC& aUri_NoHost, const TDesC& aUri_NoUserinfo, 
    96 								const TDesC& aUri_NoPort, const TDesC& aUri_NoPath, const TDesC& aUri_NoQuery, 
    97 								const TDesC& aUri_NoFragment, const TDesC& aUri_Whole) const;
    98 
    99 	void TestUriSetComponentL(const TDesC& aUri_Scheme, const TDesC& aUri_Host, const TDesC& aUri_Userinfo, 
   100 							const TDesC& aUri_Port, const TDesC& aUri_Path, const TDesC& aUri_Query, 
   101 							const TDesC& aUri_Fragment, const TDesC& aScheme, const TDesC& aHost, 
   102 							const TDesC& aUserinfo, const TDesC& aPort, const TDesC& aPath, 
   103 							const TDesC& aQuery, const TDesC& aFragment) const;
   104 private:	// Methods
   105 
   106 	// Default c'tor.
   107 	//
   108 	CUriAndAuthorityTest(CIpuTestHarness* aTestHarness);
   109 
   110 	// Non-trivial c'tor. Second part of 2-phase construction - does all allocation.
   111 	//
   112 	void ConstructL();
   113 
   114 	// Tests uri resolving.
   115 	//
   116 	// In:
   117 	// aBase		- base uri
   118 	// aRelative	- referene uri to be resolved
   119 	// aExpected	- expected result
   120 	//
   121 	void TestResolveL(const TDesC& aBase, const TDesC& aReference, const TDesC& aExpected) const;
   122 
   123 	// Tests comparison of 2 uri's
   124 	//
   125 	// In:
   126 	// aUri1		- a uri
   127 	// aUri2		- a uri
   128 	// aMatchFlags	- set of flags specifying which components match
   129 	//
   130 	void TestUriCompareL(const TDesC& aUri1, const TDesC& aUri2, TInt aMatchFlags) const;
   131 
   132 	// Tests the presence of components in a uri
   133 	//
   134 	// In:
   135 	// aUri				- the uri to test
   136 	// aPresenceFlags	- set of flags specifying which components are present
   137 	//
   138 	void TestUriComponentPresenceL(const TDesC& aUri, TInt aPresenceFlags) const;
   139 
   140 	// Tests the UriDes() function
   141 	//
   142 	// In:
   143 	// aUri	- the uri
   144 	//
   145 	void TestUriDesL(const TDesC& aUri) const;
   146 
   147 	// Tests scheme validation
   148 	//
   149 	// In:
   150 	// aUri			- the uri
   151 	// aValidScheme	- boolean value stating whether scheme is valid or not
   152 	//
   153 	void TestUriSchemeValidiyL(const TDesC& aUri, TBool aValidScheme) const;
   154 
   155 	// Tests retrieving the fragmentless uri
   156 	//
   157 	// In:
   158 	// aUri			- the uri
   159 	// aExpected	- the expeced fragmentless uri
   160 	//
   161 	void TestUriWithoutFragmentL(const TDesC& aUri, const TDesC& aExpected);
   162 
   163 //
   164 //
   165 //	Authority Tests
   166 //
   167 //
   168 	
   169 	// Tests the parsing of TAuthorityParser components
   170 	//
   171 	// In:
   172 	// aAuthority	- the authority to be parsed
   173 	// aHost		- what the host should be
   174 	// aUserInfo	- what the userinfo should be
   175 	// aPort		- what the port should be
   176 	//
   177 	void TestAuthorityComponentExtractionL(const TDesC16& aAuthority, const TDesC16& aHost, 
   178 										   const TDesC16& aUserinfo, const TDesC16& aPort) const;
   179 
   180 	// Tests comparison of 2 authorities
   181 	//
   182 	// In:
   183 	// aAuthority1	- an authority
   184 	// aAuthority2	- an authority
   185 	// aMatchFlags	- set of flags specifying which components match
   186 	//
   187 	void TestAuthorityCompareL(const TDesC& aAuthority1, const TDesC& aAuthority2, TInt aMatchFlags) const;
   188 					
   189 	// Tests the presence of components in an authority
   190 	//
   191 	// In:
   192 	// aAuthority		- the authority to test
   193 	// aPresenceFlags	- set of flags specifying which components are present
   194 	//
   195 	void TestAuthorityComponentPresenceL(const TDesC& aAuthority, TInt aPresenceFlags) const;
   196 
   197 	// Tests the AuthorityDes() function
   198 	//
   199 	// In:
   200 	// aAuthority	- the authority
   201 	//
   202 	void TestAuthorityDesL(const TDesC& aAuthority);
   203 
   204 	void TestAuthoritySetComponentL(const TDesC& aAuthority_Host, const TDesC& aAuthority_Userinfo, const TDesC& aAuthority_Port, 
   205 									const TDesC& aHost, const TDesC& aUserinfo, const TDesC& aPort);
   206 
   207 	void TestAuthoritySetAndEscapeComponentL(const TDesC& aAuthority_Host, const TDesC& aAuthority_Userinfo, const TDesC& aAuthority_Port, 
   208 											const TDesC& aHost, const TDesC& aUserinfo, const TDesC& aPort) const;
   209 
   210 	void TestAuthorityRemoveComponentL(const TDesC& aAuthority_NoHost, const TDesC& aAuthority_NoUserinfo, 
   211 									   const TDesC& aAuthority_NoPort, const TDesC& aAuthority_Whole) const;
   212 
   213 private:	// Attributes
   214 
   215 	// Test harness
   216 	//
   217 	CIpuTestHarness*	iTestHarness;
   218 
   219 	};
   220 
   221 #endif	// __CURIANDAUTHORITYTEST_H__