os/graphics/windowing/windowserver/test/t_integ/src/t_pseudoappshared.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 
    17 
    18 /**
    19  @file
    20  @test
    21  @internalComponent
    22 */
    23 
    24 #include <e32debug.h> //RDebug
    25 
    26 #include "t_pseudoappshared.h"
    27 #include "t_pseudoappscreen.h"
    28 #include "t_pseudoappwindow.h"
    29 
    30 CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection()
    31 :iScreenNo(-1),iWindowNo(-1),iSurfaceId(TSurfaceId::CreateNullId())
    32 	{
    33 	}
    34 
    35 CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId)
    36 :iScreenNo(aScreenNo),iWindowNo(aWindowNo),iSurfaceId(aSurfaceId)
    37 	{
    38 	}
    39 
    40 CTPseudoAppShared::TSurfaceCollection::TSurfaceCollection(TInt aScreenNo, TInt aWindowNo)
    41 :iScreenNo(aScreenNo),iWindowNo(aWindowNo),iSurfaceId(TSurfaceId::CreateNullId())
    42 	{
    43 	}
    44 
    45 TBool CTPseudoAppShared::TSurfaceCollection::IndicesEqual(const TSurfaceCollection& aFirst, const TSurfaceCollection& aSecond)
    46 	{
    47 	return (aFirst.iScreenNo==aSecond.iScreenNo && aFirst.iWindowNo==aSecond.iWindowNo);
    48 	}
    49 
    50 TBool CTPseudoAppShared::TSurfaceCollection::AnotherWindowWithSameSurfaceId(const TSurfaceCollection& aFirst, const TSurfaceCollection& aSecond)
    51 	{
    52 	return (aFirst.iSurfaceId==aSecond.iSurfaceId && (aFirst.iScreenNo!=aSecond.iScreenNo || aFirst.iWindowNo!=aSecond.iWindowNo));
    53 	}
    54 
    55 EXPORT_C CTPseudoAppShared::CTPseudoAppShared()
    56 	{
    57 	}
    58 
    59 EXPORT_C void CTPseudoAppShared::AddTestScreenL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize,
    60 												TGceTestResults* aGceTestResults, const TDesC& aConfigFileName)
    61 	{
    62 	CTestScreen* newScreen = CTestScreen::NewL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName, *this);
    63 	CleanupStack::PushL(newScreen);
    64 	iTestScreens.AppendL(newScreen);
    65 	CleanupStack::Pop(newScreen);
    66 	}
    67 
    68 CTPseudoAppShared::~CTPseudoAppShared()
    69 	{
    70 	iTestScreens.ResetAndDestroy();
    71 	iTestScreens.Close();
    72 	iSurfaceCollection.Close();
    73 	}
    74 
    75 TSurfaceId CTPseudoAppShared::GetSurfaceId(TInt aScreenNo, TInt aWindowNo)
    76 	{
    77 	TSurfaceCollection matchCollection(aScreenNo, aWindowNo);
    78 	
    79 	TInt pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::IndicesEqual));
    80 	if(pos == KErrNotFound)
    81 		{
    82 		return TSurfaceId::CreateNullId();
    83 		}
    84 	else
    85 		{
    86 		return iSurfaceCollection[pos].iSurfaceId;
    87 		}
    88 	}
    89 
    90 void CTPseudoAppShared::SetSurfaceIdL(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId)
    91 	{
    92 	TSurfaceCollection newCollection(aScreenNo, aWindowNo, aSurfaceId);
    93 	
    94 	TInt pos = iSurfaceCollection.Find(newCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::IndicesEqual));
    95 	if(pos >= 0)
    96 		{
    97 		// Replace SurfaceId for window as already in array
    98 		iSurfaceCollection[pos].iSurfaceId = aSurfaceId;
    99 		}
   100 	else if(pos == KErrNotFound)
   101 		{
   102 		// Add new entry to array
   103 		iSurfaceCollection.AppendL(newCollection);
   104 		}
   105 	else
   106 		{
   107 		User::Leave(pos);
   108 		}
   109 	}
   110 
   111 void CTPseudoAppShared::RemoveSurfaceIdEntry(TInt aScreenNo, TInt aWindowNo)
   112 	{
   113 	TSurfaceCollection matchCollection(aScreenNo, aWindowNo);
   114 	
   115 	TInt pos = 0;
   116 	while(pos >= 0)
   117 		{
   118 		pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::IndicesEqual));
   119 		if(pos == KErrNotFound)
   120 			{
   121 			return;
   122 			}
   123 		else
   124 			{
   125 			iSurfaceCollection.Remove(pos);
   126 			}
   127 		}
   128 	}
   129 
   130 TBool CTPseudoAppShared::RotationSupported(TInt aScreenNo, TInt aWindowNo, const TSurfaceId& aSurfaceId) const
   131 	{
   132 	TSurfaceCollection matchCollection(aScreenNo, aWindowNo, aSurfaceId);
   133 	
   134 	TInt pos = iSurfaceCollection.Find(matchCollection, TIdentityRelation<TSurfaceCollection>(TSurfaceCollection::AnotherWindowWithSameSurfaceId));
   135 	
   136 	return (pos == KErrNotFound);
   137 	}