os/graphics/egl/egltest/endpointtestsuite/automated/inc/remotetestbase.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/egl/egltest/endpointtestsuite/automated/inc/remotetestbase.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,210 @@
     1.4 +// Copyright (c) 2009-2010 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 +
    1.17 +/**
    1.18 + @file
    1.19 + @test
    1.20 + @internalComponent - Internal Symbian test code
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +#ifndef __REMOTETESTBASE_H__
    1.25 +#define __REMOTETESTBASE_H__
    1.26 +
    1.27 +
    1.28 +#include <e32base.h>
    1.29 +#include <e32msgqueue.h>
    1.30 +#include <test/tefexportconst.h>
    1.31 +#include "eglendpointwrap.h"
    1.32 +#include "egltest_commscommon.h"
    1.33 +
    1.34 +
    1.35 +class CRemoteTestStepBase;
    1.36 +class CRemoteTestEnv;
    1.37 +
    1.38 +
    1.39 +//Active object used to generate a timeout if worker thread takes too long.
    1.40 +class CTimeoutTimer : public CTimer
    1.41 +    {
    1.42 +public:
    1.43 +    static CTimeoutTimer* NewL(CRemoteTestEnv& aEnv, TInt aPriority);
    1.44 +    ~CTimeoutTimer();
    1.45 +
    1.46 +private:
    1.47 +    CTimeoutTimer(CRemoteTestEnv& aEnv, TInt aPriority);
    1.48 +    void ConstructL();
    1.49 +    void RunL();
    1.50 +
    1.51 +private:
    1.52 +    CRemoteTestEnv& iEnv;
    1.53 +    };
    1.54 +
    1.55 +
    1.56 +//Active object used to listen to the worker thread to see if it panics.
    1.57 +class CWorkerListener : public CActive
    1.58 +    {
    1.59 +public:
    1.60 +    static CWorkerListener* NewL(CRemoteTestEnv& aEnv, TInt aPriority);
    1.61 +    ~CWorkerListener();
    1.62 +    void Listen(RThread& aThread);
    1.63 +
    1.64 +private:
    1.65 +    CWorkerListener(CRemoteTestEnv& aEnv, TInt aPriority);
    1.66 +    void ConstructL();
    1.67 +    void RunL();
    1.68 +    void DoCancel();
    1.69 +
    1.70 +private:
    1.71 +    CRemoteTestEnv& iEnv;
    1.72 +    RThread* iThread;
    1.73 +    };
    1.74 +
    1.75 +
    1.76 +//Active object used to listen for test case completion from the worker thread.
    1.77 +class CTestCaseListener : public CActive
    1.78 +    {
    1.79 +public:
    1.80 +    static CTestCaseListener* NewL(CRemoteTestEnv& aEnv, TInt aPriority);
    1.81 +    ~CTestCaseListener();
    1.82 +    void Listen();
    1.83 +
    1.84 +private:
    1.85 +    CTestCaseListener(CRemoteTestEnv& aEnv, TInt aPriority);
    1.86 +    void ConstructL();
    1.87 +    void RunL();
    1.88 +    void DoCancel();
    1.89 +
    1.90 +private:
    1.91 +    CRemoteTestEnv& iEnv;
    1.92 +    };
    1.93 +
    1.94 +
    1.95 +//This class provides the remote test environment. CreateRemoteTestStepL()
    1.96 +//Should be edited to return an instance of a derived CRemoteTestStepBase
    1.97 +//class that corresponds with the passed in aTestUid.
    1.98 +class CRemoteTestEnv : public CActive
    1.99 +    {
   1.100 +public:
   1.101 +    static CRemoteTestEnv* NewL();
   1.102 +    virtual ~CRemoteTestEnv();
   1.103 +
   1.104 +    void StartReceivingCmds();
   1.105 +    CRemoteTestStepBase* CreateRemoteTestStepL(TTestUid aTestUid);
   1.106 +
   1.107 +    void SendResult(TRemoteTestVerdict aVerdict);
   1.108 +    void SendLog(const TDesC8& aFile, TInt aLine, TInt aSeverity, const TDesC& aMessage);
   1.109 +
   1.110 +    void TestCaseCompleted();
   1.111 +    void TestCaseTimedOut();
   1.112 +    void WorkerExitted();
   1.113 +
   1.114 +protected:
   1.115 +    CRemoteTestEnv();
   1.116 +    void ConstructL();
   1.117 +
   1.118 +private:
   1.119 +    void RunL();
   1.120 +    void DoCancel();
   1.121 +
   1.122 +    void ReceiveCmd();
   1.123 +    TBool SetupTestStep();
   1.124 +
   1.125 +    //These functions run in the context of the worker thread.
   1.126 +    void RunCurrentTestStepL();
   1.127 +    static TInt TestThreadEntryPoint(TAny* aSelf);
   1.128 +
   1.129 +    void DoEglHeapMark();
   1.130 +    void DoEglHeapCheck();
   1.131 +
   1.132 +private:
   1.133 +    RMsgQueue<TRemoteTestResult> iResultOutQueue;
   1.134 +    RMsgQueue<TRemoteTestParamsPacket> iParamsInQueue;
   1.135 +
   1.136 +    CRemoteTestStepBase* iCurTestStep;
   1.137 +    TRemoteTestParamsPacket iCurTestCaseParamsPacket;
   1.138 +    TRemoteTestVerdict iCurTestCaseVerdict;
   1.139 +    RThread iCurWorker;
   1.140 +
   1.141 +    TThreadId iSupervisorId;
   1.142 +    TRequestStatus iNotifyRunTestCase;
   1.143 +
   1.144 +    CTimeoutTimer* iTimeoutTimer;
   1.145 +    CWorkerListener* iWorkerListener;
   1.146 +    CTestCaseListener* iTestCaseListener;
   1.147 +    };
   1.148 +
   1.149 +
   1.150 +//This is the base class for all remote test steps. Derived classes should implement
   1.151 +//DoRemoteTestStepL(), and return the result of the test as a TVerdict.
   1.152 +class CRemoteTestStepBase : public CBase, public MLog
   1.153 +    {
   1.154 +public:
   1.155 +    virtual ~CRemoteTestStepBase();
   1.156 +
   1.157 +    virtual TRemoteTestVerdict DoStartRemoteTestStepL(const TRemoteTestParams& aMessageIn);
   1.158 +    virtual TRemoteTestVerdict DoRunRemoteTestCaseL(TInt aTestCase, const TRemoteTestParams& aMessageIn) = 0;
   1.159 +    virtual TRemoteTestVerdict DoEndRemoteTestStepL(const TRemoteTestParams& aMessageIn);
   1.160 +
   1.161 +    virtual TInt Timeout() const;
   1.162 +    
   1.163 +    void Log(const TText8* aFile, TInt aLine, TInt aSeverity, TRefByValue<const TDesC> aFmt, ...);
   1.164 +    const TEglEndpointWrap& EglEndpoint() const;
   1.165 +
   1.166 +    void EglStartL();
   1.167 +    void EglEndL();
   1.168 +
   1.169 +protected:
   1.170 +    CRemoteTestStepBase(TTestUid aUid);
   1.171 +
   1.172 +private:
   1.173 +    friend class CRemoteTestEnv;
   1.174 +    //Function called by CRemoteTestEnv.
   1.175 +    //It should NOT be called by a derived class during construction.
   1.176 +    void ConstructL(CRemoteTestEnv& aTestEnv);
   1.177 +
   1.178 +private:
   1.179 +    const TTestUid iUid;
   1.180 +    TInt iCurrentTestCase;
   1.181 +    CRemoteTestEnv* iTestEnv;
   1.182 +    TEglEndpointWrap iEndpoint;
   1.183 +    };
   1.184 +
   1.185 +
   1.186 +// Logger Macros - based on TEF but for use with CRemoteTestStepBase.
   1.187 +//The severity enumeration is from TEF.
   1.188 +#define REMOTE_INFO_PRINTF1(p1)                            Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
   1.189 +#define REMOTE_INFO_PRINTF2(p1, p2)                        Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
   1.190 +#define REMOTE_INFO_PRINTF3(p1, p2, p3)                    Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3))
   1.191 +#define REMOTE_INFO_PRINTF4(p1, p2, p3, p4)                Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4))
   1.192 +#define REMOTE_INFO_PRINTF5(p1, p2, p3, p4, p5)            Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5))
   1.193 +#define REMOTE_INFO_PRINTF6(p1, p2, p3, p4, p5, p6)        Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6))
   1.194 +#define REMOTE_INFO_PRINTF7(p1, p2, p3, p4, p5, p6, p7)    Log(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
   1.195 +
   1.196 +#define REMOTE_WARN_PRINTF1(p1)                            Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1))
   1.197 +#define REMOTE_WARN_PRINTF2(p1, p2)                        Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2))
   1.198 +#define REMOTE_WARN_PRINTF3(p1, p2, p3)                    Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3))
   1.199 +#define REMOTE_WARN_PRINTF4(p1, p2, p3, p4)                Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4))
   1.200 +#define REMOTE_WARN_PRINTF5(p1, p2, p3, p4, p5)            Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5))
   1.201 +#define REMOTE_WARN_PRINTF6(p1, p2, p3, p4, p5, p6)        Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6))
   1.202 +#define REMOTE_WARN_PRINTF7(p1, p2, p3, p4, p5, p6, p7)    Log(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
   1.203 +
   1.204 +#define REMOTE_ERR_PRINTF1(p1)                             Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1))
   1.205 +#define REMOTE_ERR_PRINTF2(p1, p2)                         Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2))
   1.206 +#define REMOTE_ERR_PRINTF3(p1, p2, p3)                     Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3))
   1.207 +#define REMOTE_ERR_PRINTF4(p1, p2, p3, p4)                 Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4))
   1.208 +#define REMOTE_ERR_PRINTF5(p1, p2, p3, p4, p5)             Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5))
   1.209 +#define REMOTE_ERR_PRINTF6(p1, p2, p3, p4, p5, p6)         Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6))
   1.210 +#define REMOTE_ERR_PRINTF7(p1, p2, p3, p4, p5, p6, p7)     Log(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
   1.211 +
   1.212 +
   1.213 +#endif