sl@0: // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef TFBSBASE_H sl@0: #define TFBSBASE_H sl@0: sl@0: #include "test/TGraphicsHarness.h" sl@0: #include sl@0: sl@0: #define INFO_PRINTF9(p1, p2, p3, p4, p5, p6, p7, p8, p9) \ sl@0: {\ sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6), (p7), (p8), (p9));\ sl@0: } sl@0: sl@0: #define ERR_PRINTF9(p1, p2, p3, p4, p5, p6, p7, p8, p9) \ sl@0: {\ sl@0: Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6), (p7), (p8), (p9));\ sl@0: } sl@0: sl@0: #define TESTTRUEL(a) \ sl@0: {\ sl@0: TBool b = a;\ sl@0: if(!b){\ sl@0: if(iCurrentRunIsLowMemory)\ sl@0: {\ sl@0: INFO_PRINTF1(_L("TESTTRUEL failed."));\ sl@0: }\ sl@0: else\ sl@0: {\ sl@0: ERR_PRINTF1(_L("TESTTRUEL failed."));\ sl@0: }\ sl@0: User::Leave(KErrGeneral);\ sl@0: }\ sl@0: } sl@0: sl@0: #define TESTEQUALL(actual, expected) \ sl@0: {\ sl@0: TBool b = (actual == expected);\ sl@0: if(!b){\ sl@0: if(iCurrentRunIsLowMemory)\ sl@0: {\ sl@0: INFO_PRINTF3(_L("TESTEQUALL failed. Expected %i, got %i"), expected, actual);\ sl@0: }\ sl@0: else\ sl@0: {\ sl@0: ERR_PRINTF3(_L("TESTEQUALL failed. Expected %i, got %i"), expected, actual);\ sl@0: }\ sl@0: User::Leave(KErrGeneral);\ sl@0: }\ sl@0: } sl@0: sl@0: #define TESTSIZEEQUALL(actual, expected) \ sl@0: {\ sl@0: TSize a = actual;\ sl@0: TSize b = expected;\ sl@0: TBool c = (actual == expected);\ sl@0: if(!c){\ sl@0: if(iCurrentRunIsLowMemory)\ sl@0: {\ sl@0: INFO_PRINTF5(_L("TESTEQUALL failed. Expected (%i,%i), got (%i,%i)"), b.iHeight, b.iWidth, a.iHeight, a.iWidth);\ sl@0: }\ sl@0: else\ sl@0: {\ sl@0: ERR_PRINTF5(_L("TESTEQUALL failed. Expected (%i,%i), got (%i,%i)"), b.iHeight, b.iWidth, a.iHeight, a.iWidth);\ sl@0: }\ sl@0: User::Leave(KErrGeneral);\ sl@0: }\ sl@0: } sl@0: sl@0: #define TESTCOLOREQUALL(actual, expected) \ sl@0: {\ sl@0: TRgb a = actual;\ sl@0: TRgb b = expected;\ sl@0: TBool c = (actual == expected);\ sl@0: if(!c){\ sl@0: if(iCurrentRunIsLowMemory)\ sl@0: {\ sl@0: INFO_PRINTF9(_L("TESTEQUALL failed. Expected (RGBA) (%i,%i,%i,%i), got (%i,%i,%i,%i)"), b.Red(), b.Green(), b.Blue(), b.Alpha(), a.Red(), a.Green(), a.Blue(), a.Alpha());\ sl@0: }\ sl@0: else\ sl@0: {\ sl@0: ERR_PRINTF9(_L("TESTEQUALL failed. Expected (RGBA) (%i,%i,%i,%i), got (%i,%i,%i,%i)"), b.Red(), b.Green(), b.Blue(), b.Alpha(), a.Red(), a.Green(), a.Blue(), a.Alpha());\ sl@0: }\ sl@0: User::Leave(KErrGeneral);\ sl@0: }\ sl@0: } sl@0: sl@0: #define TESTNOTEQUALL(actual, notexpected) \ sl@0: {\ sl@0: TBool b = (actual == notexpected);\ sl@0: if(b){\ sl@0: if(iCurrentRunIsLowMemory)\ sl@0: {\ sl@0: INFO_PRINTF2(_L("TESTNOTEQUALL failed. Expected not to get %i but did"), notexpected);\ sl@0: }\ sl@0: else\ sl@0: {\ sl@0: ERR_PRINTF2(_L("TESTNOTEQUALL failed. Expected not to get %i but did"), notexpected);\ sl@0: }\ sl@0: User::Leave(KErrGeneral);\ sl@0: }\ sl@0: } sl@0: sl@0: #define TESTNOERRORL(a) \ sl@0: {\ sl@0: TInt b = a;\ sl@0: if(KErrNone != b){\ sl@0: if(iCurrentRunIsLowMemory)\ sl@0: {\ sl@0: INFO_PRINTF2(_L("Error code returned: %i"), b);\ sl@0: }\ sl@0: else\ sl@0: {\ sl@0: ERR_PRINTF2(_L("Unexpected error code returned: %i"), b);\ sl@0: }\ sl@0: User::Leave(b);\ sl@0: }\ sl@0: } sl@0: sl@0: #define TESTEXPECTEDERRORL(a, aExpectedError) \ sl@0: {\ sl@0: TInt b = a;\ sl@0: if(b != aExpectedError){\ sl@0: if(iCurrentRunIsLowMemory)\ sl@0: {\ sl@0: INFO_PRINTF3(_L("Expected error %i, but instead returned: %i"), aExpectedError, b);\ sl@0: }\ sl@0: else\ sl@0: {\ sl@0: ERR_PRINTF3(_L("Expected error %i, but instead returned: %i"), aExpectedError, b);\ sl@0: }\ sl@0: User::Leave(b);\ sl@0: }\ sl@0: } sl@0: sl@0: /** Base class used by all fbs extended bitmap test classes. Allows out of memory testing to sl@0: be carried out easily for each test case. sl@0: */ sl@0: class CTFbsBase : public CTGraphicsBase sl@0: { sl@0: public: sl@0: CTFbsBase(CTestStep* aStep, TBool aRunWithLowMemory); sl@0: ~CTFbsBase(); sl@0: sl@0: static TRgb ExtractRgb(TUint8* aBuffer, TInt aPixelOffset, TDisplayMode aDispMode); sl@0: sl@0: protected: sl@0: // From CTGraphicsStep sl@0: virtual void RunTestCaseL(TInt aCurTestCase); sl@0: sl@0: // Fbs test - to be implemented by test class sl@0: virtual void RunFbsTestL(TInt aCurTestCase) = 0; sl@0: sl@0: void SetLastTestCase(); sl@0: sl@0: private: sl@0: CTestStep& iTestStep; sl@0: TBool iLastTestCase; sl@0: sl@0: protected: sl@0: TBool iRunWithLowMemory; sl@0: TBool iCurrentRunIsLowMemory; sl@0: sl@0: }; sl@0: sl@0: #endif //TFBSBASE_H