os/graphics/windowing/windowserver/test/t_integ/src/t_wservconfigdata.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/t_integ/src/t_wservconfigdata.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,119 @@
     1.4 +// Copyright (c) 2007-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 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent
    1.23 +*/
    1.24 +
    1.25 +#include "t_wservconfigdata.h"
    1.26 +
    1.27 +//
    1.28 +// Construction/Destruction
    1.29 +//
    1.30 +
    1.31 +CT_WServConfigData::CT_WServConfigData()
    1.32 +	{
    1.33 +	}
    1.34 +
    1.35 +CT_WServConfigData::~CT_WServConfigData()
    1.36 +	{
    1.37 +	Empty();
    1.38 +	}
    1.39 +
    1.40 +void CT_WServConfigData::ReplaceData(const TDesC& aName, const TDesC& aData)
    1.41 +	{
    1.42 +	TInt	count=iArrayName.Count();
    1.43 +	TInt	index=0;
    1.44 +	for ( index=0; index<count; ++index )
    1.45 +		{
    1.46 +		if ( aName.Compare(iArrayName[index]) == 0 )
    1.47 +			{
    1.48 +			break;
    1.49 +			}
    1.50 +		}
    1.51 +	
    1.52 +	iArrayData.Remove(index);
    1.53 +	iArrayData.Insert(aData,index);
    1.54 +	}
    1.55 +	
    1.56 +void CT_WServConfigData::AddDataL(const TDesC& aName, const TDesC& aData)
    1.57 +	{
    1.58 +	//	Ensure name does not already exist
    1.59 +	TInt	count=iArrayName.Count();
    1.60 +	TInt	index=0;
    1.61 +	for ( index=0; index<count; ++index )
    1.62 +		{
    1.63 +		if ( aName.Compare(iArrayName[index]) == 0 )
    1.64 +			{
    1.65 +			User::Leave(KErrAlreadyExists);
    1.66 +			}
    1.67 +		}
    1.68 +
    1.69 +	iArrayName.AppendL(aName);
    1.70 +	iArrayData.AppendL(aData);
    1.71 +	}
    1.72 +
    1.73 +void CT_WServConfigData::DeleteDataL(const TDesC& aName)
    1.74 +	{
    1.75 +	//	Ensure name already exist
    1.76 +	TBool	found=EFalse;
    1.77 +	TInt	count=iArrayName.Count();
    1.78 +	for ( TInt index=0; (index<count) && (!found); ++index )
    1.79 +		{
    1.80 +		if ( aName.Compare(iArrayName[index]) == 0 )
    1.81 +			{
    1.82 +			found=ETrue;
    1.83 +			iArrayName.Remove(index);
    1.84 +			iArrayData.Remove(index);
    1.85 +			}
    1.86 +		}
    1.87 +
    1.88 +	if ( !found )
    1.89 +		{
    1.90 +		User::Leave(KErrNotFound);
    1.91 +		}
    1.92 +	}
    1.93 +
    1.94 +
    1.95 +const TWServConfigData& CT_WServConfigData::GetData(const TInt aIndex) const
    1.96 +	{
    1.97 +	return iArrayData[aIndex];
    1.98 +	}
    1.99 +
   1.100 +const TWServConfigData& CT_WServConfigData::GetName(const TInt aIndex) const
   1.101 +	{
   1.102 +	return iArrayName[aIndex];
   1.103 +	}
   1.104 +
   1.105 +void CT_WServConfigData::Empty()
   1.106 +	{
   1.107 +	iArrayName.Close();
   1.108 +	iArrayData.Close();
   1.109 +	}
   1.110 +
   1.111 +TInt CT_WServConfigData::NoOfEntriesL() const
   1.112 +	{
   1.113 +	TInt	dataCount=iArrayData.Count();
   1.114 +	TInt	nameCount=iArrayName.Count();
   1.115 +
   1.116 +	if (dataCount!=nameCount)
   1.117 +		{
   1.118 +		User::Leave(KErrGeneral);
   1.119 +		}
   1.120 +
   1.121 +	return dataCount;
   1.122 +	}