os/ossrv/syslibsapitest/syslibssvs/ecom/src/T_ImplementationInformationData.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
sl@0
    20
#include "T_ImplementationInformationData.h"
sl@0
    21
sl@0
    22
/*@{*/
sl@0
    23
///	Parameters
sl@0
    24
_LIT( KUid,													"uid" );
sl@0
    25
_LIT( KExpectedString,										"expected_string" );
sl@0
    26
_LIT( KExpectedResult,										"expected" );
sl@0
    27
_LIT( KExpectedBool,										"expected_bool" );
sl@0
    28
_LIT( KDisabled,											"disabled" );
sl@0
    29
_LIT( KElement,												"element" );
sl@0
    30
sl@0
    31
///	CImplementationInformation
sl@0
    32
_LIT( KCmdDisplayName,										"DisplayName" );
sl@0
    33
_LIT( KCmdDataType,											"DataType" );
sl@0
    34
_LIT( KCmdOpaqueData,										"OpaqueData" );
sl@0
    35
_LIT( KCmdImplementationUid,								"ImplementationUid" );
sl@0
    36
_LIT( KCmdVersion,											"Version" );
sl@0
    37
_LIT( KCmdDisabled,											"Disabled" );
sl@0
    38
_LIT( KCmdSetDisabled,										"SetDisabled" );
sl@0
    39
_LIT( KCmdDrive,											"Drive" );
sl@0
    40
_LIT( KCmdRomOnly,											"RomOnly" );
sl@0
    41
_LIT( KCmdRomBased,											"RomBased" );
sl@0
    42
_LIT( KCmdDestroy,											"~" );
sl@0
    43
sl@0
    44
_LIT( KEmptyString,											"");
sl@0
    45
/*@}*/
sl@0
    46
sl@0
    47
//////////////////////////////////////////////////////////////////////
sl@0
    48
// Construction/Destruction
sl@0
    49
//////////////////////////////////////////////////////////////////////
sl@0
    50
sl@0
    51
CT_ImplementationInformationData* CT_ImplementationInformationData::NewL( )
sl@0
    52
	{
sl@0
    53
	CT_ImplementationInformationData*	ret = new ( ELeave ) CT_ImplementationInformationData( );
sl@0
    54
	CleanupStack::PushL( ret );
sl@0
    55
	ret->ConstructL();
sl@0
    56
	CleanupStack::Pop( ret );
sl@0
    57
	return ret;
sl@0
    58
	}
sl@0
    59
sl@0
    60
CT_ImplementationInformationData::CT_ImplementationInformationData( )
sl@0
    61
:	iImplementationInformation(NULL)
sl@0
    62
	{
sl@0
    63
	}
sl@0
    64
sl@0
    65
void CT_ImplementationInformationData::ConstructL()
sl@0
    66
	{
sl@0
    67
	}
sl@0
    68
sl@0
    69
CT_ImplementationInformationData::~CT_ImplementationInformationData()
sl@0
    70
	{
sl@0
    71
	DestroyData();
sl@0
    72
	}
sl@0
    73
sl@0
    74
void CT_ImplementationInformationData::DestroyData()
sl@0
    75
	{
sl@0
    76
	//	this does not own iImplementationInformation
sl@0
    77
	iImplementationInformation=NULL;
sl@0
    78
	}
sl@0
    79
sl@0
    80
//////////////////////////////////////////////////////////////////////
sl@0
    81
// Read data from INI file
sl@0
    82
//////////////////////////////////////////////////////////////////////
sl@0
    83
sl@0
    84
TBool CT_ImplementationInformationData::GetUid( const TDesC& aSection, TUid& aUid )
sl@0
    85
	{
sl@0
    86
 	TInt	uidValue=0;
sl@0
    87
 	TBool	ret=GetHexFromConfig( aSection, KUid(), uidValue ) ;
sl@0
    88
 	aUid = TUid::Uid( uidValue );
sl@0
    89
 	return ret;
sl@0
    90
 	}
sl@0
    91
sl@0
    92
TBool CT_ImplementationInformationData::GetExpectedString( const TDesC& aSection, TPtrC& aExpectedString)
sl@0
    93
	{
sl@0
    94
	aExpectedString.Set(KEmptyString);
sl@0
    95
	return GetStringFromConfig( aSection, KExpectedString(), aExpectedString);
sl@0
    96
	}
sl@0
    97
sl@0
    98
TBool CT_ImplementationInformationData::GetExpectedResult( const TDesC& aSection, TInt& aExpectedResult )
sl@0
    99
	{
sl@0
   100
	aExpectedResult = 0;
sl@0
   101
	return GetIntFromConfig( aSection, KExpectedResult(), aExpectedResult );
sl@0
   102
	}
sl@0
   103
sl@0
   104
TBool CT_ImplementationInformationData::GetExpectedHexResult( const TDesC& aSection, TInt& aExpectedResult)
sl@0
   105
	{
sl@0
   106
	aExpectedResult = 0;
sl@0
   107
	return GetHexFromConfig( aSection, KExpectedResult(), aExpectedResult );
sl@0
   108
	}
sl@0
   109
sl@0
   110
TBool CT_ImplementationInformationData::GetArrayElement(const TDesC& aSection, TInt& aArrayElement)
sl@0
   111
	{
sl@0
   112
	aArrayElement = 0;
sl@0
   113
	return GetIntFromConfig( aSection, KElement(), aArrayElement);
sl@0
   114
	}
sl@0
   115
sl@0
   116
TBool CT_ImplementationInformationData::GetExpectedBool( const TDesC& aSection, TBool& aBool )
sl@0
   117
	{
sl@0
   118
	aBool = EFalse;
sl@0
   119
	return GetBoolFromConfig( aSection, KExpectedBool(), aBool );
sl@0
   120
	}
sl@0
   121
sl@0
   122
TBool CT_ImplementationInformationData::GetDisabled( const TDesC& aSection, TBool& aDisabled )
sl@0
   123
	{
sl@0
   124
	aDisabled = EFalse;
sl@0
   125
	return GetBoolFromConfig( aSection, KDisabled(), aDisabled );
sl@0
   126
	}
sl@0
   127
sl@0
   128
/**
sl@0
   129
 Test script command entry point
sl@0
   130
 @internalComponent
sl@0
   131
sl@0
   132
 @return Explanation of the object returned
sl@0
   133
 @param aCommand descriptor containing the command value
sl@0
   134
 @param aSection descriptor containing the command parameter
sl@0
   135
 @pre N/A 
sl@0
   136
 @post N/A
sl@0
   137
*/
sl@0
   138
TBool CT_ImplementationInformationData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
sl@0
   139
	{
sl@0
   140
	TBool								retVal = ETrue;
sl@0
   141
	
sl@0
   142
	if ( aCommand == KCmdDestroy )
sl@0
   143
		{
sl@0
   144
		DoCmdDestroy();
sl@0
   145
		}
sl@0
   146
	else if ( aCommand == KCmdDisplayName )
sl@0
   147
		{
sl@0
   148
		DoCmdDisplayName( aSection );
sl@0
   149
		}
sl@0
   150
	else if ( aCommand == KCmdDataType )
sl@0
   151
		{
sl@0
   152
		DoCmdDataType( aSection );
sl@0
   153
		}
sl@0
   154
	else if ( aCommand == KCmdOpaqueData )
sl@0
   155
		{
sl@0
   156
		DoCmdOpaqueData( aSection );
sl@0
   157
		}
sl@0
   158
	else if ( aCommand == KCmdImplementationUid )
sl@0
   159
		{
sl@0
   160
		DoCmdImplementationUid( aSection );
sl@0
   161
		}
sl@0
   162
	else if ( aCommand == KCmdVersion )
sl@0
   163
		{
sl@0
   164
		DoCmdVersion( aSection );
sl@0
   165
		}
sl@0
   166
	else if ( aCommand == KCmdDisabled )
sl@0
   167
		{
sl@0
   168
		DoCmdDisabled( aSection );
sl@0
   169
		}
sl@0
   170
	else if ( aCommand == KCmdSetDisabled )
sl@0
   171
		{
sl@0
   172
		DoCmdSetDisabled( aSection );
sl@0
   173
		}
sl@0
   174
	else if ( aCommand == KCmdDrive )
sl@0
   175
		{
sl@0
   176
		DoCmdDrive( aSection );
sl@0
   177
		}
sl@0
   178
	else if ( aCommand == KCmdRomOnly )
sl@0
   179
		{
sl@0
   180
		DoCmdRomOnly( aSection );
sl@0
   181
		}
sl@0
   182
	else if ( aCommand == KCmdRomBased )
sl@0
   183
		{
sl@0
   184
		DoCmdRomBased( aSection );
sl@0
   185
		}
sl@0
   186
	else
sl@0
   187
		{
sl@0
   188
		retVal = EFalse;
sl@0
   189
		}
sl@0
   190
sl@0
   191
	return retVal;
sl@0
   192
	}
sl@0
   193
sl@0
   194
void CT_ImplementationInformationData::DoCmdDisplayName(const TDesC& aSection)
sl@0
   195
	{
sl@0
   196
	TBuf<KMaxTestExecuteCommandLength>	actualValue;
sl@0
   197
	actualValue.Copy(iImplementationInformation->DisplayName());
sl@0
   198
	TInt	pos=actualValue.Find(_L("|"));
sl@0
   199
	if (pos>0)
sl@0
   200
		{
sl@0
   201
		actualValue.Copy(actualValue.Left(pos));
sl@0
   202
		};
sl@0
   203
	INFO_PRINTF2(_L("DisplayName %S"), &actualValue);
sl@0
   204
sl@0
   205
	TPtrC	expectedValue;
sl@0
   206
	if (GetExpectedString(aSection, expectedValue))
sl@0
   207
		{
sl@0
   208
		if (actualValue!=expectedValue)
sl@0
   209
			{
sl@0
   210
			ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
sl@0
   211
			SetBlockResult(EFail);
sl@0
   212
			}
sl@0
   213
		}
sl@0
   214
	}
sl@0
   215
sl@0
   216
void CT_ImplementationInformationData::DoCmdDataType(const TDesC& aSection)
sl@0
   217
	{
sl@0
   218
	TBuf<KMaxTestExecuteCommandLength>	actualValue;
sl@0
   219
	actualValue.Copy(iImplementationInformation->DataType());
sl@0
   220
	TInt	pos=actualValue.Find(_L("|"));
sl@0
   221
	if (pos>0)
sl@0
   222
		{
sl@0
   223
		actualValue.Copy(actualValue.Left(pos));
sl@0
   224
		};
sl@0
   225
	INFO_PRINTF2(_L("DataType %S"), &actualValue);
sl@0
   226
	
sl@0
   227
	TPtrC	expectedValue;
sl@0
   228
	if (GetExpectedString(aSection, expectedValue))
sl@0
   229
		{
sl@0
   230
		if (actualValue!=expectedValue)
sl@0
   231
			{
sl@0
   232
			ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
sl@0
   233
			SetBlockResult(EFail);
sl@0
   234
			}
sl@0
   235
		}
sl@0
   236
	}
sl@0
   237
sl@0
   238
void CT_ImplementationInformationData::DoCmdOpaqueData(const TDesC& aSection)
sl@0
   239
	{
sl@0
   240
	TBuf<KMaxTestExecuteCommandLength>	actualValue;
sl@0
   241
	actualValue.Copy(iImplementationInformation->OpaqueData());
sl@0
   242
	TInt	pos=actualValue.Find(_L("|"));
sl@0
   243
	if (pos>0)
sl@0
   244
		{
sl@0
   245
		actualValue.Copy(actualValue.Left(pos));
sl@0
   246
		};
sl@0
   247
	INFO_PRINTF2(_L("OpaqueData %S"), &actualValue);
sl@0
   248
	
sl@0
   249
	TPtrC	expectedValue;
sl@0
   250
	if (GetExpectedString(aSection, expectedValue))
sl@0
   251
		{
sl@0
   252
		if (actualValue!=expectedValue)
sl@0
   253
			{
sl@0
   254
			ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
sl@0
   255
			SetBlockResult(EFail);
sl@0
   256
			}
sl@0
   257
		}
sl@0
   258
	}
sl@0
   259
sl@0
   260
void CT_ImplementationInformationData::DoCmdImplementationUid(const TDesC& aSection)
sl@0
   261
	{
sl@0
   262
	TInt	actualValue=iImplementationInformation->ImplementationUid().iUid;
sl@0
   263
	INFO_PRINTF2(_L("ImplementationUid %d"), actualValue);
sl@0
   264
sl@0
   265
	TInt	expectedValue;
sl@0
   266
	if (GetExpectedHexResult(aSection, expectedValue))
sl@0
   267
		{
sl@0
   268
		if (actualValue!=expectedValue)
sl@0
   269
			{
sl@0
   270
			ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
sl@0
   271
			SetBlockResult(EFail);
sl@0
   272
			}
sl@0
   273
		}
sl@0
   274
	}
sl@0
   275
sl@0
   276
void CT_ImplementationInformationData::DoCmdVersion(const TDesC& aSection)
sl@0
   277
	{
sl@0
   278
	TInt	actualValue=iImplementationInformation->Version();
sl@0
   279
	INFO_PRINTF2(_L("Version %d"), actualValue);
sl@0
   280
sl@0
   281
	TInt	expectedValue;
sl@0
   282
	if (GetExpectedResult(aSection, expectedValue))
sl@0
   283
		{
sl@0
   284
		if (actualValue!=expectedValue)
sl@0
   285
			{
sl@0
   286
			ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
sl@0
   287
			SetBlockResult(EFail);
sl@0
   288
			}
sl@0
   289
		}
sl@0
   290
	}
sl@0
   291
sl@0
   292
void CT_ImplementationInformationData::DoCmdDisabled(const TDesC& aSection)
sl@0
   293
	{
sl@0
   294
	TBool	actualValue=iImplementationInformation->Disabled();
sl@0
   295
	INFO_PRINTF2(_L("Disabled %d"), actualValue);
sl@0
   296
sl@0
   297
	TBool	expectedValue;
sl@0
   298
	if (GetExpectedBool(aSection, expectedValue))
sl@0
   299
		{
sl@0
   300
		if (actualValue!=expectedValue)
sl@0
   301
			{
sl@0
   302
			ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
sl@0
   303
			SetBlockResult(EFail);
sl@0
   304
			}
sl@0
   305
		}
sl@0
   306
	}
sl@0
   307
sl@0
   308
void CT_ImplementationInformationData::DoCmdSetDisabled(const TDesC& aSection)
sl@0
   309
	{
sl@0
   310
	INFO_PRINTF1(_L("SetDisabled"));
sl@0
   311
sl@0
   312
	TBool	disabled;
sl@0
   313
	if (!GetDisabled(aSection, disabled))
sl@0
   314
		{
sl@0
   315
		ERR_PRINTF1(_L("Not enought arguments"));
sl@0
   316
		SetBlockResult( EFail );
sl@0
   317
		}
sl@0
   318
	else
sl@0
   319
		{
sl@0
   320
		iImplementationInformation->SetDisabled(disabled);
sl@0
   321
		}
sl@0
   322
	}
sl@0
   323
sl@0
   324
void CT_ImplementationInformationData::DoCmdDrive(const TDesC& aSection)
sl@0
   325
	{
sl@0
   326
	TDriveName	actualValue(iImplementationInformation->Drive().Name());
sl@0
   327
	INFO_PRINTF2(_L("Drive Name %s"), &actualValue);
sl@0
   328
sl@0
   329
	TPtrC	expectedValue;
sl@0
   330
	if (GetExpectedString(aSection, expectedValue))
sl@0
   331
		{
sl@0
   332
		if (actualValue!=expectedValue)
sl@0
   333
			{
sl@0
   334
			ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
sl@0
   335
			SetBlockResult(EFail);
sl@0
   336
			}
sl@0
   337
		}
sl@0
   338
	}
sl@0
   339
sl@0
   340
void CT_ImplementationInformationData::DoCmdRomOnly(const TDesC& aSection)
sl@0
   341
	{
sl@0
   342
	TBool	actualValue=iImplementationInformation->RomOnly();
sl@0
   343
	INFO_PRINTF2(_L("RomOnly %d"), actualValue);
sl@0
   344
sl@0
   345
	TBool	expectedValue;
sl@0
   346
	if (GetExpectedBool(aSection, expectedValue))
sl@0
   347
		{
sl@0
   348
		if (actualValue!=expectedValue)
sl@0
   349
			{
sl@0
   350
			ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
sl@0
   351
			SetBlockResult(EFail);
sl@0
   352
			}
sl@0
   353
		}
sl@0
   354
	}
sl@0
   355
sl@0
   356
void CT_ImplementationInformationData::DoCmdRomBased(const TDesC& aSection)
sl@0
   357
	{
sl@0
   358
	TBool	actualValue=iImplementationInformation->RomBased();
sl@0
   359
	INFO_PRINTF2(_L("RomBased %d"), actualValue);
sl@0
   360
sl@0
   361
	TBool	expectedValue;
sl@0
   362
	if (GetExpectedBool(aSection, expectedValue))
sl@0
   363
		{
sl@0
   364
		if (actualValue!=expectedValue)
sl@0
   365
			{
sl@0
   366
			ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
sl@0
   367
			SetBlockResult(EFail);
sl@0
   368
			}
sl@0
   369
		}
sl@0
   370
	}
sl@0
   371
sl@0
   372
void CT_ImplementationInformationData::DoCmdDestroy()
sl@0
   373
	{
sl@0
   374
	INFO_PRINTF1( _L( "Destroyed" ) );
sl@0
   375
	DestroyData();
sl@0
   376
	}