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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #include "t_pseudoappscreen.h"
23 #include "t_pseudoapputils.h"
24 #include "t_pseudoapptestresults.h"
25 #include "t_pseudoappeng.h"
27 CTestScreen* CTestScreen::NewL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults,
28 const TDesC& aConfigFileName, CTPseudoAppShared& aPseudoAppShared)
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;
38 void CTestScreen::ConstructL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults,
39 const TDesC& aConfigFileName)
41 RDebug::Print(_L("Constructing CTestScreen for screen %d\n"), aScreenNo);
44 iFrameDuration = aFrameDuration;
45 iScreenSize = aScreenSize;
47 //Create CIniData class for reading in values form ini files
48 iUtils = CIniData::NewL(aConfigFileName);
50 ImportScreenConfigL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName);
53 CTestScreen::~CTestScreen()
57 iWindAndSurf->ResetAndDestroy();
64 CTestScreen::CTestScreen(CTPseudoAppShared& aPseudoAppShared)
65 : iPseudoAppShared(aPseudoAppShared)
69 EXPORT_C void CTestScreen::UpdateL(SurfaceDetails& aSurfDetails)
71 //Update all windowed surfaces changes
72 for(TInt index1=0; index1<iWindAndSurf->Count(); index1++)
74 (*iWindAndSurf)[index1]->UpdateL(aSurfDetails);
77 //Launch popup window if configured by ini file
78 for(TInt index2=1; index2<(iPopupOccurances+1); index2++)
80 if(iFrameCounter == iFrameDuration/(2*iPopupOccurances*index2))
84 else if(iFrameCounter == (iFrameDuration/(2*iPopupOccurances*index2) + iFrameDuration/(4*iPopupOccurances)))
93 EXPORT_C TBool CTestScreen::Rotation()
98 EXPORT_C void CTestScreen::RotateL(TInt aScreenNo, TInt aFrameNumber)
100 //Only rotation of one screen supported
102 TInt err = session.Connect();
104 RDebug::Print(_L("Error connecting the session error = %d\n"),err);
106 //Determine the screen dimensions
107 CWsScreenDevice* screenDevice = NULL;
108 TRAP(err,screenDevice = new(ELeave) CWsScreenDevice(session));
110 RDebug::Print(_L("Error creating screen device = %d\n"),err);
112 err = screenDevice->Construct(aScreenNo);
114 RDebug::Print(_L("Error constructing the screen device error = %d\n"),err);
116 TSize aScreenSize = screenDevice->SizeInPixels();
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)
122 for(TInt i=0; i<iWindAndSurf->Count(); i++)
124 if( (*iWindAndSurf)[i]->RotationSupported() )
126 (*iWindAndSurf)[i]->RotateL(aScreenNo, i+1, aScreenSize, aFrameNumber);
130 RDebug::Print(_L("Rotation is not supported for this animation type"));
131 User::Panic(KTPseudoAppPanicTxt, KErrNotSupported);
135 iScreenSize = aScreenSize;
139 void CTestScreen::ImportScreenConfigL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults,
140 const TDesC& aConfigFileName)
142 TInt screenWindowNumber;
145 TBuf<KMaxUiBitmapNameLength> tempStore;
146 tempStore.Format(KScreenWindow, aScreenNo);
148 READ_INI1A(tempStore, number, screenWindowNumber, iUtils);
149 READ_INI1A(tempStore, popup_occurances, iPopupOccurances, iUtils);
151 tempStore.Format(KScreen, aScreenNo);
152 READ_INI2A(tempStore, rotation, True, False, iRotation, ETrue, EFalse, iUtils);
154 iWindAndSurf = new (ELeave) CArrayPtrFlat<CTestSurfacedWindow>(1);
156 for(TInt i=1; i<screenWindowNumber+1; i++)
158 RDebug::Print(_L("Creating surfaced window %d on screen %d\n"), i, aScreenNo);
160 iWindAndSurf->ExtendL() = CTestSurfacedWindow::NewL(aScreenNo, i, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName, iPseudoAppShared);
162 RDebug::Print(_L("Surfaced window %d on screen %d created\n"), i, aScreenNo);
166 void CTestScreen::CreatePopupWindow()
168 RDebug::Print(_L("Starting App: %S"), &KScreenWindowPopupApp);
170 TInt createErr = iPopupProcess.Create(KScreenWindowPopupApp, KNullDesC);
172 if (createErr == KErrNone)
174 iPopupProcess.SetPriority(EPriorityForeground);
175 iPopupProcess.Resume();
179 void CTestScreen::LaunchRotationApp()
181 RDebug::Print(_L("Starting App: %S"), &KScreenRotationApp);
183 TInt createErr = iRotationProcess.Create(KScreenRotationApp, KNullDesC);
185 if (createErr == KErrNone)
187 iRotationProcess.SetPriority(EPriorityForeground);
188 iRotationProcess.Resume();
192 void CTestScreen::DestroyRotationApp()
196 iRotationProcess.Kill(KErrGeneral);
200 void CTestScreen::DestroyPopupWindow()
202 iPopupProcess.Kill(KErrGeneral);