1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/t_integ/src/t_pseudoappscreen.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,204 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @test
1.22 + @internalComponent
1.23 +*/
1.24 +
1.25 +#include "t_pseudoappscreen.h"
1.26 +#include "t_pseudoapputils.h"
1.27 +#include "t_pseudoapptestresults.h"
1.28 +#include "t_pseudoappeng.h"
1.29 +
1.30 +CTestScreen* CTestScreen::NewL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults,
1.31 + const TDesC& aConfigFileName, CTPseudoAppShared& aPseudoAppShared)
1.32 + {
1.33 + RDebug::Print(_L("Creating CTestScreen class\n"));
1.34 + CTestScreen* self = new (ELeave) CTestScreen(aPseudoAppShared);
1.35 + CleanupStack::PushL(self);
1.36 + self->ConstructL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName);
1.37 + CleanupStack::Pop(); // self;
1.38 + return self;
1.39 + }
1.40 +
1.41 +void CTestScreen::ConstructL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults,
1.42 + const TDesC& aConfigFileName)
1.43 + {
1.44 + RDebug::Print(_L("Constructing CTestScreen for screen %d\n"), aScreenNo);
1.45 +
1.46 + iPopupOccurances = 0;
1.47 + iFrameDuration = aFrameDuration;
1.48 + iScreenSize = aScreenSize;
1.49 +
1.50 + //Create CIniData class for reading in values form ini files
1.51 + iUtils = CIniData::NewL(aConfigFileName);
1.52 +
1.53 + ImportScreenConfigL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName);
1.54 + }
1.55 +
1.56 +CTestScreen::~CTestScreen()
1.57 + {
1.58 + if (iWindAndSurf)
1.59 + {
1.60 + iWindAndSurf->ResetAndDestroy();
1.61 + delete iWindAndSurf;
1.62 + }
1.63 +
1.64 + delete iUtils;
1.65 + }
1.66 +
1.67 +CTestScreen::CTestScreen(CTPseudoAppShared& aPseudoAppShared)
1.68 +: iPseudoAppShared(aPseudoAppShared)
1.69 + {
1.70 + }
1.71 +
1.72 +EXPORT_C void CTestScreen::UpdateL(SurfaceDetails& aSurfDetails)
1.73 + {
1.74 + //Update all windowed surfaces changes
1.75 + for(TInt index1=0; index1<iWindAndSurf->Count(); index1++)
1.76 + {
1.77 + (*iWindAndSurf)[index1]->UpdateL(aSurfDetails);
1.78 + }
1.79 +
1.80 + //Launch popup window if configured by ini file
1.81 + for(TInt index2=1; index2<(iPopupOccurances+1); index2++)
1.82 + {
1.83 + if(iFrameCounter == iFrameDuration/(2*iPopupOccurances*index2))
1.84 + {
1.85 + CreatePopupWindow();
1.86 + }
1.87 + else if(iFrameCounter == (iFrameDuration/(2*iPopupOccurances*index2) + iFrameDuration/(4*iPopupOccurances)))
1.88 + {
1.89 + DestroyPopupWindow();
1.90 + }
1.91 + }
1.92 +
1.93 + iFrameCounter++;
1.94 + }
1.95 +
1.96 +EXPORT_C TBool CTestScreen::Rotation()
1.97 + {
1.98 + return iRotation;
1.99 + }
1.100 +
1.101 +EXPORT_C void CTestScreen::RotateL(TInt aScreenNo, TInt aFrameNumber)
1.102 + {
1.103 + //Only rotation of one screen supported
1.104 + RWsSession session;
1.105 + TInt err = session.Connect();
1.106 + if (err!=KErrNone)
1.107 + RDebug::Print(_L("Error connecting the session error = %d\n"),err);
1.108 +
1.109 + //Determine the screen dimensions
1.110 + CWsScreenDevice* screenDevice = NULL;
1.111 + TRAP(err,screenDevice = new(ELeave) CWsScreenDevice(session));
1.112 + if (err!=KErrNone)
1.113 + RDebug::Print(_L("Error creating screen device = %d\n"),err);
1.114 +
1.115 + err = screenDevice->Construct(aScreenNo);
1.116 + if (err!=KErrNone)
1.117 + RDebug::Print(_L("Error constructing the screen device error = %d\n"),err);
1.118 +
1.119 + TSize aScreenSize = screenDevice->SizeInPixels();
1.120 +
1.121 + //if screen dimensions have not changed (eg flipped) take no action
1.122 + //Rotation only supported for full screen window and surface
1.123 + if(iScreenSize != aScreenSize)
1.124 + {
1.125 + for(TInt i=0; i<iWindAndSurf->Count(); i++)
1.126 + {
1.127 + if( (*iWindAndSurf)[i]->RotationSupported() )
1.128 + {
1.129 + (*iWindAndSurf)[i]->RotateL(aScreenNo, i+1, aScreenSize, aFrameNumber);
1.130 + }
1.131 + else
1.132 + {
1.133 + RDebug::Print(_L("Rotation is not supported for this animation type"));
1.134 + User::Panic(KTPseudoAppPanicTxt, KErrNotSupported);
1.135 + }
1.136 + }
1.137 +
1.138 + iScreenSize = aScreenSize;
1.139 + }
1.140 + }
1.141 +
1.142 +void CTestScreen::ImportScreenConfigL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults,
1.143 + const TDesC& aConfigFileName)
1.144 + {
1.145 + TInt screenWindowNumber;
1.146 + TPtrC windowType;
1.147 +
1.148 + TBuf<KMaxUiBitmapNameLength> tempStore;
1.149 + tempStore.Format(KScreenWindow, aScreenNo);
1.150 +
1.151 + READ_INI1A(tempStore, number, screenWindowNumber, iUtils);
1.152 + READ_INI1A(tempStore, popup_occurances, iPopupOccurances, iUtils);
1.153 +
1.154 + tempStore.Format(KScreen, aScreenNo);
1.155 + READ_INI2A(tempStore, rotation, True, False, iRotation, ETrue, EFalse, iUtils);
1.156 +
1.157 + iWindAndSurf = new (ELeave) CArrayPtrFlat<CTestSurfacedWindow>(1);
1.158 +
1.159 + for(TInt i=1; i<screenWindowNumber+1; i++)
1.160 + {
1.161 + RDebug::Print(_L("Creating surfaced window %d on screen %d\n"), i, aScreenNo);
1.162 +
1.163 + iWindAndSurf->ExtendL() = CTestSurfacedWindow::NewL(aScreenNo, i, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName, iPseudoAppShared);
1.164 +
1.165 + RDebug::Print(_L("Surfaced window %d on screen %d created\n"), i, aScreenNo);
1.166 + }
1.167 + }
1.168 +
1.169 +void CTestScreen::CreatePopupWindow()
1.170 + {
1.171 + RDebug::Print(_L("Starting App: %S"), &KScreenWindowPopupApp);
1.172 +
1.173 + TInt createErr = iPopupProcess.Create(KScreenWindowPopupApp, KNullDesC);
1.174 +
1.175 + if (createErr == KErrNone)
1.176 + {
1.177 + iPopupProcess.SetPriority(EPriorityForeground);
1.178 + iPopupProcess.Resume();
1.179 + }
1.180 + }
1.181 +
1.182 +void CTestScreen::LaunchRotationApp()
1.183 + {
1.184 + RDebug::Print(_L("Starting App: %S"), &KScreenRotationApp);
1.185 +
1.186 + TInt createErr = iRotationProcess.Create(KScreenRotationApp, KNullDesC);
1.187 +
1.188 + if (createErr == KErrNone)
1.189 + {
1.190 + iRotationProcess.SetPriority(EPriorityForeground);
1.191 + iRotationProcess.Resume();
1.192 + }
1.193 + }
1.194 +
1.195 +void CTestScreen::DestroyRotationApp()
1.196 + {
1.197 + if(iRotation)
1.198 + {
1.199 + iRotationProcess.Kill(KErrGeneral);
1.200 + }
1.201 + }
1.202 +
1.203 +void CTestScreen::DestroyPopupWindow()
1.204 + {
1.205 + iPopupProcess.Kill(KErrGeneral);
1.206 + }
1.207 +