sl@0: // Copyright (c) 2007-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: @file sl@0: @test sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include "t_pseudoappscreen.h" sl@0: #include "t_pseudoapputils.h" sl@0: #include "t_pseudoapptestresults.h" sl@0: #include "t_pseudoappeng.h" sl@0: sl@0: CTestScreen* CTestScreen::NewL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults, sl@0: const TDesC& aConfigFileName, CTPseudoAppShared& aPseudoAppShared) sl@0: { sl@0: RDebug::Print(_L("Creating CTestScreen class\n")); sl@0: CTestScreen* self = new (ELeave) CTestScreen(aPseudoAppShared); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName); sl@0: CleanupStack::Pop(); // self; sl@0: return self; sl@0: } sl@0: sl@0: void CTestScreen::ConstructL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults, sl@0: const TDesC& aConfigFileName) sl@0: { sl@0: RDebug::Print(_L("Constructing CTestScreen for screen %d\n"), aScreenNo); sl@0: sl@0: iPopupOccurances = 0; sl@0: iFrameDuration = aFrameDuration; sl@0: iScreenSize = aScreenSize; sl@0: sl@0: //Create CIniData class for reading in values form ini files sl@0: iUtils = CIniData::NewL(aConfigFileName); sl@0: sl@0: ImportScreenConfigL(aScreenNo, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName); sl@0: } sl@0: sl@0: CTestScreen::~CTestScreen() sl@0: { sl@0: if (iWindAndSurf) sl@0: { sl@0: iWindAndSurf->ResetAndDestroy(); sl@0: delete iWindAndSurf; sl@0: } sl@0: sl@0: delete iUtils; sl@0: } sl@0: sl@0: CTestScreen::CTestScreen(CTPseudoAppShared& aPseudoAppShared) sl@0: : iPseudoAppShared(aPseudoAppShared) sl@0: { sl@0: } sl@0: sl@0: EXPORT_C void CTestScreen::UpdateL(SurfaceDetails& aSurfDetails) sl@0: { sl@0: //Update all windowed surfaces changes sl@0: for(TInt index1=0; index1Count(); index1++) sl@0: { sl@0: (*iWindAndSurf)[index1]->UpdateL(aSurfDetails); sl@0: } sl@0: sl@0: //Launch popup window if configured by ini file sl@0: for(TInt index2=1; index2<(iPopupOccurances+1); index2++) sl@0: { sl@0: if(iFrameCounter == iFrameDuration/(2*iPopupOccurances*index2)) sl@0: { sl@0: CreatePopupWindow(); sl@0: } sl@0: else if(iFrameCounter == (iFrameDuration/(2*iPopupOccurances*index2) + iFrameDuration/(4*iPopupOccurances))) sl@0: { sl@0: DestroyPopupWindow(); sl@0: } sl@0: } sl@0: sl@0: iFrameCounter++; sl@0: } sl@0: sl@0: EXPORT_C TBool CTestScreen::Rotation() sl@0: { sl@0: return iRotation; sl@0: } sl@0: sl@0: EXPORT_C void CTestScreen::RotateL(TInt aScreenNo, TInt aFrameNumber) sl@0: { sl@0: //Only rotation of one screen supported sl@0: RWsSession session; sl@0: TInt err = session.Connect(); sl@0: if (err!=KErrNone) sl@0: RDebug::Print(_L("Error connecting the session error = %d\n"),err); sl@0: sl@0: //Determine the screen dimensions sl@0: CWsScreenDevice* screenDevice = NULL; sl@0: TRAP(err,screenDevice = new(ELeave) CWsScreenDevice(session)); sl@0: if (err!=KErrNone) sl@0: RDebug::Print(_L("Error creating screen device = %d\n"),err); sl@0: sl@0: err = screenDevice->Construct(aScreenNo); sl@0: if (err!=KErrNone) sl@0: RDebug::Print(_L("Error constructing the screen device error = %d\n"),err); sl@0: sl@0: TSize aScreenSize = screenDevice->SizeInPixels(); sl@0: sl@0: //if screen dimensions have not changed (eg flipped) take no action sl@0: //Rotation only supported for full screen window and surface sl@0: if(iScreenSize != aScreenSize) sl@0: { sl@0: for(TInt i=0; iCount(); i++) sl@0: { sl@0: if( (*iWindAndSurf)[i]->RotationSupported() ) sl@0: { sl@0: (*iWindAndSurf)[i]->RotateL(aScreenNo, i+1, aScreenSize, aFrameNumber); sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print(_L("Rotation is not supported for this animation type")); sl@0: User::Panic(KTPseudoAppPanicTxt, KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: iScreenSize = aScreenSize; sl@0: } sl@0: } sl@0: sl@0: void CTestScreen::ImportScreenConfigL(TInt aScreenNo, TDisplayMode aMode, TInt aFrameDuration, const TSize& aScreenSize, TGceTestResults* aGceTestResults, sl@0: const TDesC& aConfigFileName) sl@0: { sl@0: TInt screenWindowNumber; sl@0: TPtrC windowType; sl@0: sl@0: TBuf tempStore; sl@0: tempStore.Format(KScreenWindow, aScreenNo); sl@0: sl@0: READ_INI1A(tempStore, number, screenWindowNumber, iUtils); sl@0: READ_INI1A(tempStore, popup_occurances, iPopupOccurances, iUtils); sl@0: sl@0: tempStore.Format(KScreen, aScreenNo); sl@0: READ_INI2A(tempStore, rotation, True, False, iRotation, ETrue, EFalse, iUtils); sl@0: sl@0: iWindAndSurf = new (ELeave) CArrayPtrFlat(1); sl@0: sl@0: for(TInt i=1; iExtendL() = CTestSurfacedWindow::NewL(aScreenNo, i, aMode, aFrameDuration, aScreenSize, aGceTestResults, aConfigFileName, iPseudoAppShared); sl@0: sl@0: RDebug::Print(_L("Surfaced window %d on screen %d created\n"), i, aScreenNo); sl@0: } sl@0: } sl@0: sl@0: void CTestScreen::CreatePopupWindow() sl@0: { sl@0: RDebug::Print(_L("Starting App: %S"), &KScreenWindowPopupApp); sl@0: sl@0: TInt createErr = iPopupProcess.Create(KScreenWindowPopupApp, KNullDesC); sl@0: sl@0: if (createErr == KErrNone) sl@0: { sl@0: iPopupProcess.SetPriority(EPriorityForeground); sl@0: iPopupProcess.Resume(); sl@0: } sl@0: } sl@0: sl@0: void CTestScreen::LaunchRotationApp() sl@0: { sl@0: RDebug::Print(_L("Starting App: %S"), &KScreenRotationApp); sl@0: sl@0: TInt createErr = iRotationProcess.Create(KScreenRotationApp, KNullDesC); sl@0: sl@0: if (createErr == KErrNone) sl@0: { sl@0: iRotationProcess.SetPriority(EPriorityForeground); sl@0: iRotationProcess.Resume(); sl@0: } sl@0: } sl@0: sl@0: void CTestScreen::DestroyRotationApp() sl@0: { sl@0: if(iRotation) sl@0: { sl@0: iRotationProcess.Kill(KErrGeneral); sl@0: } sl@0: } sl@0: sl@0: void CTestScreen::DestroyPopupWindow() sl@0: { sl@0: iPopupProcess.Kill(KErrGeneral); sl@0: } sl@0: