First public contribution.
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 #include <e32debug.h> //RDebug
26 #include "t_pseudoappshared.h"
27 #include "t_pseudoappscreen.h"
28 #include "t_pseudoappwindow.h"
30 CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection()
31 :iScreenNo(-1),iWindowNo(-1),iSurfaceId(TSurfaceId::CreateNullId())
35 CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId)
36 :iScreenNo(aScreenNo),iWindowNo(aWindowNo),iSurfaceId(aSurfaceId)
40 CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection(TInt aScreenNo, TInt aWindowNo)
41 :iScreenNo(aScreenNo),iWindowNo(aWindowNo),iSurfaceId(TSurfaceId::CreateNullId())
45 TBool CTPseudoAppShared::TSurfaceCollection::IndicesEqual(const TSurfaceCollection& aFirst, const TSurfaceCollection& aSecond)
47 return (aFirst.iScreenNo==aSecond.iScreenNo && aFirst.iWindowNo==aSecond.iWindowNo);
50 TBool CTPseudoAppShared::TSurfaceCollection::AnotherWindowWithSameSurfaceId(const TSurfaceCollection& aFirst, const TSurfaceCollection& aSecond)
52 return (aFirst.iSurfaceId==aSecond.iSurfaceId && (aFirst.iScreenNo!=aSecond.iScreenNo || aFirst.iWindowNo!=aSecond.iWindowNo));
55 EXPORT_C CTPseudoAppShared::CTPseudoAppShared()
59 EXPORT_C void CTPseudoAppShared::AddTestScreenL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize,
60 TGceTestResults* aGceTestResults, const TDesC& aConfigFileName)
62 CTestScreen* newScreen = CTestScreen::NewL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName, *this);
63 CleanupStack::PushL(newScreen);
64 iTestScreens.AppendL(newScreen);
65 CleanupStack::Pop(newScreen);
68 CTPseudoAppShared::~CTPseudoAppShared()
70 iTestScreens.ResetAndDestroy();
72 iSurfaceCollection.Close();
75 TSurfaceId CTPseudoAppShared::GetSurfaceId(TInt aScreenNo, TInt aWindowNo)
77 TSurfaceCollection matchCollection(aScreenNo, aWindowNo);
79 TInt pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::IndicesEqual));
80 if(pos == KErrNotFound)
82 return TSurfaceId::CreateNullId();
86 return iSurfaceCollection[pos].iSurfaceId;
90 void CTPseudoAppShared::SetSurfaceIdL(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId)
92 TSurfaceCollection newCollection(aScreenNo, aWindowNo, aSurfaceId);
94 TInt pos = iSurfaceCollection.Find(newCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::IndicesEqual));
97 // Replace SurfaceId for window as already in array
98 iSurfaceCollection[pos].iSurfaceId = aSurfaceId;
100 else if(pos == KErrNotFound)
102 // Add new entry to array
103 iSurfaceCollection.AppendL(newCollection);
111 void CTPseudoAppShared::RemoveSurfaceIdEntry(TInt aScreenNo, TInt aWindowNo)
113 TSurfaceCollection matchCollection(aScreenNo, aWindowNo);
118 pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::IndicesEqual));
119 if(pos == KErrNotFound)
125 iSurfaceCollection.Remove(pos);
130 TBool CTPseudoAppShared::RotationSupported(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId) const
132 TSurfaceCollection matchCollection(aScreenNo, aWindowNo, aSurfaceId);
134 TInt pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::AnotherWindowWithSameSurfaceId));
136 return (pos == KErrNotFound);