1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tdynamicres/inc/teflogextensions.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,110 @@
1.4 +/*
1.5 +* Copyright (c) 2008-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 +* @file
1.19 +*
1.20 +*
1.21 +*/
1.22 +
1.23 +
1.24 +
1.25 +#ifndef __TEF_LOG_EXTENSIONS__
1.26 +#define __TEF_LOG_EXTENSIONS__
1.27 +
1.28 +#include <test/tefunit.h>
1.29 +
1.30 +/*
1.31 +This file contains extensions to the TEF macros used for logging, defined in
1.32 +tefunit.h.
1.33 +*/
1.34 +
1.35 +/*
1.36 +Wrapper to check for an error, then print it and leave with it if not KErrNone.
1.37 +do ... while (0) ensures the macro can be treated like a single statement. A
1.38 +macro is used to get the line number information.
1.39 +Note that p1 will be evaluated once and only once.
1.40 +*/
1.41 +#define PRINT_ON_ERROR2_L(test, p1, p2) \
1.42 + do \
1.43 + { \
1.44 + TInt result = (test); \
1.45 + if (result != KErrNone) \
1.46 + { \
1.47 + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)); \
1.48 + User::Leave(result); \
1.49 + } \
1.50 + } \
1.51 + while (0)
1.52 +
1.53 +#define PRINT_ON_ERROR3_L(test, p1, p2, p3) \
1.54 + do \
1.55 + { \
1.56 + TInt result = (test); \
1.57 + if (result != KErrNone) \
1.58 + { \
1.59 + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)); \
1.60 + User::Leave(result); \
1.61 + } \
1.62 + } \
1.63 + while (0)
1.64 +
1.65 +/*
1.66 +Modified version of ASSERT_EQUALS() that will log the expression tested, the
1.67 +expected result and the actual one.
1.68 +*/
1.69 +#define ASSERT_CONDITION(c) _LIT(KExpression, c);
1.70 +
1.71 +#define ASSERT_EQUALS_X(aExpression, aExpected) \
1.72 + do \
1.73 + { \
1.74 + TInt result = (TInt)(aExpression); \
1.75 + TInt expected = (TInt)(aExpected); \
1.76 + if (result != expected) \
1.77 + { \
1.78 + ASSERT_CONDITION(#aExpression); \
1.79 + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S == %d, not %d"), &KExpression(), result, expected ); \
1.80 + User::Leave(KErrTEFUnitFail); \
1.81 + } \
1.82 + } \
1.83 + while (0)
1.84 +
1.85 +#define ASSERT_NOT_EQUALS_X(aExpression, aUnexpected) \
1.86 + do \
1.87 + { \
1.88 + TInt result = (TInt)(aExpression); \
1.89 + TInt unexpected = (TInt)(aUnexpected); \
1.90 + if (result == unexpected) \
1.91 + { \
1.92 + ASSERT_CONDITION(#aExpression); \
1.93 + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S == %d, unexpectedly"), &KExpression(), result ); \
1.94 + User::Leave(KErrTEFUnitFail); \
1.95 + } \
1.96 + } \
1.97 + while (0)
1.98 +
1.99 +#define ASSERT_TRUE_X(aExpression) \
1.100 + do \
1.101 + { \
1.102 + TBool result = (TBool)(aExpression); \
1.103 + if (!result) \
1.104 + { \
1.105 + ASSERT_CONDITION(#aExpression); \
1.106 + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S false"), &KExpression() ); \
1.107 + User::Leave(KErrTEFUnitFail); \
1.108 + } \
1.109 + } \
1.110 + while (0)
1.111 +
1.112 +#endif // __TEF_LOG_EXTENSIONS__
1.113 +