1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericservices/httputils/Test/t_uriparser/CUriAndAuthorityTest.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,221 @@
1.4 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __CURIANDAUTHORITYTEST_H__
1.20 +#define __CURIANDAUTHORITYTEST_H__
1.21 +
1.22 +// System includes
1.23 +//
1.24 +#include <e32base.h>
1.25 +
1.26 +// Local includes
1.27 +//
1.28 +#include "IpuTestUtils.h"
1.29 +#include <uri8.h>
1.30 +#include <uri16.h>
1.31 +#include <authority8.h>
1.32 +#include <authority16.h>
1.33 +#include <delimitedpath8.h>
1.34 +#include <delimitedpath16.h>
1.35 +#include "ctestbase.h"
1.36 +
1.37 +enum TUriMatchAndPresenceFlags
1.38 + {
1.39 + ESchemeFlag = 0x01,
1.40 + EUserinfoFlag = 0x02,
1.41 + EHostFlag = 0x04,
1.42 + EPortFlag = 0x08,
1.43 + EPathFlag = 0x10,
1.44 + EQueryFlag = 0x20,
1.45 + EFragmentFlag = 0x40
1.46 + };
1.47 +
1.48 +// CUriAndAuthorityTest - test class for the Uri and Authority family of classes
1.49 +//
1.50 +class CUriAndAuthorityTest : public CTestBase
1.51 + {
1.52 +public:
1.53 +
1.54 + // Static factory c'tor. Leaves pointer to created object on the cleanup stack.
1.55 + //
1.56 + // Rtn: pointer to newly created object - ownership transfered to caller.
1.57 + //
1.58 + static CUriAndAuthorityTest* NewLC(CIpuTestHarness* aTestHarness);
1.59 +
1.60 + // Static factory c'tor.
1.61 + //
1.62 + // Rtn: pointer to newly created object - ownership transfered to caller.
1.63 + //
1.64 + static CUriAndAuthorityTest* NewL(CIpuTestHarness* aTestHarness);
1.65 +
1.66 + // D'tor
1.67 + //
1.68 + ~CUriAndAuthorityTest();
1.69 +
1.70 + // Runs the defined tests.
1.71 + //
1.72 + void DoTestsL();
1.73 +
1.74 +//
1.75 +//
1.76 +// Uri Tests
1.77 +//
1.78 +//
1.79 +
1.80 + // Tests the parsing of TUriParser components
1.81 + //
1.82 + // In:
1.83 + // aUri - the uri to be parsed
1.84 + // aScheme - what the scheme should be
1.85 + // aUserInfo - what the userinfo should be
1.86 + // aHost - what the host should be
1.87 + // aPort - what the port should be
1.88 + // aPath - what the path should be
1.89 + // aQuery - what the query should be
1.90 + // aFragment - what the fragment should be
1.91 + //
1.92 + void TestUriComponentExtractionL(const TDesC16& aUri, const TDesC16& aScheme,
1.93 + const TDesC16& aUserinfo, const TDesC16& aHost,
1.94 + const TDesC16& aPort, const TDesC16& aPath,
1.95 + const TDesC16& aQuery, const TDesC16& aFragment) const;
1.96 +
1.97 +
1.98 + void TestUriRemoveComponentL(const TDesC& aUri_NoScheme, const TDesC& aUri_NoHost, const TDesC& aUri_NoUserinfo,
1.99 + const TDesC& aUri_NoPort, const TDesC& aUri_NoPath, const TDesC& aUri_NoQuery,
1.100 + const TDesC& aUri_NoFragment, const TDesC& aUri_Whole) const;
1.101 +
1.102 + void TestUriSetComponentL(const TDesC& aUri_Scheme, const TDesC& aUri_Host, const TDesC& aUri_Userinfo,
1.103 + const TDesC& aUri_Port, const TDesC& aUri_Path, const TDesC& aUri_Query,
1.104 + const TDesC& aUri_Fragment, const TDesC& aScheme, const TDesC& aHost,
1.105 + const TDesC& aUserinfo, const TDesC& aPort, const TDesC& aPath,
1.106 + const TDesC& aQuery, const TDesC& aFragment) const;
1.107 +private: // Methods
1.108 +
1.109 + // Default c'tor.
1.110 + //
1.111 + CUriAndAuthorityTest(CIpuTestHarness* aTestHarness);
1.112 +
1.113 + // Non-trivial c'tor. Second part of 2-phase construction - does all allocation.
1.114 + //
1.115 + void ConstructL();
1.116 +
1.117 + // Tests uri resolving.
1.118 + //
1.119 + // In:
1.120 + // aBase - base uri
1.121 + // aRelative - referene uri to be resolved
1.122 + // aExpected - expected result
1.123 + //
1.124 + void TestResolveL(const TDesC& aBase, const TDesC& aReference, const TDesC& aExpected) const;
1.125 +
1.126 + // Tests comparison of 2 uri's
1.127 + //
1.128 + // In:
1.129 + // aUri1 - a uri
1.130 + // aUri2 - a uri
1.131 + // aMatchFlags - set of flags specifying which components match
1.132 + //
1.133 + void TestUriCompareL(const TDesC& aUri1, const TDesC& aUri2, TInt aMatchFlags) const;
1.134 +
1.135 + // Tests the presence of components in a uri
1.136 + //
1.137 + // In:
1.138 + // aUri - the uri to test
1.139 + // aPresenceFlags - set of flags specifying which components are present
1.140 + //
1.141 + void TestUriComponentPresenceL(const TDesC& aUri, TInt aPresenceFlags) const;
1.142 +
1.143 + // Tests the UriDes() function
1.144 + //
1.145 + // In:
1.146 + // aUri - the uri
1.147 + //
1.148 + void TestUriDesL(const TDesC& aUri) const;
1.149 +
1.150 + // Tests scheme validation
1.151 + //
1.152 + // In:
1.153 + // aUri - the uri
1.154 + // aValidScheme - boolean value stating whether scheme is valid or not
1.155 + //
1.156 + void TestUriSchemeValidiyL(const TDesC& aUri, TBool aValidScheme) const;
1.157 +
1.158 + // Tests retrieving the fragmentless uri
1.159 + //
1.160 + // In:
1.161 + // aUri - the uri
1.162 + // aExpected - the expeced fragmentless uri
1.163 + //
1.164 + void TestUriWithoutFragmentL(const TDesC& aUri, const TDesC& aExpected);
1.165 +
1.166 +//
1.167 +//
1.168 +// Authority Tests
1.169 +//
1.170 +//
1.171 +
1.172 + // Tests the parsing of TAuthorityParser components
1.173 + //
1.174 + // In:
1.175 + // aAuthority - the authority to be parsed
1.176 + // aHost - what the host should be
1.177 + // aUserInfo - what the userinfo should be
1.178 + // aPort - what the port should be
1.179 + //
1.180 + void TestAuthorityComponentExtractionL(const TDesC16& aAuthority, const TDesC16& aHost,
1.181 + const TDesC16& aUserinfo, const TDesC16& aPort) const;
1.182 +
1.183 + // Tests comparison of 2 authorities
1.184 + //
1.185 + // In:
1.186 + // aAuthority1 - an authority
1.187 + // aAuthority2 - an authority
1.188 + // aMatchFlags - set of flags specifying which components match
1.189 + //
1.190 + void TestAuthorityCompareL(const TDesC& aAuthority1, const TDesC& aAuthority2, TInt aMatchFlags) const;
1.191 +
1.192 + // Tests the presence of components in an authority
1.193 + //
1.194 + // In:
1.195 + // aAuthority - the authority to test
1.196 + // aPresenceFlags - set of flags specifying which components are present
1.197 + //
1.198 + void TestAuthorityComponentPresenceL(const TDesC& aAuthority, TInt aPresenceFlags) const;
1.199 +
1.200 + // Tests the AuthorityDes() function
1.201 + //
1.202 + // In:
1.203 + // aAuthority - the authority
1.204 + //
1.205 + void TestAuthorityDesL(const TDesC& aAuthority);
1.206 +
1.207 + void TestAuthoritySetComponentL(const TDesC& aAuthority_Host, const TDesC& aAuthority_Userinfo, const TDesC& aAuthority_Port,
1.208 + const TDesC& aHost, const TDesC& aUserinfo, const TDesC& aPort);
1.209 +
1.210 + void TestAuthoritySetAndEscapeComponentL(const TDesC& aAuthority_Host, const TDesC& aAuthority_Userinfo, const TDesC& aAuthority_Port,
1.211 + const TDesC& aHost, const TDesC& aUserinfo, const TDesC& aPort) const;
1.212 +
1.213 + void TestAuthorityRemoveComponentL(const TDesC& aAuthority_NoHost, const TDesC& aAuthority_NoUserinfo,
1.214 + const TDesC& aAuthority_NoPort, const TDesC& aAuthority_Whole) const;
1.215 +
1.216 +private: // Attributes
1.217 +
1.218 + // Test harness
1.219 + //
1.220 + CIpuTestHarness* iTestHarness;
1.221 +
1.222 + };
1.223 +
1.224 +#endif // __CURIANDAUTHORITYTEST_H__