1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/syslibsapitest/syslibssvs/ecom/src/T_EComResolverParamsData.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,270 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +#include "T_EComResolverParamsData.h"
1.24 +
1.25 +
1.26 +/*@{*/
1.27 +/// Parameters
1.28 +_LIT(KExpectedString, "expected_string");
1.29 +_LIT(KExpectedBool, "expected_bool");
1.30 +_LIT(KDataType, "data_type");
1.31 +_LIT(KGenericMatch, "generic_match");
1.32 +_LIT(KWildcardMatch, "wildcard_match");
1.33 +
1.34 +/// TEcomResolverParams
1.35 +_LIT(KCmdDataType, "DataType");
1.36 +_LIT(KCmdSetDataType, "SetDataType");
1.37 +_LIT(KCmdSetGenericMatch, "SetGenericMatch");
1.38 +_LIT(KCmdIsGenericMatch, "IsGenericMatch");
1.39 +_LIT(KCmdSetWildcardMatch, "SetWildcardMatch");
1.40 +_LIT(KCmdIsWildcardMatch, "IsWildcardMatch");
1.41 +
1.42 +_LIT( KEmptyString, "");
1.43 +/*@}*/
1.44 +
1.45 +//////////////////////////////////////////////////////////////////////
1.46 +// Construction/Destruction
1.47 +//////////////////////////////////////////////////////////////////////
1.48 +
1.49 +/**
1.50 + * Two phase constructor
1.51 + */
1.52 +CT_EComResolverParamsData* CT_EComResolverParamsData::NewL()
1.53 + {
1.54 + CT_EComResolverParamsData* ret=new (ELeave) CT_EComResolverParamsData();
1.55 + CleanupStack::PushL(ret);
1.56 + ret->ConstructL();
1.57 + CleanupStack::Pop(ret);
1.58 + return ret;
1.59 + }
1.60 +
1.61 +/**
1.62 + * Constructor. First phase construction
1.63 + */
1.64 +CT_EComResolverParamsData::CT_EComResolverParamsData()
1.65 + {
1.66 + }
1.67 +
1.68 +/**
1.69 + * Second phase construction
1.70 + */
1.71 +void CT_EComResolverParamsData::ConstructL()
1.72 + {
1.73 + }
1.74 +
1.75 +/**
1.76 + * Destructor
1.77 + */
1.78 +CT_EComResolverParamsData::~CT_EComResolverParamsData()
1.79 + {
1.80 + DestroyData();
1.81 + }
1.82 +
1.83 +void CT_EComResolverParamsData::DestroyData()
1.84 + {
1.85 + }
1.86 +
1.87 +
1.88 +TAny* CT_EComResolverParamsData::GetObject()
1.89 +/**
1.90 + * Return a pointer to the object that the data wraps
1.91 + *
1.92 + * @return Pointer to the object that the data wraps
1.93 + */
1.94 + {
1.95 + return &iResolverParams;
1.96 + };
1.97 +
1.98 +//////////////////////////////////////////////////////////////////////
1.99 +// Read data from INI file
1.100 +//////////////////////////////////////////////////////////////////////
1.101 +
1.102 +TBool CT_EComResolverParamsData::GetExpectedString(const TDesC& aSection, TPtrC& aExpectedString)
1.103 + {
1.104 + aExpectedString.Set(KEmptyString);
1.105 + return GetStringFromConfig(aSection, KExpectedString(), aExpectedString);
1.106 + }
1.107 +
1.108 +TBool CT_EComResolverParamsData::GetDataType(const TDesC& aSection, TBuf8<KMaxTestExecuteCommandLength>& aDataType)
1.109 + {
1.110 + TPtrC dataType(KEmptyString);
1.111 + TBool ret=GetStringFromConfig(aSection, KDataType(), dataType);
1.112 + if ( ret )
1.113 + {
1.114 + aDataType.Copy(dataType);
1.115 + }
1.116 + return ret;
1.117 + }
1.118 +
1.119 +TBool CT_EComResolverParamsData::GetExpectedBool(const TDesC& aSection, TBool& aBool)
1.120 + {
1.121 + aBool = EFalse;
1.122 + return GetBoolFromConfig(aSection, KExpectedBool(), aBool );
1.123 + }
1.124 +
1.125 +TBool CT_EComResolverParamsData::GetGenericMatch(const TDesC& aSection, TBool& aGenericMatch)
1.126 + {
1.127 + aGenericMatch = EFalse;
1.128 + return GetBoolFromConfig(aSection, KGenericMatch(), aGenericMatch );
1.129 + }
1.130 +
1.131 +TBool CT_EComResolverParamsData::GetWildcardMatch(const TDesC& aSection, TBool& aWildcardMatch)
1.132 + {
1.133 + aWildcardMatch = EFalse;
1.134 + return GetBoolFromConfig(aSection, KWildcardMatch(), aWildcardMatch );
1.135 + }
1.136 +
1.137 +TBool CT_EComResolverParamsData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
1.138 +/**
1.139 + * Process a command read from the ini file
1.140 + *
1.141 + * @param aCommand The command to process
1.142 + * @param aSection The section in the ini containing data for the command
1.143 + * @param aAsyncErrorIndex Command index for async calls to return errors to
1.144 + *
1.145 + * @return ETrue if the command is processed
1.146 + *
1.147 + * @leave System wide error
1.148 + */
1.149 + {
1.150 + TBool retVal=ETrue;
1.151 +
1.152 + if ( aCommand==KCmdDataType )
1.153 + {
1.154 + DoCmdDataType(aSection);
1.155 + }
1.156 + else if ( aCommand==KCmdSetDataType )
1.157 + {
1.158 + DoCmdSetDataType(aSection);
1.159 + }
1.160 + else if ( aCommand==KCmdSetGenericMatch )
1.161 + {
1.162 + DoCmdSetGenericMatch(aSection);
1.163 + }
1.164 + else if ( aCommand==KCmdIsGenericMatch )
1.165 + {
1.166 + DoCmdIsGenericMatch(aSection);
1.167 + }
1.168 + else if ( aCommand==KCmdSetWildcardMatch )
1.169 + {
1.170 + DoCmdSetWildcardMatch(aSection);
1.171 + }
1.172 + else if ( aCommand==KCmdIsWildcardMatch )
1.173 + {
1.174 + DoCmdIsWildcardMatch(aSection);
1.175 + }
1.176 + else
1.177 + {
1.178 + retVal=EFalse;
1.179 + }
1.180 +
1.181 + return retVal;
1.182 + }
1.183 +
1.184 +void CT_EComResolverParamsData::DoCmdDataType(const TDesC& aSection)
1.185 + {
1.186 + TBuf<KMaxTestExecuteCommandLength> actualValue;
1.187 + actualValue.Copy(iResolverParams.DataType());
1.188 + INFO_PRINTF2(_L("DataType %S"), &actualValue);
1.189 +
1.190 + TPtrC expectedValue;
1.191 + if (GetExpectedString(aSection, expectedValue))
1.192 + {
1.193 + if (actualValue!=expectedValue)
1.194 + {
1.195 + ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
1.196 + SetBlockResult(EFail);
1.197 + }
1.198 + }
1.199 + }
1.200 +
1.201 +void CT_EComResolverParamsData::DoCmdSetDataType(const TDesC& aSection)
1.202 + {
1.203 + if (!GetDataType(aSection, iDataType))
1.204 + {
1.205 + ERR_PRINTF1(_L("Not enought arguments"));
1.206 + SetBlockResult(EFail);
1.207 + }
1.208 + else
1.209 + {
1.210 + iResolverParams.SetDataType(iDataType);
1.211 + }
1.212 + }
1.213 +
1.214 +void CT_EComResolverParamsData::DoCmdSetGenericMatch(const TDesC& aSection)
1.215 + {
1.216 + TBool setGenericMatch;
1.217 + if (!GetGenericMatch(aSection, setGenericMatch))
1.218 + {
1.219 + ERR_PRINTF1(_L("Not enought arguments"));
1.220 + SetBlockResult(EFail);
1.221 + }
1.222 + else
1.223 + {
1.224 + iResolverParams.SetGenericMatch(setGenericMatch);
1.225 + }
1.226 + }
1.227 +
1.228 +void CT_EComResolverParamsData::DoCmdIsGenericMatch(const TDesC& aSection)
1.229 + {
1.230 + TBool actualValue=iResolverParams.IsGenericMatch();
1.231 + INFO_PRINTF2(_L("IsGenericMatch %d"), actualValue);
1.232 +
1.233 + TBool expectedValue;
1.234 + if (GetExpectedBool(aSection, expectedValue))
1.235 + {
1.236 + if (actualValue!=expectedValue)
1.237 + {
1.238 + ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
1.239 + SetBlockResult(EFail);
1.240 + }
1.241 + }
1.242 + }
1.243 +
1.244 +void CT_EComResolverParamsData::DoCmdSetWildcardMatch(const TDesC& aSection)
1.245 + {
1.246 + TBool setWildcardMatch;
1.247 + if (!GetWildcardMatch(aSection, setWildcardMatch))
1.248 + {
1.249 + ERR_PRINTF1(_L("Not enought arguments"));
1.250 + SetBlockResult(EFail);
1.251 + }
1.252 + else
1.253 + {
1.254 + iResolverParams.SetWildcardMatch(setWildcardMatch);
1.255 + }
1.256 + }
1.257 +
1.258 +void CT_EComResolverParamsData::DoCmdIsWildcardMatch(const TDesC& aSection)
1.259 + {
1.260 + TBool actualValue=iResolverParams.IsWildcardMatch();
1.261 + INFO_PRINTF2(_L("IsWildcardMatch %d"), actualValue);
1.262 +
1.263 + TBool expectedValue;
1.264 + if (GetExpectedBool(aSection, expectedValue))
1.265 + {
1.266 + if (actualValue!=expectedValue)
1.267 + {
1.268 + ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
1.269 + SetBlockResult(EFail);
1.270 + }
1.271 + }
1.272 + }
1.273 +