os/graphics/windowing/windowserver/test/t_integ/src/t_pseudoappshared.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_pseudoappshared.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,137 @@
     1.4 +// Copyright (c) 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 +
    1.21 +/**
    1.22 + @file
    1.23 + @test
    1.24 + @internalComponent
    1.25 +*/
    1.26 +
    1.27 +#include <e32debug.h> //RDebug
    1.28 +
    1.29 +#include "t_pseudoappshared.h"
    1.30 +#include "t_pseudoappscreen.h"
    1.31 +#include "t_pseudoappwindow.h"
    1.32 +
    1.33 +CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection()
    1.34 +:iScreenNo(-1),iWindowNo(-1),iSurfaceId(TSurfaceId::CreateNullId())
    1.35 +	{
    1.36 +	}
    1.37 +
    1.38 +CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId)
    1.39 +:iScreenNo(aScreenNo),iWindowNo(aWindowNo),iSurfaceId(aSurfaceId)
    1.40 +	{
    1.41 +	}
    1.42 +
    1.43 +CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection(TInt aScreenNo, TInt aWindowNo)
    1.44 +:iScreenNo(aScreenNo),iWindowNo(aWindowNo),iSurfaceId(TSurfaceId::CreateNullId())
    1.45 +	{
    1.46 +	}
    1.47 +
    1.48 +TBool CTPseudoAppShared::TSurfaceCollection::IndicesEqual(const TSurfaceCollection& aFirst, const TSurfaceCollection& aSecond)
    1.49 +	{
    1.50 +	return (aFirst.iScreenNo==aSecond.iScreenNo && aFirst.iWindowNo==aSecond.iWindowNo);
    1.51 +	}
    1.52 +
    1.53 +TBool CTPseudoAppShared::TSurfaceCollection::AnotherWindowWithSameSurfaceId(const TSurfaceCollection& aFirst, const TSurfaceCollection& aSecond)
    1.54 +	{
    1.55 +	return (aFirst.iSurfaceId==aSecond.iSurfaceId && (aFirst.iScreenNo!=aSecond.iScreenNo || aFirst.iWindowNo!=aSecond.iWindowNo));
    1.56 +	}
    1.57 +
    1.58 +EXPORT_C CTPseudoAppShared::CTPseudoAppShared()
    1.59 +	{
    1.60 +	}
    1.61 +
    1.62 +EXPORT_C void CTPseudoAppShared::AddTestScreenL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize,
    1.63 +												TGceTestResults* aGceTestResults, const TDesC& aConfigFileName)
    1.64 +	{
    1.65 +	CTestScreen* newScreen = CTestScreen::NewL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName, *this);
    1.66 +	CleanupStack::PushL(newScreen);
    1.67 +	iTestScreens.AppendL(newScreen);
    1.68 +	CleanupStack::Pop(newScreen);
    1.69 +	}
    1.70 +
    1.71 +CTPseudoAppShared::~CTPseudoAppShared()
    1.72 +	{
    1.73 +	iTestScreens.ResetAndDestroy();
    1.74 +	iTestScreens.Close();
    1.75 +	iSurfaceCollection.Close();
    1.76 +	}
    1.77 +
    1.78 +TSurfaceId CTPseudoAppShared::GetSurfaceId(TInt aScreenNo, TInt aWindowNo)
    1.79 +	{
    1.80 +	TSurfaceCollection matchCollection(aScreenNo, aWindowNo);
    1.81 +	
    1.82 +	TInt pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::IndicesEqual));
    1.83 +	if(pos == KErrNotFound)
    1.84 +		{
    1.85 +		return TSurfaceId::CreateNullId();
    1.86 +		}
    1.87 +	else
    1.88 +		{
    1.89 +		return iSurfaceCollection[pos].iSurfaceId;
    1.90 +		}
    1.91 +	}
    1.92 +
    1.93 +void CTPseudoAppShared::SetSurfaceIdL(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId)
    1.94 +	{
    1.95 +	TSurfaceCollection newCollection(aScreenNo, aWindowNo, aSurfaceId);
    1.96 +	
    1.97 +	TInt pos = iSurfaceCollection.Find(newCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::IndicesEqual));
    1.98 +	if(pos >= 0)
    1.99 +		{
   1.100 +		// Replace SurfaceId for window as already in array
   1.101 +		iSurfaceCollection[pos].iSurfaceId = aSurfaceId;
   1.102 +		}
   1.103 +	else if(pos == KErrNotFound)
   1.104 +		{
   1.105 +		// Add new entry to array
   1.106 +		iSurfaceCollection.AppendL(newCollection);
   1.107 +		}
   1.108 +	else
   1.109 +		{
   1.110 +		User::Leave(pos);
   1.111 +		}
   1.112 +	}
   1.113 +
   1.114 +void CTPseudoAppShared::RemoveSurfaceIdEntry(TInt aScreenNo, TInt aWindowNo)
   1.115 +	{
   1.116 +	TSurfaceCollection matchCollection(aScreenNo, aWindowNo);
   1.117 +	
   1.118 +	TInt pos = 0;
   1.119 +	while(pos >= 0)
   1.120 +		{
   1.121 +		pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::IndicesEqual));
   1.122 +		if(pos == KErrNotFound)
   1.123 +			{
   1.124 +			return;
   1.125 +			}
   1.126 +		else
   1.127 +			{
   1.128 +			iSurfaceCollection.Remove(pos);
   1.129 +			}
   1.130 +		}
   1.131 +	}
   1.132 +
   1.133 +TBool CTPseudoAppShared::RotationSupported(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId) const
   1.134 +	{
   1.135 +	TSurfaceCollection matchCollection(aScreenNo, aWindowNo, aSurfaceId);
   1.136 +	
   1.137 +	TInt pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::AnotherWindowWithSameSurfaceId));
   1.138 +	
   1.139 +	return (pos == KErrNotFound);
   1.140 +	}