1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicstest/graphicstestharness/src/TTMSGraphicsStep.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,205 @@
1.4 +// TTMSGraphicsStep.cpp
1.5 +// Copyright (c) 2006-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 +@file
1.22 +@test
1.23 +@internalComponent
1.24 +*/
1.25 +
1.26 +#include <bautils.h>
1.27 +#include <test/ttmsgraphicsstep.h>
1.28 +#include <f32file.h>
1.29 +#include <e32std.h>
1.30 +
1.31 +_LIT8(KLogPass,"PASS");
1.32 +_LIT8(KLogFail,"FAIL");
1.33 +
1.34 +
1.35 +void CTTMSGraphicsStep::CleanUpAndWriteResults()
1.36 + {
1.37 + TBuf<256> testID;
1.38 + TBuf<8> testResult;
1.39 +
1.40 + for (TInt iArrayIndex=0; iArrayIndex < iArrayTMSData.Count(); iArrayIndex++)
1.41 + {
1.42 + CTMSDataColumn columnData = iArrayTMSData[iArrayIndex];
1.43 +
1.44 + testID.Copy(columnData.iTheID);
1.45 + testResult.Copy(columnData.iTheResult);
1.46 +
1.47 + INFO_PRINTF2(_L("START_TESTCASE %S"),&testID);
1.48 + INFO_PRINTF2(_L("Line = 1 Command = START_TESTCASE %S"),&testID);
1.49 + INFO_PRINTF2(_L("END_TESTCASE %S"),&testID);
1.50 + INFO_PRINTF3(_L("Line = 1 Command = END_TESTCASE %S ***TestCaseResult = %S"),&testID,&testResult);
1.51 + }
1.52 +
1.53 + iArrayTMSData.Close();
1.54 + }
1.55 +
1.56 +EXPORT_C CTTMSGraphicsStep::CTTMSGraphicsStep() : iStepPassFail(ETrue), iShowMultipleResults(EFalse)
1.57 + {
1.58 + iCurrentTestStepName.Copy(KUnknownSYMTestCaseIDName);
1.59 + }
1.60 +
1.61 +EXPORT_C void CTTMSGraphicsStep::CloseTMSGraphicsStep()
1.62 + {
1.63 + CTTMSGraphicsStep::CleanUpAndWriteResults();
1.64 + }
1.65 +
1.66 +EXPORT_C CTTMSGraphicsStep::~CTTMSGraphicsStep()
1.67 + {
1.68 + CTTMSGraphicsStep::CleanUpAndWriteResults();
1.69 + }
1.70 +
1.71 +// writes out the results of a test that has just been executed to the log file(s)
1.72 +// the first time a test result is written it is also added to the iTestStepNames array.
1.73 +// This array is then checked on subsequent tests to see if the test has already been written to log
1.74 +// if it has and multiple test results are not wanted further logging of this test is omitted.
1.75 +
1.76 +
1.77 +void CTTMSGraphicsStep::DebugLogL(const TDesC8& aTestCaseID, const TDesC8& aResult)
1.78 + {
1.79 + TBool foundID = EFalse;
1.80 + if(!iShowMultipleResults)
1.81 + {
1.82 + for (TInt iArrayIndex=0; iArrayIndex < iArrayTMSData.Count(); iArrayIndex++)
1.83 + {
1.84 + CTMSDataColumn columnData = iArrayTMSData[iArrayIndex];
1.85 + if (columnData.iTheID.Compare(aTestCaseID)== 0)
1.86 + {
1.87 + if (columnData.iTheResult.Compare(KLogFail) != 0)
1.88 + {
1.89 + iArrayTMSData[iArrayIndex].iTheResult.Copy(aResult);
1.90 + }
1.91 + foundID = ETrue;
1.92 + iArrayIndex = iArrayTMSData.Count();
1.93 + }
1.94 + }
1.95 + }
1.96 +
1.97 + if (!foundID || iShowMultipleResults)
1.98 + {
1.99 + CTMSDataColumn theData;
1.100 + theData.iTheID.Copy(aTestCaseID);
1.101 + theData.iTheResult.Copy(aResult);
1.102 + iArrayTMSData.Append(theData);
1.103 + }
1.104 + }
1.105 +
1.106 +EXPORT_C void CTTMSGraphicsStep::RecordTestResultL()
1.107 + {
1.108 + TBuf<64> unknownTMSID(KUnknownSYMTestCaseIDName);
1.109 + TBuf8<64> unknownID8;
1.110 + unknownID8.Copy(unknownTMSID);
1.111 +
1.112 + TBuf<64> undefinedTMSID(KUndefinedSYMTestCaseIDName);
1.113 + TBuf8<64> undefinedID8;
1.114 + undefinedID8.Copy(undefinedTMSID);
1.115 +
1.116 + TBuf<64> notaTMSID(KNotATestSYMTestCaseIDName);
1.117 + TBuf8<64> notaID8;
1.118 + notaID8.Copy(notaTMSID);
1.119 +
1.120 + TBuf<128> currentTSName;
1.121 + currentTSName.Copy(iCurrentTestStepName);
1.122 +
1.123 + if (iCurrentTestStepName.Compare(unknownID8) == 0) // unknown tests logged to warning file
1.124 + {
1.125 + INFO_PRINTF1(_L("ID NOT SET"));
1.126 + }
1.127 + else if (iCurrentTestStepName.Compare(undefinedID8) == 0) // undefined tests logged to warning file
1.128 + {
1.129 + INFO_PRINTF1(_L("ID UNDEFINED"));
1.130 + }
1.131 + else if (iCurrentTestStepName.Compare(notaID8) == 0)
1.132 + {
1.133 + }
1.134 + else
1.135 + {
1.136 + if( iStepPassFail == EFalse)
1.137 + {
1.138 + INFO_PRINTF2(_L("%S FAILED"), ¤tTSName );
1.139 + DebugLogL(iCurrentTestStepName, KLogFail);
1.140 + }
1.141 + else
1.142 + {
1.143 + DebugLogL(iCurrentTestStepName, KLogPass);
1.144 + }
1.145 + }
1.146 + }
1.147 +
1.148 +// sets the name and pass/fail state of the individual test that is about to be executed
1.149 +EXPORT_C void CTTMSGraphicsStep::SetTestStepID(const TDesC& aStepName)
1.150 + {
1.151 + if(TestStepName() == KNullDesC)
1.152 + {
1.153 + SetTestStepName(aStepName);
1.154 + }
1.155 +
1.156 + iCurrentTestStepName.Copy(aStepName);
1.157 + iStepPassFail = ETrue;
1.158 + }
1.159 +
1.160 +EXPORT_C void CTTMSGraphicsStep::SetOverallTestStepID(const TDesC& aStepName)
1.161 + {
1.162 + iCurrentTestStepName.Copy(aStepName);
1.163 + iStepPassFail = ETrue;
1.164 + if (!TestStepResult() == EPass)
1.165 + TEST(EFalse);
1.166 + }
1.167 +
1.168 +// needed for the overide of CTGraphicsBase::testBooleanTrue to allow us to set
1.169 +// whether an individual test has passed or failed
1.170 +EXPORT_C void CTTMSGraphicsStep::MQCTest(TBool aCondition, const TText8* aFile, TInt aLine)
1.171 + {
1.172 + if(!aCondition)
1.173 + {
1.174 + iStepPassFail = EFalse;
1.175 + }
1.176 + testBooleanTrue( aCondition, aFile, aLine, ETrue);
1.177 + }
1.178 +
1.179 +// needed for the overide of CTGraphicsBase::testBooleanTrue to allow us to set
1.180 +// whether an individual test has passed or failed
1.181 +EXPORT_C void CTTMSGraphicsStep::MQCTestL(TBool aCondition, const TText8* aFile, TInt aLine)
1.182 + {
1.183 + if(!aCondition)
1.184 + {
1.185 + iStepPassFail = EFalse;
1.186 + }
1.187 + testBooleanTrueL( aCondition, aFile, aLine, ETrue);
1.188 + }
1.189 +
1.190 +// needed for the overide of CTGraphicsBase::testBooleanTrueWithErrorCode to allow us to set
1.191 +// whether an individual test has passed or failed. Also allows line and file of test failure
1.192 +// to be displayed.
1.193 +EXPORT_C void CTTMSGraphicsStep::MQCTestWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine)
1.194 + {
1.195 + if(!aCondition)
1.196 + {
1.197 + iStepPassFail = EFalse;
1.198 + SetTestStepResult(EFail);
1.199 + _LIT(KMessage,"Test Failed with error [%d]");
1.200 + Logger().LogExtra(aFile, aLine, ESevrErr, KMessage, aErrorCode);
1.201 + }
1.202 + }
1.203 +
1.204 +// sets whether tests with the same @SYMTestCaseID xxxxxx name are printed multiple times in the log files
1.205 +EXPORT_C void CTTMSGraphicsStep::MultipleResultsForSameID(TBool aShowMultipleResults)
1.206 + {
1.207 + iShowMultipleResults = aShowMultipleResults;
1.208 + }