sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include //RDebug sl@0: sl@0: #include "t_pseudoappshared.h" sl@0: #include "t_pseudoappscreen.h" sl@0: #include "t_pseudoappwindow.h" sl@0: sl@0: CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection() sl@0: :iScreenNo(-1),iWindowNo(-1),iSurfaceId(TSurfaceId::CreateNullId()) sl@0: { sl@0: } sl@0: sl@0: CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId) sl@0: :iScreenNo(aScreenNo),iWindowNo(aWindowNo),iSurfaceId(aSurfaceId) sl@0: { sl@0: } sl@0: sl@0: CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection(TInt aScreenNo, TInt aWindowNo) sl@0: :iScreenNo(aScreenNo),iWindowNo(aWindowNo),iSurfaceId(TSurfaceId::CreateNullId()) sl@0: { sl@0: } sl@0: sl@0: TBool CTPseudoAppShared::TSurfaceCollection::IndicesEqual(const TSurfaceCollection& aFirst, const TSurfaceCollection& aSecond) sl@0: { sl@0: return (aFirst.iScreenNo==aSecond.iScreenNo && aFirst.iWindowNo==aSecond.iWindowNo); sl@0: } sl@0: sl@0: TBool CTPseudoAppShared::TSurfaceCollection::AnotherWindowWithSameSurfaceId(const TSurfaceCollection& aFirst, const TSurfaceCollection& aSecond) sl@0: { sl@0: return (aFirst.iSurfaceId==aSecond.iSurfaceId && (aFirst.iScreenNo!=aSecond.iScreenNo || aFirst.iWindowNo!=aSecond.iWindowNo)); sl@0: } sl@0: sl@0: EXPORT_C CTPseudoAppShared::CTPseudoAppShared() sl@0: { sl@0: } sl@0: sl@0: EXPORT_C void CTPseudoAppShared::AddTestScreenL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, sl@0: TGceTestResults* aGceTestResults, const TDesC& aConfigFileName) sl@0: { sl@0: CTestScreen* newScreen = CTestScreen::NewL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName, *this); sl@0: CleanupStack::PushL(newScreen); sl@0: iTestScreens.AppendL(newScreen); sl@0: CleanupStack::Pop(newScreen); sl@0: } sl@0: sl@0: CTPseudoAppShared::~CTPseudoAppShared() sl@0: { sl@0: iTestScreens.ResetAndDestroy(); sl@0: iTestScreens.Close(); sl@0: iSurfaceCollection.Close(); sl@0: } sl@0: sl@0: TSurfaceId CTPseudoAppShared::GetSurfaceId(TInt aScreenNo, TInt aWindowNo) sl@0: { sl@0: TSurfaceCollection matchCollection(aScreenNo, aWindowNo); sl@0: sl@0: TInt pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation(TSurfaceCollection::IndicesEqual)); sl@0: if(pos == KErrNotFound) sl@0: { sl@0: return TSurfaceId::CreateNullId(); sl@0: } sl@0: else sl@0: { sl@0: return iSurfaceCollection[pos].iSurfaceId; sl@0: } sl@0: } sl@0: sl@0: void CTPseudoAppShared::SetSurfaceIdL(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId) sl@0: { sl@0: TSurfaceCollection newCollection(aScreenNo, aWindowNo, aSurfaceId); sl@0: sl@0: TInt pos = iSurfaceCollection.Find(newCollection, TIdentityRelation(TSurfaceCollection::IndicesEqual)); sl@0: if(pos >= 0) sl@0: { sl@0: // Replace SurfaceId for window as already in array sl@0: iSurfaceCollection[pos].iSurfaceId = aSurfaceId; sl@0: } sl@0: else if(pos == KErrNotFound) sl@0: { sl@0: // Add new entry to array sl@0: iSurfaceCollection.AppendL(newCollection); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(pos); sl@0: } sl@0: } sl@0: sl@0: void CTPseudoAppShared::RemoveSurfaceIdEntry(TInt aScreenNo, TInt aWindowNo) sl@0: { sl@0: TSurfaceCollection matchCollection(aScreenNo, aWindowNo); sl@0: sl@0: TInt pos = 0; sl@0: while(pos >= 0) sl@0: { sl@0: pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation(TSurfaceCollection::IndicesEqual)); sl@0: if(pos == KErrNotFound) sl@0: { sl@0: return; sl@0: } sl@0: else sl@0: { sl@0: iSurfaceCollection.Remove(pos); sl@0: } sl@0: } sl@0: } sl@0: sl@0: TBool CTPseudoAppShared::RotationSupported(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId) const sl@0: { sl@0: TSurfaceCollection matchCollection(aScreenNo, aWindowNo, aSurfaceId); sl@0: sl@0: TInt pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation(TSurfaceCollection::AnotherWindowWithSameSurfaceId)); sl@0: sl@0: return (pos == KErrNotFound); sl@0: }