sl@0
|
1 |
// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#ifndef TEXTENDEDBITMAPCOMMON_H
|
sl@0
|
17 |
#define TEXTENDEDBITMAPCOMMON_H
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "test/TGraphicsHarness.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
// Uid for use when testing an extended bitmap that does not need to be
|
sl@0
|
22 |
// drawn using the example rasterizer.
|
sl@0
|
23 |
const TUid KUidTestExtendedBitmap = TUid::Uid(0xFFFFFFFF);
|
sl@0
|
24 |
|
sl@0
|
25 |
// Macros to automatically test error condition and report when test fails.
|
sl@0
|
26 |
#define TESTCREATEEXTENDEDBITMAPL(sizeInPixels, displayMode, typeUid, data, dataSize, aExpectedError) \
|
sl@0
|
27 |
{\
|
sl@0
|
28 |
CFbsBitmap* bmp = new(ELeave)CFbsBitmap;\
|
sl@0
|
29 |
TInt res = bmp->CreateExtendedBitmap(sizeInPixels, displayMode, typeUid, data, dataSize);\
|
sl@0
|
30 |
delete bmp;\
|
sl@0
|
31 |
TESTEXPECTEDERRORL(res, aExpectedError);\
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
#define TESTCREATEEXTENDEDBITMAPINITIALIZERL(sizeInPixels, displayMode, typeUid, data, dataSize, aExpectedError) \
|
sl@0
|
35 |
{\
|
sl@0
|
36 |
CFbsBitmap* bmp2 = new(ELeave)CFbsBitmap;\
|
sl@0
|
37 |
CleanupStack::PushL(bmp2);\
|
sl@0
|
38 |
CTestExtendedBitmapInitializer* initializer = new(ELeave) CTestExtendedBitmapInitializer(data, dataSize);\
|
sl@0
|
39 |
TInt res2 = bmp2->CreateExtendedBitmap(sizeInPixels, displayMode, typeUid, dataSize, *initializer);\
|
sl@0
|
40 |
delete initializer;\
|
sl@0
|
41 |
CleanupStack::PopAndDestroy(bmp2);\
|
sl@0
|
42 |
TESTEXPECTEDERRORL(res2, aExpectedError);\
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
|
sl@0
|
46 |
class CTestExtendedBitmapInitializer : public CBase, public MFbsExtendedBitmapInitializer
|
sl@0
|
47 |
{
|
sl@0
|
48 |
public:
|
sl@0
|
49 |
CTestExtendedBitmapInitializer(const TUint8* aTestData, const TInt aTestDataSize);
|
sl@0
|
50 |
|
sl@0
|
51 |
// From MFbsExtendedBitmapInitializer
|
sl@0
|
52 |
TInt InitExtendedBitmap(TAny* aData, TInt aDataSize);
|
sl@0
|
53 |
private:
|
sl@0
|
54 |
const TInt iTestDataSize;
|
sl@0
|
55 |
const TUint8* iTestData;
|
sl@0
|
56 |
};
|
sl@0
|
57 |
|
sl@0
|
58 |
inline CTestExtendedBitmapInitializer::CTestExtendedBitmapInitializer(const TUint8* aTestData, const TInt aTestDataSize)
|
sl@0
|
59 |
: iTestDataSize(aTestDataSize), iTestData(aTestData)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
inline TInt CTestExtendedBitmapInitializer::InitExtendedBitmap(TAny* aData, TInt aDataSize)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
if (!iTestData || iTestDataSize < aDataSize)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
// Used to test handling of initializer error by CreateExtendedBitmap() and for
|
sl@0
|
68 |
// GRAPHICS-FBSERV-EXTENDEDBITMAP-0014 - CTExtendedBitmapNegative::CreateNullDataL()
|
sl@0
|
69 |
// to be returned the correct error on providing NULL data
|
sl@0
|
70 |
return KErrUnderflow;
|
sl@0
|
71 |
}
|
sl@0
|
72 |
Mem::Copy(aData, iTestData, aDataSize);
|
sl@0
|
73 |
return KErrNone;
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
|
sl@0
|
77 |
#endif // TEXTENDEDBITMAPCOMMON_H
|