egl/egltest/endpointtestsuite/automated/inc/egltest_commscommon.h
changeset 98 bf7481649c98
child 136 62bb7c97884c
equal deleted inserted replaced
85:cdf2f6e5c390 98:bf7481649c98
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 
       
    13 
       
    14 /**
       
    15  @file
       
    16  @test
       
    17  @internalComponent - Internal Symbian test code
       
    18 */
       
    19 
       
    20 
       
    21 /*
       
    22  * To add a new message that can be passed over the message queue:
       
    23  * 1. Add the test name to the TTestUid enum.
       
    24  * 2. Create a T class to hold the params.
       
    25  * 3. Add the T class to the TRemoteTestParams union.
       
    26  *
       
    27  * These steps are described in more detail below, where the
       
    28  * individual bits should be added.
       
    29  */
       
    30 
       
    31 
       
    32 #ifndef __EGLTEST_COMMSCOMMON_H__
       
    33 #define __EGLTEST_COMMSCOMMON_H__
       
    34 
       
    35 
       
    36 #include <e32base.h>
       
    37 #include <graphics/surface.h>
       
    38 #include <EGL/egl.h>
       
    39 #include "log.h"
       
    40 #include "egltest_endpoint_engine_types.h"
       
    41 
       
    42 #define ENDPOINT_ASSERT_DEBUG(x, y) do { if (!x) { RDebug::Printf("Assertion (%s) failed: %s:%d ", #x, __FILE__, __LINE__); y; } } while(0)
       
    43 
       
    44 //The maximum size of a message in an async message queue is 256 bytes.
       
    45 //If these valuses are increased, the maximum size will be exceeded.
       
    46 const TInt KRSLogMessageLength = 172;
       
    47 const TInt KRSLogFileLength = 32;
       
    48 
       
    49 
       
    50 //Names for the Async message queues that are used for
       
    51 //communication between the TEF driver app and the test
       
    52 //thread within window server.
       
    53 _LIT(KResultQueueName, "RemoteTestEnvResultQueue");
       
    54 _LIT(KParamsQueueName, "RemoteTestEnvParamsQueue");
       
    55 
       
    56 const TInt KStartTestStepCaseNumber = -1;
       
    57 const TInt KEndTestStepCaseNumber = -2;
       
    58 
       
    59 //Uids for all of the tests that the test thread knows about.
       
    60 enum TTestUid
       
    61     {
       
    62     //Endpoint Api Exposure Test.
       
    63     ETestUidEndpointApiExposure,
       
    64 
       
    65     // Common UID for engine code.
       
    66     ETestUidEndpointEngine,
       
    67 
       
    68     // Endpoint Lifetime test.
       
    69     ETestUidEndpointLifetime,
       
    70 
       
    71     //Image Tearing Test.
       
    72     ETestUidEndpointTearing,
       
    73     };
       
    74 
       
    75 
       
    76 //Each test should have a struct with data members to hold
       
    77 //the test's parameters. The name name should begin
       
    78 //"TTest..." and should contain no member functions.
       
    79 //(c-style struct).
       
    80 
       
    81 //If it is found that many tests use the same params, we should
       
    82 //create a TTestGeneric class to hold the params and derive
       
    83 //classes from it.
       
    84 
       
    85 struct TTestEndpointApiExposure
       
    86     {
       
    87     };
       
    88 
       
    89 struct TTestEndpointTearing
       
    90     {
       
    91     TSurfaceId iSurfaceId;
       
    92     };
       
    93 
       
    94 
       
    95 //Union for all of the structs that tests use to pass
       
    96 //params between the local side and the remote side.
       
    97 union TRemoteTestParams
       
    98     {
       
    99     //Endpoint Api Exposure Test.
       
   100     TTestEndpointApiExposure iTestEndpointApiExposure;
       
   101 
       
   102     //Endpoint engine data.
       
   103     TTestEndpointEngine iEndpointEngine;
       
   104 
       
   105     //Image Tearing Test.
       
   106     TTestEndpointTearing iEndpointTearing;
       
   107     };
       
   108 
       
   109 
       
   110 //Structure that is passed from local side to remote side
       
   111 //in the async message queue. It contains the test Uid,
       
   112 //test case and the params.
       
   113 class TRemoteTestParamsPacket
       
   114     {
       
   115 public:
       
   116     TRemoteTestParamsPacket();
       
   117     TRemoteTestParamsPacket(TTestUid aTestUid, TInt aTestCase, const TRemoteTestParams& aParams);
       
   118     const TTestUid iUid;
       
   119     const TInt iTestCase;
       
   120     const TRemoteTestParams iParams;
       
   121     };
       
   122 
       
   123 
       
   124 //The object passed back to the TEF driver app from the test
       
   125 //thread. It can be used for sending the resuult of a test and
       
   126 //for logging.
       
   127 class TRemoteTestResult
       
   128     {
       
   129 public:
       
   130     TRemoteTestResult();
       
   131 
       
   132     //Constructor for sending logging info.
       
   133     TRemoteTestResult(TTestUid aUid, TInt aTestCase, const TDesC8& aFile, TInt aLine, TInt aSeverity, const TDesC& aMessage);
       
   134 
       
   135     //Constructor for sending result info.
       
   136     TRemoteTestResult(TTestUid aUid, TInt aTestCase, TRemoteTestVerdict aVerdict);
       
   137 
       
   138 public:
       
   139     //If EFalse this is a logging message, else a result message.
       
   140     TBool iFinished;
       
   141     TTestUid iUid;
       
   142     TInt iTestCase;
       
   143 
       
   144     //Result message.
       
   145     TRemoteTestVerdict iVerdict;
       
   146 
       
   147     //Logging message.
       
   148     TBuf8<KRSLogFileLength> iFile;
       
   149     TInt iLine;
       
   150     TInt iSeverity;
       
   151     TBuf8<KRSLogMessageLength> iMessage;
       
   152     };
       
   153 
       
   154 
       
   155 //Inline functions --------------------------------------------------------
       
   156 
       
   157 inline TRemoteTestParamsPacket::TRemoteTestParamsPacket() :
       
   158     iUid((TTestUid)0),
       
   159     iTestCase(0),
       
   160     iParams(TRemoteTestParams())
       
   161     {
       
   162     }
       
   163 
       
   164 
       
   165 inline TRemoteTestParamsPacket::TRemoteTestParamsPacket(TTestUid aTestUid, TInt aTestCase, const TRemoteTestParams& aParams) :
       
   166     iUid(aTestUid),
       
   167     iTestCase(aTestCase),
       
   168     iParams(aParams)
       
   169     {
       
   170     }
       
   171 
       
   172 
       
   173 inline TRemoteTestResult::TRemoteTestResult()
       
   174     {
       
   175     }
       
   176 
       
   177 
       
   178 inline TRemoteTestResult::TRemoteTestResult(TTestUid aUid, TInt aTestCase, const TDesC8& aFile, TInt aLine, TInt aSeverity, const TDesC& aMessage) :
       
   179     iFinished(EFalse),
       
   180     iVerdict(ERtvInconclusive),
       
   181     iUid(aUid),
       
   182     iTestCase(aTestCase),
       
   183     iLine(aLine),
       
   184     iSeverity(aSeverity)
       
   185     {
       
   186     //Copy the filename to the log object. If the string is too long,
       
   187     //truncate the string and append an elipsis to the log.
       
   188     //The "-1"s ensure that a free char is left for appending a NULL (in the TEF app).
       
   189     TBool truncate = iFile.MaxLength()-1 < aFile.Length();
       
   190     TInt numChars = truncate ? iFile.MaxLength()-3-1 : aFile.Length();
       
   191     iFile = aFile.Left(numChars);
       
   192     if(truncate)
       
   193         {
       
   194         iFile.Append(_L("..."));
       
   195         }
       
   196 
       
   197     //Copy the message to the log object. If the string is too long,
       
   198     //truncate the string and append an elipsis to the log.
       
   199     //Note we convert message from unicode to ascii to conserve space in the message queue.
       
   200     truncate = iMessage.MaxLength() < aMessage.Length();
       
   201     numChars = truncate ? iMessage.MaxLength()-3 : aMessage.Length();
       
   202     iMessage.Copy(aMessage.Left(numChars));
       
   203     if(truncate)
       
   204         {
       
   205         iMessage.Append(_L8("..."));
       
   206         }
       
   207     }
       
   208 
       
   209 
       
   210 inline TRemoteTestResult::TRemoteTestResult(TTestUid aUid, TInt aTestCase, TRemoteTestVerdict aVerdict) :
       
   211     iFinished(ETrue),
       
   212     iUid(aUid),
       
   213     iTestCase(aTestCase),
       
   214     iVerdict(aVerdict)
       
   215     {
       
   216     }
       
   217 
       
   218 //------------------------------------------------------------------------------------
       
   219 
       
   220 
       
   221 #endif