sl@0: /* 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: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent Internal Symbian test code sl@0: */ sl@0: sl@0: #include "FNTSTORE.H" sl@0: #include "OPENFONT.H" sl@0: #include "FNTBODY.H" sl@0: #include "FNTSTD.H" sl@0: #include "t_cachedeletion.h" sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: _LIT(KSecondProcess,"tcachedeletionprocess"); sl@0: _LIT(KThirdProcess,"tcachedeletionprocess"); sl@0: sl@0: class CTCacheDeletion : public CTGraphicsBase sl@0: { sl@0: public: sl@0: CTCacheDeletion(CTestStep* aStep); sl@0: ~CTCacheDeletion(); sl@0: protected: sl@0: // From CTGraphicsStep sl@0: virtual void RunTestCaseL(TInt aCurTestCase); sl@0: private: sl@0: void RunProcess2L(); sl@0: }; sl@0: sl@0: CTCacheDeletion::CTCacheDeletion(CTestStep* aStep) sl@0: : CTGraphicsBase(aStep) sl@0: { sl@0: sl@0: } sl@0: sl@0: CTCacheDeletion::~CTCacheDeletion() sl@0: { sl@0: // no action needed sl@0: } sl@0: sl@0: void TimerCleanup(TAny *aTimer) sl@0: { sl@0: ((RTimer*)aTimer)->Cancel(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FNTSTORE-0050 sl@0: sl@0: @SYMTestCaseDesc sl@0: Tests font and bitmap server disconnection (when a process finishes) sl@0: at the same time a process is outputing. sl@0: sl@0: @SYMTestActions sl@0: This function creates two processes. These processes are called sl@0: process 3 and process 2. Process 3 is created, and run. There are sl@0: parameters input to the process. The first is an indicator to the sl@0: process of the instance (2 or 3) and the second is a timeout. sl@0: Process3 runs continually, drawing text for the full timeout period. sl@0: Process2 is created and allowed to finish in a loop in this function for sl@0: the same timeout period, currently ten seconds. sl@0: sl@0: @SYMTestExpectedResults sl@0: Test should pass sl@0: */ sl@0: void CTCacheDeletion::RunProcess2L() sl@0: { sl@0: TInt runForMicroSecs = 1000*1000*10; sl@0: sl@0: //create process 3 sl@0: RProcess process3; sl@0: TInt err; sl@0: err = process3.Create(KThirdProcess, KNullDesC); sl@0: User::LeaveIfError(err); sl@0: CleanupClosePushL(process3); sl@0: sl@0: //run process 3 sl@0: process3.SetParameter(1,1); sl@0: process3.SetParameter(2,runForMicroSecs); sl@0: TRequestStatus completeStatus3; sl@0: process3.Logon(completeStatus3); sl@0: TRequestStatus rendezvousStatus3; sl@0: rendezvousStatus3=KRequestPending; sl@0: process3.Rendezvous(rendezvousStatus3); sl@0: process3.Resume(); //start the process sl@0: User::WaitForRequest(rendezvousStatus3); sl@0: sl@0: //create a timer sl@0: RTimer timer; sl@0: timer.CreateLocal(); sl@0: TRequestStatus timerStatus=KRequestPending; sl@0: TTimeIntervalMicroSeconds32 timeout(runForMicroSecs); sl@0: timer.After(timerStatus, runForMicroSecs); sl@0: sl@0: TCleanupItem cleanup(TimerCleanup,&timer); sl@0: CleanupStack::PushL(cleanup); sl@0: sl@0: do sl@0: { sl@0: //run process 2 in a loop sl@0: sl@0: //create process 2 sl@0: RProcess process2; sl@0: TInt err = process2.Create(KSecondProcess, KNullDesC); sl@0: User::LeaveIfError(err); sl@0: CleanupClosePushL(process2); sl@0: sl@0: //start process 2 sl@0: process2.SetParameter(1,0); sl@0: process2.SetParameter(2,runForMicroSecs);//not actually used sl@0: TRequestStatus completeStatus2; sl@0: process2.Logon(completeStatus2); sl@0: TRequestStatus rendezvousStatus2; sl@0: rendezvousStatus2=KRequestPending; sl@0: process2.Rendezvous(rendezvousStatus2); sl@0: process2.Resume(); //start the process sl@0: sl@0: //rendezvous with 2 sl@0: User::WaitForRequest(rendezvousStatus2); sl@0: TInt status = rendezvousStatus2.Int(); sl@0: TEST(status ==1); sl@0: sl@0: //now let 2 finish sl@0: User::WaitForRequest(completeStatus2); sl@0: TExitType exit = process2.ExitType(); sl@0: TEST(exit == EExitKill); sl@0: TInt reason = process2.ExitReason(); sl@0: TEST (reason == 0); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: while (timerStatus==KRequestPending); sl@0: timer.Cancel(); sl@0: CleanupStack::Pop();//timer sl@0: sl@0: //rendezvous with 3 sl@0: User::WaitForRequest(rendezvousStatus3); sl@0: TInt status = rendezvousStatus3.Int(); sl@0: TEST(status ==10); sl@0: sl@0: //now let 3 finish sl@0: User::WaitForRequest(completeStatus3); sl@0: TExitType exit = process3.ExitType(); sl@0: TEST(exit == EExitKill); sl@0: TInt reason = process3.ExitReason(); sl@0: TEST (reason == 0); sl@0: sl@0: CleanupStack::PopAndDestroy();//process 3 sl@0: } sl@0: sl@0: void CTCacheDeletion::RunTestCaseL( TInt aCurTestCase ) sl@0: { sl@0: #if defined __WINS__ || defined __WINSCW__ sl@0: aCurTestCase = aCurTestCase; //to avoid unused warning sl@0: TestComplete(); //only run test on hardware, always passes on winscw sl@0: return; sl@0: #endif sl@0: ((CTCacheDeletionStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: sl@0: switch ( aCurTestCase ) sl@0: { sl@0: case 1: sl@0: ((CTCacheDeletionStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0050")); sl@0: RunProcess2L(); sl@0: break; sl@0: case 2: sl@0: ((CTCacheDeletionStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTCacheDeletionStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTCacheDeletionStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: // -------------- sl@0: __CONSTRUCT_STEP__(CacheDeletion)