os/graphics/egl/egltest/endpointtestsuite/automated/inc/egltest_commscommon.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/egltest_commscommon.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,249 @@
     1.4 +// Copyright (c) 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 +
    1.17 +/**
    1.18 + @file
    1.19 + @test
    1.20 + @internalComponent - Internal Symbian test code
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +/*
    1.25 + * To add a new message that can be passed over the message queue:
    1.26 + * 1. Add the test name to the TTestUid enum.
    1.27 + * 2. Create a T class to hold the params.
    1.28 + * 3. Add the T class to the TRemoteTestParams union.
    1.29 + *
    1.30 + * These steps are described in more detail below, where the
    1.31 + * individual bits should be added.
    1.32 + */
    1.33 +
    1.34 +
    1.35 +#ifndef __EGLTEST_COMMSCOMMON_H__
    1.36 +#define __EGLTEST_COMMSCOMMON_H__
    1.37 +
    1.38 +
    1.39 +#include <e32base.h>
    1.40 +#include <graphics/surface.h>
    1.41 +#include <EGL/egl.h>
    1.42 +#include "log.h"
    1.43 +#include "egltest_endpoint_engine_types.h"
    1.44 +
    1.45 +#define ENDPOINT_ASSERT_DEBUG(x, y) do { if (!x) { RDebug::Printf("Assertion (%s) failed: %s:%d ", #x, __FILE__, __LINE__); y; } } while(0)
    1.46 +
    1.47 +//The maximum size of a message in an async message queue is 256 bytes.
    1.48 +//If these valuses are increased, the maximum size will be exceeded.
    1.49 +const TInt KRSLogMessageLength = 172;
    1.50 +const TInt KRSLogFileLength = 32;
    1.51 +
    1.52 +
    1.53 +//Names for the Async message queues that are used for
    1.54 +//communication between the TEF driver app and the test
    1.55 +//thread within window server.
    1.56 +_LIT(KResultQueueName, "RemoteTestEnvResultQueue");
    1.57 +_LIT(KParamsQueueName, "RemoteTestEnvParamsQueue");
    1.58 +
    1.59 +const TInt KStartTestStepCaseNumber = -1;
    1.60 +const TInt KEndTestStepCaseNumber = -2;
    1.61 +
    1.62 +//Uids for all of the tests that the test thread knows about.
    1.63 +enum TTestUid
    1.64 +    {
    1.65 +    //Endpoint Api Exposure Test.
    1.66 +    ETestUidEndpointApiExposure,
    1.67 +
    1.68 +    // Common UID for engine code.
    1.69 +    ETestUidEndpointEngine,
    1.70 +
    1.71 +    // Endpoint Lifetime test.
    1.72 +    ETestUidEndpointLifetime,
    1.73 +
    1.74 +    //Image Tearing Test.
    1.75 +    ETestUidEndpointTearing,
    1.76 +    
    1.77 +    //Multithreaded stress tests.
    1.78 +    ETestUidEndpointThreadStress,
    1.79 +    
    1.80 +    //Release Image with Gles context tests.
    1.81 +    ETestUidEndpointReleaseImageGles,
    1.82 +    
    1.83 +    // vgThreading test.
    1.84 +    ETestUidVgThreading,
    1.85 +    };
    1.86 +
    1.87 +
    1.88 +//Each test should have a struct with data members to hold
    1.89 +//the test's parameters. The name name should begin
    1.90 +//"TTest..." and should contain no member functions.
    1.91 +//(c-style struct).
    1.92 +
    1.93 +//If it is found that many tests use the same params, we should
    1.94 +//create a TTestGeneric class to hold the params and derive
    1.95 +//classes from it.
    1.96 +
    1.97 +struct TTestEndpointApiExposure
    1.98 +    {
    1.99 +    };
   1.100 +
   1.101 +struct TTestEndpointTearing
   1.102 +    {
   1.103 +    TSurfaceId iSurfaceId;
   1.104 +    };
   1.105 +
   1.106 +struct TTestEndpointThreadStress
   1.107 +    {
   1.108 +    TInt iNumThreads;
   1.109 +    };
   1.110 +
   1.111 +struct TTestEndpointReleaseImageGles
   1.112 +    {
   1.113 +    TBool iUseValidGlesContext;
   1.114 +    };
   1.115 +
   1.116 +
   1.117 +//Union for all of the structs that tests use to pass
   1.118 +//params between the local side and the remote side.
   1.119 +union TRemoteTestParams
   1.120 +    {
   1.121 +    //Endpoint Api Exposure Test.
   1.122 +    TTestEndpointApiExposure iTestEndpointApiExposure;
   1.123 +
   1.124 +    //Endpoint engine data.
   1.125 +    TTestEndpointEngine iEndpointEngine;
   1.126 +    
   1.127 +    // Endpoint Engine configuration data.
   1.128 +    TTestEndpointEngineConfig iEndpointEngineConfig;
   1.129 +
   1.130 +    //Image Tearing Test.
   1.131 +    TTestEndpointTearing iEndpointTearing;
   1.132 +    
   1.133 +    //Multithreaded stress tests.
   1.134 +    TTestEndpointThreadStress iEndpointThreadStress;
   1.135 +    
   1.136 +    //Release Image with Gles context tests.
   1.137 +    TTestEndpointReleaseImageGles iEndpointReleaseImageGles;
   1.138 +    };
   1.139 +
   1.140 +
   1.141 +//Structure that is passed from local side to remote side
   1.142 +//in the async message queue. It contains the test Uid,
   1.143 +//test case and the params.
   1.144 +class TRemoteTestParamsPacket
   1.145 +    {
   1.146 +public:
   1.147 +    TRemoteTestParamsPacket();
   1.148 +    TRemoteTestParamsPacket(TTestUid aTestUid, TInt aTestCase, const TRemoteTestParams& aParams);
   1.149 +    const TTestUid iUid;
   1.150 +    const TInt iTestCase;
   1.151 +    const TRemoteTestParams iParams;
   1.152 +    };
   1.153 +
   1.154 +
   1.155 +//The object passed back to the TEF driver app from the test
   1.156 +//thread. It can be used for sending the resuult of a test and
   1.157 +//for logging.
   1.158 +class TRemoteTestResult
   1.159 +    {
   1.160 +public:
   1.161 +    TRemoteTestResult();
   1.162 +
   1.163 +    //Constructor for sending logging info.
   1.164 +    TRemoteTestResult(TTestUid aUid, TInt aTestCase, const TDesC8& aFile, TInt aLine, TInt aSeverity, const TDesC& aMessage);
   1.165 +
   1.166 +    //Constructor for sending result info.
   1.167 +    TRemoteTestResult(TTestUid aUid, TInt aTestCase, TRemoteTestVerdict aVerdict);
   1.168 +
   1.169 +public:
   1.170 +    //If EFalse this is a logging message, else a result message.
   1.171 +    TBool iFinished;
   1.172 +    TTestUid iUid;
   1.173 +    TInt iTestCase;
   1.174 +
   1.175 +    //Result message.
   1.176 +    TRemoteTestVerdict iVerdict;
   1.177 +
   1.178 +    //Logging message.
   1.179 +    TBuf8<KRSLogFileLength> iFile;
   1.180 +    TInt iLine;
   1.181 +    TInt iSeverity;
   1.182 +    TBuf8<KRSLogMessageLength> iMessage;
   1.183 +    };
   1.184 +
   1.185 +
   1.186 +//Inline functions --------------------------------------------------------
   1.187 +
   1.188 +inline TRemoteTestParamsPacket::TRemoteTestParamsPacket() :
   1.189 +    iUid((TTestUid)0),
   1.190 +    iTestCase(0),
   1.191 +    iParams(TRemoteTestParams())
   1.192 +    {
   1.193 +    }
   1.194 +
   1.195 +
   1.196 +inline TRemoteTestParamsPacket::TRemoteTestParamsPacket(TTestUid aTestUid, TInt aTestCase, const TRemoteTestParams& aParams) :
   1.197 +    iUid(aTestUid),
   1.198 +    iTestCase(aTestCase),
   1.199 +    iParams(aParams)
   1.200 +    {
   1.201 +    }
   1.202 +
   1.203 +
   1.204 +inline TRemoteTestResult::TRemoteTestResult()
   1.205 +    {
   1.206 +    }
   1.207 +
   1.208 +
   1.209 +inline TRemoteTestResult::TRemoteTestResult(TTestUid aUid, TInt aTestCase, const TDesC8& aFile, TInt aLine, TInt aSeverity, const TDesC& aMessage) :
   1.210 +    iFinished(EFalse),
   1.211 +    iVerdict(ERtvInconclusive),
   1.212 +    iUid(aUid),
   1.213 +    iTestCase(aTestCase),
   1.214 +    iLine(aLine),
   1.215 +    iSeverity(aSeverity)
   1.216 +    {
   1.217 +    //Copy the filename to the log object. If the string is too long,
   1.218 +    //truncate the string and append an elipsis to the log.
   1.219 +    //The "-1"s ensure that a free char is left for appending a NULL (in the TEF app).
   1.220 +    TBool truncate = iFile.MaxLength()-1 < aFile.Length();
   1.221 +    TInt numChars = truncate ? iFile.MaxLength()-3-1 : aFile.Length();
   1.222 +    iFile = aFile.Left(numChars);
   1.223 +    if(truncate)
   1.224 +        {
   1.225 +        iFile.Append(_L("..."));
   1.226 +        }
   1.227 +
   1.228 +    //Copy the message to the log object. If the string is too long,
   1.229 +    //truncate the string and append an elipsis to the log.
   1.230 +    //Note we convert message from unicode to ascii to conserve space in the message queue.
   1.231 +    truncate = iMessage.MaxLength() < aMessage.Length();
   1.232 +    numChars = truncate ? iMessage.MaxLength()-3 : aMessage.Length();
   1.233 +    iMessage.Copy(aMessage.Left(numChars));
   1.234 +    if(truncate)
   1.235 +        {
   1.236 +        iMessage.Append(_L8("..."));
   1.237 +        }
   1.238 +    }
   1.239 +
   1.240 +
   1.241 +inline TRemoteTestResult::TRemoteTestResult(TTestUid aUid, TInt aTestCase, TRemoteTestVerdict aVerdict) :
   1.242 +    iFinished(ETrue),
   1.243 +    iUid(aUid),
   1.244 +    iTestCase(aTestCase),
   1.245 +    iVerdict(aVerdict)
   1.246 +    {
   1.247 +    }
   1.248 +
   1.249 +//------------------------------------------------------------------------------------
   1.250 +
   1.251 +
   1.252 +#endif