1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/fontstore/tfs/t_cachedeletion.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,195 @@
1.4 +/*
1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +/**
1.23 + @file
1.24 + @test
1.25 + @internalComponent Internal Symbian test code
1.26 +*/
1.27 +
1.28 +#include "FNTSTORE.H"
1.29 +#include "OPENFONT.H"
1.30 +#include "FNTBODY.H"
1.31 +#include "FNTSTD.H"
1.32 +#include "t_cachedeletion.h"
1.33 +#include <hal.h>
1.34 +#include <s32file.h>
1.35 +#include <graphics/shapeimpl.h>
1.36 +
1.37 +_LIT(KSecondProcess,"tcachedeletionprocess");
1.38 +_LIT(KThirdProcess,"tcachedeletionprocess");
1.39 +
1.40 +class CTCacheDeletion : public CTGraphicsBase
1.41 + {
1.42 +public:
1.43 + CTCacheDeletion(CTestStep* aStep);
1.44 + ~CTCacheDeletion();
1.45 +protected:
1.46 +// From CTGraphicsStep
1.47 + virtual void RunTestCaseL(TInt aCurTestCase);
1.48 +private:
1.49 + void RunProcess2L();
1.50 + };
1.51 +
1.52 +CTCacheDeletion::CTCacheDeletion(CTestStep* aStep)
1.53 + : CTGraphicsBase(aStep)
1.54 + {
1.55 +
1.56 + }
1.57 +
1.58 +CTCacheDeletion::~CTCacheDeletion()
1.59 + {
1.60 + // no action needed
1.61 + }
1.62 +
1.63 +void TimerCleanup(TAny *aTimer)
1.64 + {
1.65 + ((RTimer*)aTimer)->Cancel();
1.66 + }
1.67 +
1.68 +/**
1.69 + @SYMTestCaseID
1.70 + GRAPHICS-FNTSTORE-0050
1.71 +
1.72 + @SYMTestCaseDesc
1.73 + Tests font and bitmap server disconnection (when a process finishes)
1.74 + at the same time a process is outputing.
1.75 +
1.76 + @SYMTestActions
1.77 + This function creates two processes. These processes are called
1.78 + process 3 and process 2. Process 3 is created, and run. There are
1.79 + parameters input to the process. The first is an indicator to the
1.80 + process of the instance (2 or 3) and the second is a timeout.
1.81 + Process3 runs continually, drawing text for the full timeout period.
1.82 + Process2 is created and allowed to finish in a loop in this function for
1.83 + the same timeout period, currently ten seconds.
1.84 +
1.85 + @SYMTestExpectedResults
1.86 + Test should pass
1.87 +*/
1.88 +void CTCacheDeletion::RunProcess2L()
1.89 + {
1.90 + TInt runForMicroSecs = 1000*1000*10;
1.91 +
1.92 + //create process 3
1.93 + RProcess process3;
1.94 + TInt err;
1.95 + err = process3.Create(KThirdProcess, KNullDesC);
1.96 + User::LeaveIfError(err);
1.97 + CleanupClosePushL(process3);
1.98 +
1.99 + //run process 3
1.100 + process3.SetParameter(1,1);
1.101 + process3.SetParameter(2,runForMicroSecs);
1.102 + TRequestStatus completeStatus3;
1.103 + process3.Logon(completeStatus3);
1.104 + TRequestStatus rendezvousStatus3;
1.105 + rendezvousStatus3=KRequestPending;
1.106 + process3.Rendezvous(rendezvousStatus3);
1.107 + process3.Resume(); //start the process
1.108 + User::WaitForRequest(rendezvousStatus3);
1.109 +
1.110 + //create a timer
1.111 + RTimer timer;
1.112 + timer.CreateLocal();
1.113 + TRequestStatus timerStatus=KRequestPending;
1.114 + TTimeIntervalMicroSeconds32 timeout(runForMicroSecs);
1.115 + timer.After(timerStatus, runForMicroSecs);
1.116 +
1.117 + TCleanupItem cleanup(TimerCleanup,&timer);
1.118 + CleanupStack::PushL(cleanup);
1.119 +
1.120 + do
1.121 + {
1.122 + //run process 2 in a loop
1.123 +
1.124 + //create process 2
1.125 + RProcess process2;
1.126 + TInt err = process2.Create(KSecondProcess, KNullDesC);
1.127 + User::LeaveIfError(err);
1.128 + CleanupClosePushL(process2);
1.129 +
1.130 + //start process 2
1.131 + process2.SetParameter(1,0);
1.132 + process2.SetParameter(2,runForMicroSecs);//not actually used
1.133 + TRequestStatus completeStatus2;
1.134 + process2.Logon(completeStatus2);
1.135 + TRequestStatus rendezvousStatus2;
1.136 + rendezvousStatus2=KRequestPending;
1.137 + process2.Rendezvous(rendezvousStatus2);
1.138 + process2.Resume(); //start the process
1.139 +
1.140 + //rendezvous with 2
1.141 + User::WaitForRequest(rendezvousStatus2);
1.142 + TInt status = rendezvousStatus2.Int();
1.143 + TEST(status ==1);
1.144 +
1.145 + //now let 2 finish
1.146 + User::WaitForRequest(completeStatus2);
1.147 + TExitType exit = process2.ExitType();
1.148 + TEST(exit == EExitKill);
1.149 + TInt reason = process2.ExitReason();
1.150 + TEST (reason == 0);
1.151 +
1.152 + CleanupStack::PopAndDestroy();
1.153 + }
1.154 + while (timerStatus==KRequestPending);
1.155 + timer.Cancel();
1.156 + CleanupStack::Pop();//timer
1.157 +
1.158 + //rendezvous with 3
1.159 + User::WaitForRequest(rendezvousStatus3);
1.160 + TInt status = rendezvousStatus3.Int();
1.161 + TEST(status ==10);
1.162 +
1.163 + //now let 3 finish
1.164 + User::WaitForRequest(completeStatus3);
1.165 + TExitType exit = process3.ExitType();
1.166 + TEST(exit == EExitKill);
1.167 + TInt reason = process3.ExitReason();
1.168 + TEST (reason == 0);
1.169 +
1.170 + CleanupStack::PopAndDestroy();//process 3
1.171 + }
1.172 +
1.173 +void CTCacheDeletion::RunTestCaseL( TInt aCurTestCase )
1.174 + {
1.175 +#if defined __WINS__ || defined __WINSCW__
1.176 + aCurTestCase = aCurTestCase; //to avoid unused warning
1.177 + TestComplete(); //only run test on hardware, always passes on winscw
1.178 + return;
1.179 +#endif
1.180 + ((CTCacheDeletionStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1.181 +
1.182 + switch ( aCurTestCase )
1.183 + {
1.184 + case 1:
1.185 + ((CTCacheDeletionStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0050"));
1.186 + RunProcess2L();
1.187 + break;
1.188 + case 2:
1.189 + ((CTCacheDeletionStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.190 + ((CTCacheDeletionStep*)iStep)->CloseTMSGraphicsStep();
1.191 + TestComplete();
1.192 + break;
1.193 + }
1.194 + ((CTCacheDeletionStep*)iStep)->RecordTestResultL();
1.195 + }
1.196 +
1.197 +// --------------
1.198 +__CONSTRUCT_STEP__(CacheDeletion)