os/graphics/windowing/windowserver/test/t_integ/src/t_pseudoappscreen.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2007-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  @file
    18  @test
    19  @internalComponent
    20 */
    21 
    22 #include "t_pseudoappscreen.h"
    23 #include "t_pseudoapputils.h"
    24 #include "t_pseudoapptestresults.h"
    25 #include "t_pseudoappeng.h"
    26 
    27 CTestScreen* CTestScreen::NewL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults,
    28 							   const TDesC& aConfigFileName, CTPseudoAppShared& aPseudoAppShared)
    29     {
    30 	RDebug::Print(_L("Creating CTestScreen class\n"));
    31     CTestScreen* self = new (ELeave) CTestScreen(aPseudoAppShared);
    32     CleanupStack::PushL(self);
    33     self->ConstructL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName);
    34     CleanupStack::Pop(); // self;
    35     return self;
    36     }
    37 
    38 void CTestScreen::ConstructL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults,
    39 							const TDesC& aConfigFileName)
    40 	{
    41 	RDebug::Print(_L("Constructing CTestScreen for screen %d\n"), aScreenNo);
    42 
    43 	iPopupOccurances = 0;
    44 	iFrameDuration = aFrameDuration;
    45 	iScreenSize = aScreenSize;
    46 
    47 	//Create CIniData class for reading in values form ini files
    48 	iUtils = CIniData::NewL(aConfigFileName);
    49 
    50 	ImportScreenConfigL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName);
    51 	}
    52 
    53 CTestScreen::~CTestScreen()
    54 	{
    55 	if (iWindAndSurf)
    56 		{
    57 		iWindAndSurf->ResetAndDestroy();
    58 		delete iWindAndSurf;
    59 		}
    60 
    61 	delete iUtils;
    62 	}
    63 
    64 CTestScreen::CTestScreen(CTPseudoAppShared& aPseudoAppShared)
    65 : iPseudoAppShared(aPseudoAppShared)
    66 	{
    67 	}
    68 
    69 EXPORT_C void CTestScreen::UpdateL(SurfaceDetails& aSurfDetails)
    70 	{
    71 	//Update all windowed surfaces changes
    72 	for(TInt index1=0; index1<iWindAndSurf->Count(); index1++)
    73 		{
    74 		(*iWindAndSurf)[index1]->UpdateL(aSurfDetails);
    75 		}
    76 
    77 	//Launch popup window if configured by ini file
    78 	for(TInt index2=1; index2<(iPopupOccurances+1); index2++)
    79 		{
    80 		if(iFrameCounter == iFrameDuration/(2*iPopupOccurances*index2))
    81 			{
    82 			CreatePopupWindow();
    83 			}
    84 		else if(iFrameCounter == (iFrameDuration/(2*iPopupOccurances*index2) + iFrameDuration/(4*iPopupOccurances)))
    85 			{
    86 			DestroyPopupWindow();
    87 			}
    88 		}
    89 
    90 	iFrameCounter++;
    91 	}
    92 
    93 EXPORT_C TBool CTestScreen::Rotation()
    94 	{
    95 	return iRotation;
    96 	}
    97 
    98 EXPORT_C void CTestScreen::RotateL(TInt aScreenNo, TInt aFrameNumber)
    99 	{
   100 	//Only rotation of one screen supported
   101 	RWsSession session;
   102 	TInt err = session.Connect();
   103 	if (err!=KErrNone)
   104 		RDebug::Print(_L("Error connecting the session error = %d\n"),err);	
   105 
   106 	//Determine the screen dimensions
   107 	CWsScreenDevice* screenDevice = NULL;
   108 	TRAP(err,screenDevice = new(ELeave) CWsScreenDevice(session));
   109 	if (err!=KErrNone)
   110 		RDebug::Print(_L("Error creating screen device = %d\n"),err);	
   111 		
   112 	err = screenDevice->Construct(aScreenNo);
   113 	if (err!=KErrNone)
   114 		RDebug::Print(_L("Error constructing the screen device error = %d\n"),err);	
   115 
   116 	TSize aScreenSize = screenDevice->SizeInPixels();
   117 
   118 	//if screen dimensions have not changed (eg flipped) take no action
   119 	//Rotation only supported for full screen window and surface
   120 	if(iScreenSize != aScreenSize)
   121 		{
   122 		for(TInt i=0; i<iWindAndSurf->Count(); i++)
   123 			{
   124 			if( (*iWindAndSurf)[i]->RotationSupported() )
   125 				{
   126 				(*iWindAndSurf)[i]->RotateL(aScreenNo, i+1, aScreenSize, aFrameNumber);
   127 				}
   128 			else
   129 				{
   130 				RDebug::Print(_L("Rotation is not supported for this animation type"));
   131 				User::Panic(KTPseudoAppPanicTxt, KErrNotSupported);
   132 				}
   133 			}
   134 
   135 		iScreenSize = aScreenSize;
   136 		}
   137 	}
   138 
   139 void CTestScreen::ImportScreenConfigL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults,
   140 							const TDesC& aConfigFileName)
   141 	{
   142 	TInt screenWindowNumber;
   143 	TPtrC windowType;
   144 
   145 	TBuf<KMaxUiBitmapNameLength>	tempStore;
   146 	tempStore.Format(KScreenWindow, aScreenNo);
   147 
   148 	READ_INI1A(tempStore, number, screenWindowNumber, iUtils);
   149 	READ_INI1A(tempStore, popup_occurances, iPopupOccurances, iUtils);
   150 
   151 	tempStore.Format(KScreen, aScreenNo);
   152 	READ_INI2A(tempStore, rotation, True, False, iRotation, ETrue, EFalse, iUtils);
   153 
   154 	iWindAndSurf = new (ELeave) CArrayPtrFlat<CTestSurfacedWindow>(1);
   155 
   156 	for(TInt i=1; i<screenWindowNumber+1; i++)
   157 		{
   158 		RDebug::Print(_L("Creating surfaced window %d on screen %d\n"), i, aScreenNo);
   159 
   160 		iWindAndSurf->ExtendL() = CTestSurfacedWindow::NewL(aScreenNo, i, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName, iPseudoAppShared);
   161 
   162 		RDebug::Print(_L("Surfaced window %d on screen %d created\n"), i, aScreenNo);
   163 		}
   164 	}
   165 
   166 void CTestScreen::CreatePopupWindow()
   167 	{
   168 	RDebug::Print(_L("Starting App: %S"), &KScreenWindowPopupApp);
   169 
   170 	TInt createErr = iPopupProcess.Create(KScreenWindowPopupApp, KNullDesC);
   171 
   172 	if (createErr == KErrNone)
   173 		{
   174 		iPopupProcess.SetPriority(EPriorityForeground);
   175 		iPopupProcess.Resume();
   176 		}
   177 	}
   178 
   179 void CTestScreen::LaunchRotationApp()
   180 	{
   181 	RDebug::Print(_L("Starting App: %S"), &KScreenRotationApp);
   182 
   183 	TInt createErr = iRotationProcess.Create(KScreenRotationApp, KNullDesC);
   184 
   185 	if (createErr == KErrNone)
   186 		{
   187 		iRotationProcess.SetPriority(EPriorityForeground);
   188 		iRotationProcess.Resume();
   189 		}
   190 	}
   191 
   192 void CTestScreen::DestroyRotationApp()
   193 	{
   194 	if(iRotation)
   195 		{
   196 		iRotationProcess.Kill(KErrGeneral);
   197 		}
   198 	}
   199 
   200 void CTestScreen::DestroyPopupWindow()
   201 	{
   202 	iPopupProcess.Kill(KErrGeneral);
   203 	}
   204